pub struct Sector {
pub top_left: Point,
pub diameter: u32,
pub angle_start: Angle,
pub angle_sweep: Angle,
}
Expand description
Sector primitive
§Examples §Create some sectors with different stylesuse embedded_graphics::{
pixelcolor::Rgb565,
prelude::*,
primitives::{Sector, PrimitiveStyle, PrimitiveStyleBuilder},
};
Sector::new(Point::new(10, 20), 30, 0.0.deg(), 90.0.deg())
.into_styled(PrimitiveStyle::with_stroke(Rgb565::WHITE, 1))
.draw(&mut display)?;
let style = PrimitiveStyleBuilder::new()
.stroke_color(Rgb565::RED)
.stroke_width(3)
.fill_color(Rgb565::GREEN)
.build();
Sector::new(Point::new(10, 20), 30, 180.0.deg(), -90.0.deg())
.into_styled(style)
.draw(&mut display)?;
Sector::new(Point::new(10, 20), 30, 0.0.deg(), 90.0.deg())
.translate(Point::new(15, 5))
.into_styled(PrimitiveStyle::with_fill(Rgb565::BLUE))
.draw(&mut display)?;
Top-left point of the bounding-box of the circle supporting the sector
Diameter of the circle supporting the sector
Angle at which the sector starts
Angle defining the sector sweep starting at angle_start
Source§ SourceCreate a new sector delimited with a top-left point with a specific diameter and start and sweep angles
SourceCreate a new sector centered around a given point with a specific diameter and start and sweep angles
SourceCreates an arc based on a circle.
The resulting sector will match the top_left
and diameter
of the base circle.
Returns a circle with the same top_left
and diameter
as this sector.
Return the center point of the sector
Source§ Source§ Source§Returns true
if the given point is inside the shape.
Writes the defmt representation of self
to fmt
.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between
self
and
other
values if one exists.
Read more 1.0.0 · Source§Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more 1.0.0 · Source§Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more 1.0.0 · Source§Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more 1.0.0 · Source§Tests greater than or equal to (for
self
and
other
) and is used by the
>=
operator.
Read more Source§ Source§Iterator over all points inside the primitive.
Source§Returns an iterator over all points inside the primitive.
Source§ Source§Converts this primitive into a Styled
.
Returns the bounding box using the given style.
Source§ Source§ Source§Translate the sector from its current position to a new position by (x, y) pixels, returning a new Sector
. For a mutating transform, see translate_mut
.
let sector = Sector::new(Point::new(5, 10), 10, 0.0.deg(), 90.0.deg());
let moved = sector.translate(Point::new(10, 10));
assert_eq!(moved.top_left, Point::new(15, 20));
Source§
Translate the sector from its current position to a new position by (x, y) pixels.
let mut sector = Sector::new(Point::new(5, 10), 10, 0.0.deg(), 90.0.deg());
sector.translate_mut(Point::new(10, 10));
assert_eq!(sector.top_left, Point::new(15, 20));
Source§ Source§
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4