Shape class

Drawing helper class, equivalent to PyMuPDF's Shape.

Provides methods to draw lines, rectangles, circles, curves, and other shapes on a PDF page, then commit them to the content stream.

Usage:

final shape = Shape(page);
shape.drawLine(Point(50, 50), Point(200, 50));
shape.drawRect(Rect(100, 100, 300, 200));
shape.finish(color: [0, 0, 0], width: 1);
shape.commit();

Constructors

Shape({required double pageWidth, required double pageHeight})
Create a new Shape for a page.

Properties

hasDrawings bool
Whether there are uncommitted drawings.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasPath bool
Whether the current path has elements.
no setter
pageHeight double
Height of the page.
final
pageWidth double
Width of the page.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalContents int
Sum of all drawing commands.
getter/setter pair

Methods

commit({bool overlay = true}) String
Commit all drawing commands to the page content stream.
drawBezier(Point p1, Point p2, Point p3, Point p4) Point
Draw a Bezier curve.
drawCircle(Point center, double radius) Point
Draw a circle with given center and radius.
drawLine(Point p1, Point p2) Point
Draw a line from p1 to p2.
drawOval(Rect rect) Point
Draw an oval inscribed in a rectangle.
drawPolyline(List<Point> points) Point
Draw a sequence of connected lines.
drawQuad(Quad quad) Point
Draw a quadratic Bezier curve.
drawRect(Rect rect) Point
Draw a rectangle.
drawSector(Point center, Point point, double angle, {bool fullSector = true}) Point
Draw a sector (pie slice).
drawSquiggle(Point p1, Point p2, {double breadth = 2}) Point
Draw a squiggly (wavy) line.
drawZigzag(Point p1, Point p2, {double breadth = 2}) Point
Draw a zigzag line.
finish({List<double>? color, List<double>? fill, double width = 1, List<double>? dashes, int lineCap = 0, int lineJoin = 0, bool closePath = false, bool even_odd = false, double opacity = 1, double fillOpacity = 1, String? morph}) → void
Finish the current path with stroke/fill properties.
insertText(Point point, String text, {double fontSize = 11, String fontName = 'Helvetica', List<double>? color, double rotate = 0}) int
Insert text at a point.
insertTextbox(Rect rect, String text, {double fontSize = 11, String fontName = 'Helvetica', List<double>? color, int align = 0}) double
Insert text into a rectangle.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited