libgpac
Documentation of the core library of GPAC
Canvas Interface Reference

import"evg.idl";

+ Collaboration diagram for Canvas:

Public Member Functions

 Canvas (unsigned long width, unsigned long height, DOMString pixfmt)
 
 Canvas (unsigned long width, unsigned long height, DOMString pixfmt, ArrayBuffer data, optional unsigned long stride=0, optional unsigned long stride_uv=0)
 
void clear (IRect rc, unsigned long r, unsigned long g, unsigned long b, unsigned long a)
 
void clear (IRect rc, DOMString color)
 
void clear (IRect rc, DOMString color)
 
void clearf (IRect rc, double r, double g, double b, double a)
 
void clearf (IRect rc, DOMString color)
 
void fill (Stencil stencil)
 
void fill (Texture texture)
 
void reassign (ArrayBuffer data)
 
Object toRGB (optional bool as_array=false, Float y, Float u, Float v, optional Float a=1.0)
 
Object toRGB (optional bool as_array=false, Vec4f color)
 
Object toYUV (optional bool as_array=false, Float r, Float g, Float b, optional Float a=1.0)
 
Object toYUV (optional bool as_array=false, Vec4f color)
 

Data Fields

attribute boolean centered
 
writeonly Path path
 
writeonly Matrix2D matrix
 
writeonly IRect clipper
 
attribute unsigned long compositeOperation
 
attribute AlphaCallback on_alpha
 

Detailed Description

The Canvas object is used to draw vectorial 2D path

Constructor & Destructor Documentation

◆ Canvas() [1/2]

Canvas::Canvas ( unsigned long  width,
unsigned long  height,
DOMString  pixfmt 
)

Canvas constructor. The canvas memory is owned by the canvas object

Parameters
widththe width in pixels of the canvas
heightthe height in pixels of the canvas
pixfmtthe pixel fomat of the canvas

◆ Canvas() [2/2]

Canvas::Canvas ( unsigned long  width,
unsigned long  height,
DOMString  pixfmt,
ArrayBuffer  data,
optional unsigned long  stride = 0,
optional unsigned long  stride_uv = 0 
)

Canvas constructor

Parameters
widththe width in pixels of the canvas
heightthe height in pixels of the canvas
pixfmtthe pixel fomat of the canvas
datathe data buffer on which to write. The size shall be greater than the size required for the given size and pixel format.
stridehorizontal stride in pixel of the data
stride_uvhorizontal stride in pixel of the data for the U and V planes

Member Function Documentation

◆ clear() [1/3]

void Canvas::clear ( IRect  rc,
unsigned long  r,
unsigned long  g,
unsigned long  b,
unsigned long  a 
)

clears the canvas with the given color - see gf_evg_surface_clear

Note
Omitting the last values will assume 0xFF for alpha, and 0 for other values.
Parameters
rcthe rectangle to clear, in pixel coordinates
rred value, between 0 and 255
ggreen value, between 0 and 255
bblue value, between 0 and 255
aalpha value, between 0 and 255

◆ clear() [2/3]

void Canvas::clear ( IRect  rc,
DOMString  color 
)

clears the canvas with the given color. See gf_evg_surface_clear

Parameters
rcthe rectangle to clear, in pixel coordinates
coloran HTML/SVG color name or an HTML color value formated as $RRGGBB, #RRGGBB or 0xRRGGBB

◆ clear() [3/3]

void Canvas::clear ( IRect  rc,
DOMString  color 
)

clears the canvas with the given color. See gf_evg_surface_clear

Parameters
rcthe rectangle to clear, in pixel coordinates
coloran HTML/SVG color name or an HTML color value formated as $RRGGBB, #RRGGBB or 0xRRGGBB

◆ clearf() [1/2]

void Canvas::clearf ( IRect  rc,
double  r,
double  g,
double  b,
double  a 
)

clears the canvas with the given color

Note
Omitting the last values will assume 1.0 for alpha, and 0.0 for other values. See gf_evg_surface_clear
Parameters
rcthe rectangle to clear, in pixel coordinates
rred value, between 0.0 and 1.0
ggreen value, between 0.0 and 1.0
bblue value, between 0.0 and 1.0
aalpha value, between 0.0 and 1.0

◆ clearf() [2/2]

void Canvas::clearf ( IRect  rc,
DOMString  color 
)

clears the canvas with the given color. See gf_evg_surface_clear

Parameters
rcthe rectangle to clear, in pixel coordinates
coloran HTML/SVG color name or an HTML color value formated as $RRGGBB, #RRGGBB or 0xRRGGBB

◆ fill() [1/2]

void Canvas::fill ( Stencil  stencil)

fills the path with the given solid brush or gradient stencil - see gf_evg_surface_fill

Parameters
stencilthe stencil to use

◆ fill() [2/2]

void Canvas::fill ( Texture  texture)

fills the path with the given texture - see gf_evg_surface_fill

Parameters
texturethe texture to use

◆ reassign()

void Canvas::reassign ( ArrayBuffer  data)

reassign internal data (typically at each new packet)

Warning
This assumes the data layout has not changed (width, height, pixel format, strides). If these are modified, create a new canvas.
Parameters
datathe buffer to use

◆ toRGB() [1/2]

Object Canvas::toRGB ( optional bool  as_array = false,
Float  y,
Float  u,
Float  v,
optional Float  a = 1.0 
)

converts YUV color to RGB

Parameters
as_arrayif true, the return object is an array of 4 components, otherwise it is a Vec4f object
yY component value
uCb/U component value
vCr/V component value
aalpha value, not modified
Returns
the converted value

◆ toRGB() [2/2]

Object Canvas::toRGB ( optional bool  as_array = false,
Vec4f  color 
)

converts YUV color to RGB

Parameters
as_arrayif true, the return object is an array of 4 components, otherwise it is a Vec4f object
colorthe YUV value to convert
Returns
the converted value

◆ toYUV() [1/2]

Object Canvas::toYUV ( optional bool  as_array = false,
Float  r,
Float  g,
Float  b,
optional Float  a = 1.0 
)

converts RGB color to YUV

Parameters
as_arrayif true, the return object is an array of 4 components, otherwise it is Vec4f object
rred component value
ggreen component value
bblue component value
aalpha value, not modified
Returns
the converted value

◆ toYUV() [2/2]

Object Canvas::toYUV ( optional bool  as_array = false,
Vec4f  color 
)

converts RGB color to YUV

Parameters
as_arrayif true, the return object is an array of 4 components, otherwise it is a Vec4f object
colorthe RGB value to convert
Returns
the converted value

Field Documentation

◆ centered

attribute boolean Canvas::centered

indicates if surface coordinates are centered or not - see gf_evg_surface_set_center_coords

◆ path

writeonly Path Canvas::path

path to draw - see gf_evg_surface_set_path. The path object is either a Path or a Text

◆ matrix

writeonly Matrix2D Canvas::matrix

matrix to apply to path - see gf_evg_surface_set_matrix.

Note
A same path can be drawn several times with different matrices, null means no matrix.

◆ clipper

writeonly IRect Canvas::clipper

clipper in pixel coordinates - see gf_evg_surface_set_clipper

Note
A same path can be drawn several times with different clipper, null means no clipper. Clipper applies to both fill and clear functions

◆ compositeOperation

attribute unsigned long Canvas::compositeOperation

composite operation for alpha surfaces - see gf_evg_surface_set_composite_mode

◆ on_alpha

attribute AlphaCallback Canvas::on_alpha

alpha custom callback composite operation for alpha surfaces - see gf_evg_surface_set_alpha_callback Default is undefined at creation time