FL.objects.Canvas.Canvas

class FL.objects.Canvas.Canvas(canvas: Canvas | None = None)

Bases: Copyable

Canvas - 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_color

bk_mode

brush_color

brush_style

delta

Horizontal shift during coordinates transformation

draw_style

parent

parent object

pen_color

pen_style

scale

Scaling during coordinates transformation

text_color

Convert(p: Point) 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

Parameters:
  • p0 (Point) – _description_

  • p1 (Point) – _description_

  • p2 (Point) – _description_

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

Parameters:
  • r_or_p0_or_x0 (Rect | Point | float) – _description_

  • p1_or_y0 (Point | float | None, optional) – _description_. Defaults to None.

  • x1 (float | None, optional) – _description_. Defaults to None.

  • y1 (float | None, optional) – _description_. Defaults to None.

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:
LineTo(p_or_x: Point | float, y: float | None = None) None

Draws a straight line to the position p or (x, y) coordinates

Parameters:
  • p_or_x (Point | float) – _description_

  • y (float | None, optional) – _description_. Defaults to None.

MoveTo(p_or_x: Point | float, y: float | None = None) None

Moves current position to p or (x, y) coordinates

Parameters:
  • p_or_x (Point | float) – _description_

  • y (float | None, optional) – _description_. Defaults to None.

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.

PutImage(i: Image, p: Point, mode: int | None = None) None

Puts Image i at the selected point

Parameters:
  • i (Image) – _description_

  • p (Point) – _description_

  • mode (int | 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

Parameters:
  • r_or_p0_or_x0 (Rect | Point | float) – _description_

  • p1_or_y0 (Point | float | None, optional) – _description_. Defaults to None.

  • x1 (float | None, optional) – _description_. Defaults to None.

  • y1 (float | None, optional) – _description_. Defaults to None.

SplineTo(p0: Point, p1: Point) None

Draws a 2th-order Bezier curve from the current point to points p0, p1

Parameters:
  • p0 (Point) – _description_

  • p1 (Point) – _description_

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)

Parameters:
  • p_or_x (Point | float) – _description_

  • s_or_y (str | float) – _description_

  • s (str | None, optional) – _description_. Defaults to None.

UnConvert(p: Point) Point

Converts screen coordinates to the currently defined coordinate space

Parameters:

p (Point) – _description_

property delta: Point

Horizontal shift during coordinates transformation

Returns:

_description_

Return type:

Point

property parent: Any

parent object

Returns:

The parent

Return type:

Any

property scale: Point

Scaling during coordinates transformation

Returns:

_description_

Return type:

Point