Skip to content

# `Canvas`

## FL.Canvas = class Canvas(object)

      ===============================================
        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 to assign attributes to Canvas object

      CONSTRUCTOR:
        ++ 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

      ATTRIBUTES:
        delta (Point) - horizontal shift during coordinates transformation
        scale (Point(float)) - scaling during coordinates transformation
        width (integer, read-only) - width of the canvas in pixels
        height (integer, read-only) - height of the canvas in pixels
        draw_style (integer, write-only) - sets current drawing mode (copy, XOR, invert etc.)
        pen_color (integer, write-only) - sets current pen color
        pen_style (integer, write-only) - sets current pen style (solid, dashed etc.)
        brush_color (integer, write-only) - sets current brush color
        brush_style (integer, write-only) -  sets current brush style (solid, patterned etc.)
        text_color (integer, write-only) - sets color for a text
        bk_color (integer, write-only) - sets color for a text background
        bk_mode (integer, write-only) - sets background mode for a text output (transparent or opaque)

      OPERATIONS:

      METHODS
        MoveTo(Point p) | (x, y) - moves current position to p or (x, y) coordinates
        LineTo(Point p) | (x, y) - draws a straight line to the position p or (x, y)
        CurveTo(Point p0, Point p1, Point p2) - draws a 3th-order Bezier curve from the current point to points p0, p1, p2
        SplineTo(Point p0, Point p1) - draws a 2th-order Bezier curve from the current point to points p0, p1
        Ellipse(Rect r) | (Point p0, Point p1) | (x0, y0, x1, y1) - draws a filled ellipse defined by the Rect r, points p0 and p1 or set of coordinates
        Rectangle(Rect r) | (Point p0, Point p1) | (x0, y0, x1, y1) - draws a filled rectangle defined by the Rect r, points p0 and p1 or set of coordinates
        Convert(Point p) - converts coordinates from the source coordinate space to screen coordinates
        UnConvert(Point p) - converts screen coordinates to the currently defined coordinate space
        FitGlyph(Rect r, Glyph g) | (Rect r, Glyph g, WeightVector w) - recalculates parameters of coordinate conversion function to fit glyph g into rectangle r using currently selected options.
        FillGlyph(Glyph g) | (Glyph g, WeightVector w) - fills the glyph g using current coordinate transformation.
        OutlineGlyph(Glyph g) | (Glyph g, WeightVector w) - draws the glyph g outline using current coordinate transformation.
        TextOut(Point p, string s) | (x, y, string s) - draws the string s in the position p or (x, y)
        PutImage(Image i, Point p) | (Image i, Pioint p, int mode) - puts Image i at the selected point

#### Methods

Convert(...)

CurveTo(...)

Ellipse(...)

FillGlyph(...)

FitGlyph(...)

LineTo(...)

MoveTo(...)

OutlineGlyph(...)

PutImage(...)

Rectangle(...)

SplineTo(...)

TextOut(...)

UnConvert(...)

__delattr__(...)

      x.__delattr__('name') <==> del x.name

__getattribute__(...)

      x.__getattribute__('name') <==> x.name

__init__(...)

      x.__init__(...) initializes x; see help(type(x)) for signature

__repr__(...)

      x.__repr__() <==> repr(x)

__setattr__(...)

      x.__setattr__('name', value) <==> x.name = value

#### Attributes

__new__ = <built-in method __new__ of type object>

      T.__new__(S, ...) -> a new object with type S, a subtype of T