Class SelDCSurface

all stuffs related to Cairo surfaces and especially graphics verbs

Methods

SelDCSurface:OperatorConst (operator) transcode operators capabilities.
SelDCSurface:create (width, height) Create a surface for drawing
SelDCSurface:SubSurface (x, y, width, hight) Create a SubSurface from this surface.
SelDCSurface:Release () Delete a surface
SelDCSurface:destroy () Delete a surface
SelDCSurface:GetSize () Return surface's size
SelDCSurface:GetWidth () Return surface's width
SelDCSurface:GetHight () Return surface's hight
SelDCSurface:SaveContext () Push cairo context for latter use.
SelDCSurface:RestoreContext () Restore previously saved cairo context
SelDCSurface:SetSourcePattern (pattern) Set source the given pattern
SelDCSurface:SetSourceSurface (surface, x, y) Set source the given surface
SelDCSurface:SetColor (r, g, b, opacity) Set foreground color
SelDCSurface:SetPenWidth (width) Set line width when drawing
SelDCSurface:SetOperator (mode) Sets the compositing operator to be used for all drawing operations
SelDCSurface:Scale (x, y) Scale the surface
SelDCSurface:SetClip (x1, y1, x2, y2) Restrict drawing to a rectangular area
SelDCSurface:SetClipS (x, y, width, hight) Restrict drawing to a rectangular area
SelDCSurface:ResetClip () Remove clipping restriction : drawing can be done everywhere on the surface.
SelDCSurface:Clear (r, g, b, opacity, width) Fill a surface with given color
SelDCSurface:DrawLine (x1, y1, x2, y2, width) Draw a line
SelDCSurface:DrawRectangle (x, y, width, hight, width) Draw a rectangle
SelDCSurface:FillRectangle (x1, y1, width, hight) Draw a filled rectangle
SelDCSurface:FillTriangle (x1, y1, x2, y2, x3, y3) Draw a filled triangle
SelDCSurface:DrawArc (x, y, radius, start_angle, end_angle, width, safe) Draw an arc.
SelDCSurface:FillArc (x, y, radius, start_angle, end_angle, width, safe) Draw a filled arc.
SelDCSurface:Paint () drawing operator that paints the current source everywhere within the current clip region
SelDCSurface:Blit (source, x, y, xs, ys, width, height) Blit another surface to the current one.
SelDCSurface:SetFont (font, size) Set Font to use
SelDCSurface:DrawString (text, x, y) Draw a string with the current font.
SelDCSurface:DrawStringTop (text, x, y) Draw a string with the current font.
SelDCSurface:GetFontExtents () Return current font extents
SelDCSurface:GetStringExtents (text, width, hight) Gets the extents for a string of text
SelDCSurface:getStatus () return Cairo's status.
SelDCSurface:Dump (directory, prefix) Save the surface as a PNG file


Methods

SelDCSurface:OperatorConst (operator)
transcode operators capabilities.

See Cairo's documentation for full list of operators

Parameters:

Returns:

    int value
SelDCSurface:create (width, height)
Create a surface for drawing

Parameters:

  • width integer
  • height integer
SelDCSurface:SubSurface (x, y, width, hight)
Create a SubSurface from this surface.

It's only a portion of the mother surface on which drawing are clipped and origin is translated to its top-left corner.

No addition buffer is allocated and all graphical manipulation are directly impacting the mother surface.

Parameters:

  • x Number left top corner
  • y Number left top corner
  • width Number
  • hight Number

Returns:

    SelDCSurface surface
SelDCSurface:Release ()
Delete a surface Remove all references to its objects.
SelDCSurface:destroy ()
Delete a surface Remove all references to its objects.
SelDCSurface:GetSize ()
Return surface's size

Returns:

  1. integer width
  2. integer hight
SelDCSurface:GetWidth ()
Return surface's width

Returns:

    integer width
SelDCSurface:GetHight ()
Return surface's hight

Returns:

    integer hight
SelDCSurface:SaveContext ()
Push cairo context for latter use.

Useful to modify temporary drawing context

SelDCSurface:RestoreContext ()
Restore previously saved cairo context
SelDCSurface:SetSourcePattern (pattern)
Set source the given pattern

Parameters:

SelDCSurface:SetSourceSurface (surface, x, y)
Set source the given surface

Parameters:

  • surface SelDCSurface
  • x Number surface origin (default 0)
  • y Number surface origin (default 0)
SelDCSurface:SetColor (r, g, b, opacity)
Set foreground color

Parameters:

  • r Number component saturation from 0 to 1
  • g Number component saturation from 0 to 1
  • b Number component saturation from 0 to 1
  • opacity Number component saturation from 0 to 1
SelDCSurface:SetPenWidth (width)
Set line width when drawing

Parameters:

  • width Number
SelDCSurface:SetOperator (mode)
Sets the compositing operator to be used for all drawing operations

Parameters:

  • mode integer

See also:

SelDCSurface:Scale (x, y)
Scale the surface

Parameters:

  • x Number scale factor
  • y Number scale factor
SelDCSurface:SetClip (x1, y1, x2, y2)
Restrict drawing to a rectangular area

Parameters:

  • x1 Number left top corner
  • y1 Number left top corner
  • x2 Number bottom right corner
  • y2 Number bottom right corner
SelDCSurface:SetClipS (x, y, width, hight)
Restrict drawing to a rectangular area

Parameters:

  • x Number left top corner
  • y Number left top corner
  • width Number
  • hight Number
SelDCSurface:ResetClip ()
Remove clipping restriction : drawing can be done everywhere on the surface.
SelDCSurface:Clear (r, g, b, opacity, width)
Fill a surface with given color

Parameters:

  • r Number component saturation from 0 to 1
  • g Number component saturation from 0 to 1
  • b Number component saturation from 0 to 1
  • opacity Number component saturation from 0 to 1
  • width Number line width (optional, 1 by default)
SelDCSurface:DrawLine (x1, y1, x2, y2, width)
Draw a line

Parameters:

  • x1 Number start point
  • y1 Number start point
  • x2 Number end point
  • y2 Number end point
  • width Number line width (optional, 1 by default)
SelDCSurface:DrawRectangle (x, y, width, hight, width)
Draw a rectangle

Parameters:

  • x Number left top corner
  • y Number left top corner
  • width Number line width (optional, 1 by default)
  • hight Number
  • width Number line width (optional, 1 by default)
SelDCSurface:FillRectangle (x1, y1, width, hight)
Draw a filled rectangle

Parameters:

  • x1 Number left top corner
  • y1 Number left top corner
  • width Number
  • hight Number
SelDCSurface:FillTriangle (x1, y1, x2, y2, x3, y3)
Draw a filled triangle

Parameters:

  • x1 Number top #1
  • y1 Number top #1
  • x2 Number top #2
  • y2 Number top #2
  • x3 Number top #3
  • y3 Number top #3
SelDCSurface:DrawArc (x, y, radius, start_angle, end_angle, width, safe)
Draw an arc.

Notez-bien : angles are in radian

Parameters:

  • x Number center of the circle
  • y Number center of the circle
  • radius Number
  • start_angle Number
  • end_angle Number
  • width Number line width (optional, 1 by default)
  • safe boolean if true, ensure end > start (not for development)
SelDCSurface:FillArc (x, y, radius, start_angle, end_angle, width, safe)
Draw a filled arc.

Notez-bien : angles are in radian

Parameters:

  • x Number center of the circle
  • y Number center of the circle
  • radius Number
  • start_angle Number
  • end_angle Number
  • width Number line width (optional, 1 by default)
  • safe boolean if true, ensure end > start (not for development)
SelDCSurface:Paint ()
drawing operator that paints the current source everywhere within the current clip region
SelDCSurface:Blit (source, x, y, xs, ys, width, height)
Blit another surface to the current one.

Notez-bien : Alpha channel is considered during bliting

Parameters:

  • source SelDCSurface source surface
  • x Number target position
  • y Number target position
  • xs Number source position (default 0)
  • ys Number source position (default 0)
  • width integer
  • height integer
SelDCSurface:SetFont (font, size)
Set Font to use

Parameters:

SelDCSurface:DrawString (text, x, y)
Draw a string with the current font.

The position is based on it's baseline.

If the position is not provided, the string is placed at the current drawing position which may be just after the current line.

Parameters:

  • text string
  • x Number string position (optional)
  • y Number string position (optional)
SelDCSurface:DrawStringTop (text, x, y)
Draw a string with the current font.

The position is the top-left of the resulting drawing.

Parameters:

  • text string
  • x Number string position
  • y Number string position
SelDCSurface:GetFontExtents ()
Return current font extents

Returns:

  1. Number height recommended vertical distance between baselines
  2. Number ascent the distance that the font extends above the baseline
  3. Number descent the distance that the font extends below the baseline
  4. Number maxxadvance the maximum space advance in X direction
  5. Number maxyadvance the maximum space advance in Y direction (for vertical one)
SelDCSurface:GetStringExtents (text, width, hight)
Gets the extents for a string of text

Parameters:

  • text string
  • width Number
  • hight Number
SelDCSurface:getStatus ()
return Cairo's status.

Notez-bien : 0, the surface is valid

Returns:

  1. string surface_status surface own status
  2. string cairo_status cairo's context status
SelDCSurface:Dump (directory, prefix)
Save the surface as a PNG file

Parameters:

  • directory string where to save the file
  • prefix string file's prefix

Returns:

  1. string or nil result file written (nil in case of error)
  2. nil or string error error message if any
generated by LDoc 1.4.6 Last updated 2022-09-05 22:24:51