-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add polygons to draw filled polygons
- Loading branch information
1 parent
bcb592a
commit 8ca2b8b
Showing
5 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// This file is released into Public Domain. | ||
use crate::common::*; | ||
use gnuplot::*; | ||
|
||
mod common; | ||
|
||
fn example(c: Common) | ||
{ | ||
let coords = [[0., 0.], [1., 1.], [2., 0.5], [2., -0.5], [1., -1.]]; | ||
|
||
let mut fg = Figure::new(); | ||
fg.set_title("Polygons"); | ||
|
||
let ax = fg.axes2d(); | ||
ax.polygon( | ||
coords.iter().map(|x| x[0]), | ||
coords.iter().map(|x| x[1]), | ||
&[], | ||
); | ||
|
||
ax.polygon( | ||
coords.iter().map(|x| x[0] + 2.), | ||
coords.iter().map(|x| x[1]), | ||
&[FillAlpha(0.), BorderColor("black"), LineWidth(4.)], | ||
); | ||
ax.polygon( | ||
coords.iter().map(|x| x[0]), | ||
coords.iter().map(|x| x[1] + 2.), | ||
&[Color("#FF0000"), BorderColor("black"), LineWidth(4.)], | ||
); | ||
ax.polygon( | ||
coords.iter().map(|x| x[0] + 2.), | ||
coords.iter().map(|x| x[1] + 2.), | ||
&[ | ||
FillPattern(Fix(BigCrosses)), | ||
Color("#FF0000"), | ||
BorderColor("black"), | ||
LineWidth(4.), | ||
LineStyle(Dash), | ||
], | ||
); | ||
c.show(&mut fg, "polygons"); | ||
} | ||
|
||
fn main() | ||
{ | ||
Common::new().map(|c| example(c)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters