libgpac
Documentation of the core library of GPAC
EVG JS API

Embedded Vector Graphics JavaScript API. More...

+ Collaboration diagram for EVG JS API:

Data Structures

interface  Canvas
 
interface  IRect
 
interface  Rect
 
interface  Point2D
 
interface  AlphaCallback
 
interface  Path
 
interface  PenSettings
 
interface  Matrix2D
 
interface  ColorMatrix
 
interface  Color
 
interface  Colorf
 
interface  Stencil
 
interface  Texture
 
interface  ConvolutionKernel
 
interface  Text
 
interface  TextMeasure
 
interface  Matrix
 
interface  Vec3f
 
interface  Rectf
 
interface  Vec4f
 
interface  Canvas3D
 
interface  VertexAttribInterpolator
 
interface  VertexAttrib
 
interface  Shader
 

Enumerations

enum  ShaderType { GF_EVG_SHADER_FRAGMENT =1, GF_EVG_SHADER_VERTEX }
 
enum  AttributeMapType { GF_EVG_VAI_VERTEX_INDEX =0, GF_EVG_VAI_VERTEX, GF_EVG_VAI_PRIMITIVE }
 

Functions

long PixelSize (DOMString pixel_format)
 

Detailed Description

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:

Whenever pixel coordinates are indicated, 0,0 indicates:

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.

Data Structure Documentation

◆ IRect

interface 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

interface Rect

rectangle object

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

interface Point2D

point object

Data Fields
unsigned long x

x coordinate of point

y coordinate of point

◆ PenSettings

interface 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

interface Color

color object

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

interface Colorf

color object

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 intergers, and there shall be at least w * h coefficients

◆ TextMeasure

interface 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

◆ Vec3f

interface Vec3f

3D vector object

Data Fields
attribute float x

X coordinate

attribute float y

Y coordinate

attribute float z

Z coordinate

◆ Rectf

interface Rectf

rectangle object

Data Fields
attribute float x

X coordinate

attribute float y

Y coordinate

attribute float width

width

attribute float height

height

◆ Vec4f

interface Vec4f

4D vector object

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'

Enumeration Type Documentation

◆ ShaderType

enum 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

Function Documentation

◆ PixelSize()

long PixelSize ( DOMString  pixel_format)

queries size in bytes of a pixel for a given pixel format

Parameters
pixel_formatthe desired pixel format
Returns
the size in bytes