SourceEnum Shape
from egui import Shapeclass Shape:A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).
You should generally recreate your Shapes each frame,
but storing them should also be fine with one exception:
Shape.Text depends on the current pixels_per_point (dpi scale)
and so must be recreated every time pixels_per_point changes.
Methods§
def as_circle(self, /) -> CircleShape |None§
def as_cubic_bezier(self, /) -> CubicBezierShape |None§
def as_ellipse(self, /) -> EllipseShape |None§
def as_line_segment(self, /) -> tuple[Pos2, Pos2, Stroke] |None§
def as_mesh(self, /) -> Mesh |None§
def as_path(self, /) -> PathShape |None§
def as_quadratic_bezier(self, /) -> QuadraticBezierShape |None§
def as_rect(self, /) -> RectShape |None§
def as_text(self, /) -> TextShape |None§
def as_vec(self, /) -> list[Shape] |None§
def callback_rect(self, /) -> Rect |None§
@staticmethod
def circle(shape: CircleShape) -> Shape§
Source@staticmethod
def circle_filled(center: Pos2, radius: float, fill_color: Color32) -> Shape§
Source@staticmethod
def circle_stroke(center: Pos2, radius: float, stroke: Stroke) -> Shape§
Source@staticmethod
def closed_line(points: Sequence[Pos2], stroke: PathStroke) -> Shape§
A line that closes back to the start point again.
Source@staticmethod
def convex_polygon(points: Sequence[Pos2], fill: Color32, stroke: PathStroke) -> Shape§
A convex polygon with a fill and optional stroke.
The most performant winding order is clockwise.
@staticmethod
def cubic_bezier(shape: CubicBezierShape) -> Shape§
Source@staticmethod
def dashed_line(path: Sequence[Pos2], stroke: Stroke, dash_length: float, gap_length: float) -> list[Shape]§
Turn a line into dashes.
Source@staticmethod
def dashed_line_with_offset(path: Sequence[Pos2], stroke: Stroke, dash_lengths: Sequence[float], gap_lengths: Sequence[float], dash_offset: float) -> list[Shape]§
Turn a line into dashes with different dash/gap lengths and a start offset.
Source@staticmethod
def dotted_line(path: Sequence[Pos2], color: Color32, spacing: float, radius: float) -> list[Shape]§
Turn a line into equally spaced dots.
@staticmethod
def ellipse(shape: EllipseShape) -> Shape§
Source@staticmethod
def ellipse_filled(center: Pos2, radius: Vec2, fill_color: Color32) -> Shape§
Source@staticmethod
def ellipse_stroke(center: Pos2, radius: Vec2, stroke: Stroke) -> Shape§
Source@staticmethod
def galley(pos: Pos2, galley: Galley, fallback_color: Color32) -> Shape§
Any uncolored parts of the Galley (using Color32.PLACEHOLDER) will be replaced with the given color.
Any non-placeholder color in the galley takes precedence over this fallback color.
Source@staticmethod
def galley_with_override_text_color(pos: Pos2, galley: Galley, text_color: Color32) -> Shape§
All text color in the Galley will be replaced with the given color.
Source@staticmethod
def gradient_rect(rect: Rect, direction: Direction, from: Color32, to: Color32) -> Shape§
Paints a gradient rectangle that transitions from color_from to color_to
along the given direction.
For example, Direction.TopDown paints color_from at the top edge fading
to color_to at the bottom edge.
Source@staticmethod
def hline(min_x: float, max_x: float, y: float, stroke: Stroke) -> Shape§
A horizontal line.
Source@staticmethod
def image(texture_id: TextureId, rect: Rect, uv: Rect, tint: Color32) -> Shape§
An image at the given position.
uv should normally be Rect.from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))
unless you want to crop or flip the image.
tint is a color multiplier. Use Color32.WHITE if you don't want to tint the image.
def kind(self, /) -> str§
Source@staticmethod
def line(points: Sequence[Pos2], stroke: PathStroke) -> Shape§
A line through many points.
Use egui.Shape.line_segment instead if your line only connects two points.
Source@staticmethod
def line_segment(a: Pos2, b: Pos2, stroke: Stroke) -> Shape§
A line between two points.
More efficient than calling egui.Shape.line.
Source@staticmethod
def mesh(mesh: Mesh) -> Shape§
@staticmethod
def noop() -> Shape§
@staticmethod
def path(shape: PathShape) -> Shape§
@staticmethod
def quadratic_bezier(shape: QuadraticBezierShape) -> Shape§
@staticmethod
def rect(shape: RectShape) -> Shape§
Source@staticmethod
def rect_filled(rect: Rect, corner_radius: Any, fill_color: Color32) -> Shape§
See also egui.Shape.rect_stroke.
Source@staticmethod
def rect_stroke(rect: Rect, corner_radius: Any, stroke: Stroke, stroke_kind: StrokeKind) -> Shape§
See also egui.Shape.rect_filled.
Sourcedef scale(self, /, factor: float) -> None§
Scale the shape by factor, in-place.
A wrapper around egui.Shape.transform.
Source@staticmethod
def text(shape: TextShape) -> Shape§
Sourcedef texture_id(self, /) -> TextureId§
Sourcedef transform(self, /, transform: TSTransform) -> None§
Transform (move/scale) the shape in-place.
If using a PaintCallback, note that only the rect is scaled as opposed
to other shapes where the stroke is also scaled.
Sourcedef translate(self, /, delta: Vec2) -> None§
Move the shape by delta, in-place.
A wrapper around egui.Shape.transform.
@staticmethod
def vec(shapes: Sequence[Any]) -> Shape§
Sourcedef visual_bounding_rect(self, /) -> Rect§
The visual bounding rectangle (includes stroke widths)
Source@staticmethod
def vline(x: float, min_y: float, max_y: float, stroke: Stroke) -> Shape§
A vertical line.