Embedded Vector Graphics JavaScript API.
More...
This module provides bindings for GPAC Vector Graphics Rendering engine called EVG (for Embedded Vector Graphics).
The API is loaded as a JS module with the name "evg":
import * as evg from 'evg'
...
The API supports all Vector Graphics from Vector Graphics Rendering, 2D Vector Path, bindings for 2D and 3D matrices and text rendering as used by the Compositor.
The API is a low level access to the software rasterizer and does not follow the Canvas2D API (https://www.w3.org/TR/2dcontext/) but most of the tools required to implement Canvas2D are present in the evg API.
It allows a filter to:
- generate new video frames from scratch
- use input video frames to generate new frames
- generate vector graphics and text directly on input video frames
Whenever pixel coordinates are indicated, 0,0 indicates:
- the center of the surface if the surface uses centered coordinates
- the top-left of the surface if the surface does not use centered coordinates
Whenever using an object as a parameter to a function, only the parameter names as listed in the corresponding interface object are checked. The name of the interface is not, and it usually does not define any constructor.
- Note
- Although 10-bit raster is supported for YUV formats (framebuffer and textures), colors are internally handled as 8-bits for solid brush and gradients. This will be updated in the near future.
The 3D extension of Canvas object can be used to draw vectorial 3D meshes and 2D paths.
- Warning
- The 3D rasterizer is much much slower than WebGL as it is only software and not realy optimized, do not use it for complex 3D scenes.
-
The 3D rasterizer is still an experimental project: it might not be completely stable and its API may change a lot in the near future.
The 3D rasterizer can however be useful when drawing simple 3D objects over an existing video, as it avoids GPU transfers of the frame data.
The rasterizer supports:
- points, lines, triangles, quads, strips and fans
- 2D texturing using RGBA or YUVA colorspace
- perspective correct interpolation
- simple antialiasing
- depth buffer (float only)
- rasterizing in YUVA or RGBA space
- a simple shading language for both vertex and fragment processing
The rasterizer does not claim compliancy to any GPU specification, and will likely produce different results than WebGL.
◆ IRect
rectangle object, pixel coordinate
Data Fields |
unsigned long |
x |
x coordinate in pixels of top-left corner
y coordinate in pixels of top-left corner
|
unsigned long |
w |
width of rectangle in pixels
|
unsigned long |
h |
height of rectangle in pixels
|
◆ Rect
Data Fields |
unsigned long |
x |
x coordinate of top-left corner
y coordinate of top-left corner
|
unsigned long |
w |
width of rectangle
|
unsigned long |
h |
height of rectangle
|
◆ Point2D
Data Fields |
unsigned long |
x |
x coordinate of point
y coordinate of point
|
◆ PenSettings
Pen settings, see GF_PenSettings
Data Fields |
attribute double |
width |
pen line width
|
attribute double |
miter |
The miter limit of the line joins
|
attribute double |
offset |
The initial dash offset in the outline. All points before this offset will be ignored when building the outline
|
attribute double |
length |
The author-specified path length. Ignored if <= 0
|
attribute unsigned long |
cap |
The style of the lines ends
|
attribute unsigned long |
join |
The style of the lines joins
|
attribute unsigned long |
align |
The alignment of the outline with regard to the path
|
attribute unsigned long |
dash |
The dash style of the line
|
attribute Array |
dashes |
The dash pattern used for custom dashing
|
◆ Color
Data Fields |
unsigned long |
r |
red component - if absent, default to 0
|
unsigned long |
g |
green component - if absent, default to 0
|
unsigned long |
b |
blue component - if absent, default to 0
|
unsigned long |
a |
alpha component - if absent, default to 255
|
◆ Colorf
Data Fields |
double |
r |
red component - if absent, default to 0
|
double |
g |
green component - if absent, default to 0
|
double |
b |
blue component - if absent, default to 0
|
double |
a |
alpha component - if absent, default to 1.0
|
◆ ConvolutionKernel
interface ConvolutionKernel |
convolution kernel interface
Data Fields |
attribute unsigned long |
w |
kernel width - shall be an odd number
|
attribute unsigned long |
h |
kernel height - shall be an odd number
|
attribute unsigned long |
norm |
kernel normalization. If 0 or undefined, no normalization is applied
|
attribute Array |
k |
kernel coeficients. The coeficients are unsigned integers, and there shall be at least w * h coefficients
|
◆ TextMeasure
text measurement interface
Data Fields |
double |
width |
measured width of text
|
double |
height |
measured height of text
|
unsigned long |
em_size |
size of EM box of font
|
unsigned long |
ascent |
ascent of font
|
unsigned long |
descent |
descent of font
|
unsigned long |
line_spacing |
line spacing of font
|
unsigned long |
underlined |
underline position in EM box
|
unsigned long |
baseline |
baseline position in EM box
|
unsigned long |
max_advance_h |
max horizontal advance of any glyphs in font
|
unsigned long |
max_advance_v |
max vertical advance of any glyphs in font
|
boolean |
right_to_left |
set to true if text is right to left, false otherwise
|
◆ Vec3f
Data Fields |
attribute float |
x |
X coordinate
|
attribute float |
y |
Y coordinate
|
attribute float |
z |
Z coordinate
|
◆ Rectf
Data Fields |
attribute float |
x |
X coordinate
|
attribute float |
y |
Y coordinate
|
attribute float |
width |
width
|
attribute float |
height |
height
|
◆ Vec4f
Data Fields |
attribute float |
x |
X coordinate
|
attribute float |
y |
Y coordinate
|
attribute float |
z |
Z coordinate
|
attribute float |
w |
4th dimension same as 'q' or 'alpha'
|
attribute float |
q |
4th dimension same as 'w' or 'alpha'
|
attribute float |
alpha |
4th dimension same as 'q' or 'w'
|
◆ BlitParameters
Parameter object for canvas texture blit
Data Fields |
DOMString |
mode |
name of the scale mode - see gpac -hx ffsws . If undefined, let FFMPEG decide
|
double |
p1 |
first parameter of scale mode, if any
|
double |
p2 |
second parameter of scale mode, if any
|
◆ ShaderType
defined shader types
Enumerator |
---|
GF_EVG_SHADER_FRAGMENT | shader is a fragment shader
|
GF_EVG_SHADER_VERTEX | shader is a vertex
|
◆ AttributeMapType
Map type for vertex attributes and vertex attribute interpolators
Enumerator |
---|
GF_EVG_VAI_VERTEX_INDEX | one vertex attribute is given for each vertex index
|
GF_EVG_VAI_VERTEX | one vertex attribute is given for each vertex
|
GF_EVG_VAI_PRIMITIVE | one vertex attribute is given for each primitive
|
◆ PixelSize()
queries size in bytes of a pixel for a given pixel format
- Parameters
-
pixel_format | the desired pixel format |
- Returns
- the size in bytes