FL.objects.Canvas.Canvas
- class FL.objects.Canvas.Canvas(canvas: Canvas | None = None)
Bases:
CopyableCanvas - class to represent screen paint area and operations
This class can perform automatic coordinates transformations, so you can draw in Glyph coordinate space or, if you prefer, in screen coordinates directly.
Use constants defined for FontLab module in Fldict to assign attributes to Canvas object
- __init__(canvas: Canvas | None = None) None
Never create Canvas object explicitly - they must be obtained from the FontLab’s window classes
Canvas() - generic constructor, creates an empty Canvas Canvas(Canvas) - copy constructor
Methods
Convert(p)Converts coordinates from the source coordinate space
CurveTo(p0, p1, p2)Draws a 3th-order Bezier curve from the current point to points p0, p1, p2
Ellipse(r_or_p0_or_x0[, p1_or_y0, x1, y1])Draws a filled ellipse defined by the Rect r, points p0 and p1 or set of coordinates
FillGlyph(g[, w])Fills the glyph g using current coordinate transformation.
FitGlyph(r, g[, w])Recalculates parameters of coordinate conversion function to fit glyph g into rectangle r using currently selected options.
LineTo(p_or_x[, y])Draws a straight line to the position p or (x, y) coordinates
MoveTo(p_or_x[, y])Moves current position to p or (x, y) coordinates
OutlineGlyph(g[, w])Draws the glyph g outline using current coordinate transformation.
PutImage(i, p[, mode])Puts Image i at the selected point
Rectangle(r_or_p0_or_x0[, p1_or_y0, x1, y1])Draws a filled rectangle defined by the Rect r, points p0 and p1 or set of coordinates
SplineTo(p0, p1)Draws a 2th-order Bezier curve from the current point to points p0, p1
TextOut(p_or_x, s_or_y[, s])Draws the string s in the position p or (x, y)
UnConvert(p)Converts screen coordinates to the currently defined coordinate space
__init__([canvas])Never create Canvas object explicitly - they must be obtained from the FontLab's window classes
Attributes
bk_colorbk_modebrush_colorbrush_styleHorizontal shift during coordinates transformation
draw_styleparent object
pen_colorpen_styleScaling during coordinates transformation
text_color- Convert(p: Point)
Converts coordinates from the source coordinate space
- Parameters:
p (Point) – _description_
- CurveTo(p0: Point, p1: Point, p2: Point) None
Draws a 3th-order Bezier curve from the current point to points p0, p1, p2
- Ellipse(r_or_p0_or_x0: Rect | Point | float, p1_or_y0: Point | float | None = None, x1: float | None = None, y1: float | None = None) None
Draws a filled ellipse defined by the Rect r, points p0 and p1 or set of coordinates
- FillGlyph(g: Glyph, w: WeightVector | None = None) None
Fills the glyph g using current coordinate transformation.
- Parameters:
g (Glyph) – _description_
w (WeightVector | None, optional) – _description_. Defaults to None.
- FitGlyph(r: Rect, g: Glyph, w: WeightVector | None = None) None
Recalculates parameters of coordinate conversion function to fit glyph g into rectangle r using currently selected options.
- Parameters:
r (Rect) – _description_
g (Glyph) – _description_
w (WeightVector) – _description_
- LineTo(p_or_x: Point | float, y: float | None = None) None
Draws a straight line to the position p or (x, y) coordinates
- MoveTo(p_or_x: Point | float, y: float | None = None) None
Moves current position to p or (x, y) coordinates
- OutlineGlyph(g: Glyph, w: WeightVector | None = None) None
Draws the glyph g outline using current coordinate transformation.
- Parameters:
g (Glyph) – _description_
w (WeightVector | None, optional) – _description_. Defaults to None.
- Rectangle(r_or_p0_or_x0: Rect | Point | float, p1_or_y0: Point | float | None = None, x1: float | None = None, y1: float | None = None) None
Draws a filled rectangle defined by the Rect r, points p0 and p1 or set of coordinates
- SplineTo(p0: Point, p1: Point) None
Draws a 2th-order Bezier curve from the current point to points p0, p1
- TextOut(p_or_x: Point | float, s_or_y: str | float, s: str | None = None) None
Draws the string s in the position p or (x, y)
- UnConvert(p: Point)
Converts screen coordinates to the currently defined coordinate space
- Parameters:
p (Point) – _description_