new AVPlayer(NSOpenGLContext? gl)
Create a new instance of an AVPlayer. For video playback a gl
context
must be specified for the creation of textures. For audio only playback
the context argument can be omitted.
void appendFile(string path)
Add a file to the playlist.
void appendURL(string url)
Add a URL to the playlist.
float currentDuration()
object currentFrameTexture()
float[ ] currentLoadedTimeRanges()
float currentTime()
int error()
void play()
void playNext()
Play the next entry in the playlist.
bool prerollAtRate(float rate)
float rate()
Return the current playback rate.
void removeAll()
Remove all entries from the playlist.
void seekToTime(float secs)
void setLoops(bool loops)
Set whether or not the playlist loops.
void setRate(float rate)
Set the current playback rate.
void setVolume(float vol)
Set the audio volume.
string status()
float volume()
Return the current audio volume setting.
static string getString()
Returns the string value from the current general clipboard.
static bool setData(ArrayBuffer data, string datatype)
Sets the data value for datatype
in the current general clipboard.
Returns true on success.
static bool setString(string str)
Sets the string value for the current general clipboard. Returns true on success.
new MagicProgram(gl, program)
Create a MagicProgram object, which is a wrapper around a GLSL program to make it easier to access uniforms and attribs.
static MagicProgram createFromBasename(gl, directory, base, opts)
Create a new MagicProgram from the vertex shader source in file
base
.vshader and the fragment shader source in file base
.fshader in the
directory directory
.
// Creates a magic program from myshader.vshader and myshader.fshader in
// the same directory as the running source JavaScript file.
var mp = MagicProgram.createFromBasename(gl, __dirname, 'myshader');
static MagicProgram createFromFiles(gl, vfilename, ffilename, opts)
Create a new MagicProgram from the vertex shader source in file vfilename
and the fragment shader source in file ffilename
.
If opts
is supplied and opts.watch
is true, the files will be watched
for changes and automatically reloaded with a success or failure message
printed to the console.
static MagicProgram createFromStrings(gl, string vstr, string fstr)
Create a new MagicProgram from the vertex shader source string vstr
and
the fragment shader source string fstr
.
new Mat3()
Constructs an identity matrix.
Mat3 represents an 3x3 matrix. The elements are, using mathematical notation numbered starting from 1 as aij, where i is the row and j is the column:
a11 a12 a13
a21 a22 a23
a31 a32 a33
Almost all operations are multiplies to the current matrix, and happen in
place. You can use dup
to return a copy. Most operations return this to
support chaining.
It is common to use toFloat32Array
to get a Float32Array in OpenGL (column
major) memory ordering. NOTE: The code tries to be explicit about whether
things are row major or column major, but remember that GLSL works in
column major ordering, and this code generally uses row major ordering.
this adjoint()
Reference: http://en.wikipedia.org/wiki/Adjugate_matrix
float determinant()
Mat3 dup()
Return a new copy of the matrix.
this invert()
Invert the matrix. The matrix must be invertible.
Mat3 inverted()
Return an inverted matrix. The matrix must be invertible.
this mul(Mat3 b)
Matrix multiply this = this * b
this mul2(Mat3 a, Mat3 b)
Matrix multiply this = a * b
Vec2 mulVec2(Vec2 v)
Multiply Vec2 v
by the current matrix, returning a Vec2 of this * v
.
Ignores perspective (only applies scale and translation).
Vec2 mulVec2p(Vec2 v)
Multiply Vec2 v
by the current matrix and perform a perspective divide.
Implies that the missing z component of v
would be 1.
Vec3 mulVec3(Vec3 v)
Multiply Vec3 v
by the current matrix, returning a Vec3 of this * v
.
this negate()
this pmapQuadQuad(x0, y0, x1, y1, x2, y2, x3, y3,
u0, v0, u1, v1, u2, v2, u3, v3)
Overwrite this
with a matrix that maps from (x0,y0) .. (x3,y3) to
(u0,v0) .. (u3,v3). NOTE: This is sensitive to the coordinate ordering,
they should follow the pattern as pmapSquareQuad
.
Reference: Paul Heckbert "Fundamentals of Texture Mapping and Image Warping"
this pmapSquareQuad(x0, y0, x1, y1, x2, y2, x3, y3)
Find mapping between (0, 0), (1, 0), (1, 1), (0, 1) to (x0,y0) .. (x3, y3).
this reset()
Reset to the identity matrix.
this set3x3r(a11, a12, a13, a21, a22, a23, a31, a32, a33)
Set the full 9 elements of the 3x3 matrix, arguments in row major order. The elements are specified in row major order.
Float32Array toFloat32Array()
Return a Float32Array in suitable column major order for WebGL.
this transpose()
Transpose the matrix, rows become columns and columns become rows.
new Mat4()
Constructs an identity matrix.
Mat4 represents an 4x4 matrix. The elements are, using mathematical notation numbered starting from 1 as aij, where i is the row and j is the column:
a11 a12 a13 a14
a21 a22 a23 a24
a31 a32 a33 a34
a41 a42 a43 a44
Almost all operations are multiplies to the current matrix, and happen in
place. You can use dup
to return a copy. Most operations return this to
support chaining.
It is common to use toFloat32Array
to get a Float32Array in OpenGL (column
major) memory ordering. NOTE: The code tries to be explicit about whether
things are row major or column major, but remember that GLSL works in
column major ordering, and this code generally uses row major ordering.
Mat4 dup()
Return a new copy of the matrix.
this frustum(l, r, b, t, n, f)
Multiply by a frustum matrix computed from left, right, bottom, top, near, and far.
this invert()
Invert the matrix. The matrix must be invertible.
Mat4 inverted()
Return an inverted matrix. The matrix must be invertible.
this lookAt(ex, ey, ez, cx, cy, cz, ux, uy, uz)
Multiply by a look at matrix, computed from the eye, center, and up points.
this mul(b)
Matrix multiply this = this * b
this mul2(a, b)
Matrix multiply this = a * b
this mul4x4r(b11, b12, b13, b14, b21, b22, b23, b24,
b31, b32, b33, b34, b41, b42, b43, b44)
Multiply the current matrix by 16 elements that would compose a Mat4 object, but saving on creating the object. this = this * b. The elements are specified in row major order.
Vec3 mulVec3(Vec3 v)
Multiply Vec3 v
by the current matrix, returning a Vec3 of this * v.
Vec3 mulVec3p(Vec3 v)
Multiply Vec3 v
by the current matrix, returning a Vec3 of this * v.
Performs the perspective divide by w
.
Vec4 mulVec4(Vec4 v)
Multiply Vec4 v
by the current matrix, returning a Vec4 of this * v.
this ortho(l, r, b, t, n, f)
Multiply by a orthographic matrix, computed from the clipping planes.
this perspective(fovy, aspect, znear, zfar)
Multiply by a perspective matrix, computed from the field of view, aspect ratio, and the z near and far planes.
this reset()
Reset to the identity matrix.
this rotate(theta, x, y, z)
IN RADIANS, not in degrees like OpenGL. Rotate about x, y, z. The caller must supply x, y, z as a unit vector.
this scale(x, y, z)
Multiply by a scale of x, y, and z.
this set4x4c(a11, a21, a31, a41, a12, a22, a32, a42,
a13, a23, a33, a43, a14, a24, a34, a44)
Set the full 16 elements of the 4x4 matrix, arguments in column major order.
this set4x4r(a11, a12, a13, a14, a21, a22, a23, a24,
a31, a32, a33, a34, a41, a42, a43, a44)
Set the full 16 elements of the 4x4 matrix, arguments in row major order.
Float32Array toFloat32Array()
Return a Float32Array in suitable column major order for WebGL.
this translate(x, y, z)
Multiply by a translation of x, y, and z.
this transpose()
Transpose the matrix, rows become columns and columns become rows.
void activeTexture(GLenum texture)
void attachShader(WebGLProgram program, WebGLShader shader)
void beginTransformFeedback(GLenum primitiveMode)
void bindAttribLocation(WebGLProgram program, GLuint index, DOMString name)
void bindBuffer(GLenum target, WebGLBuffer buffer)
void bindBufferBase(GLenum target, GLuint index, WebGLBuffer? buffer)
void bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer,
GLintptr offset, GLsizeiptr size)
void bindFramebuffer(GLenum target, WebGLFramebuffer framebuffer)
void bindRenderbuffer(GLenum target, WebGLRenderbuffer renderbuffer)
void bindTexture(GLenum target, WebGLTexture texture)
void bindTransformFeedback (GLenum target, WebGLTransformFeedback? transformFeedback)
void bindVertexArray(WebGLVertexArrayObject? vertexArray)
void blendColor(GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha)
void blendEquation(GLenum mode)
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
void blendFunc(GLenum sfactor, GLenum dfactor)
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha)
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
void bufferData(GLenum target, GLsizei size, GLenum usage)
void bufferData(GLenum target, ArrayBufferView data, GLenum usage)
void bufferData(GLenum target, ArrayBuffer data, GLenum usage)
void bufferSubData(GLenum target, GLsizeiptr offset, ArrayBufferView data)
void bufferSubData(GLenum target, GLsizeiptr offset, ArrayBuffer data)
GLenum checkFramebufferStatus(GLenum target)
void clear(GLbitfield mask)
void clearColor(GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha)
void clearDepth(GLclampf depth)
void clearStencil(GLint s)
void colorMask(GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha)
void compileShader(WebGLShader shader)
void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border,
ArrayBufferView data)
WebGLBuffer createBuffer()
WebGLFramebuffer createFramebuffer()
WebGLProgram createProgram()
WebGLRenderbuffer createRenderbuffer()
WebGLShader createShader(GLenum type)
WebGLTexture createTexture()
WebGLTransformFeedback? createTransformFeedback()
WebGLVertexArrayObject? createVertexArray()
void cullFace(GLenum mode)
void deleteBuffer(WebGLBuffer buffer)
void deleteFramebuffer(WebGLFramebuffer framebuffer)
void deleteProgram(WebGLProgram program)
void deleteRenderbuffer(WebGLRenderbuffer renderbuffer)
void deleteShader(WebGLShader shader)
void deleteTexture(WebGLTexture texture)
void deleteTransformFeedback(WebGLTransformFeedback? vertexArray)
void deleteVertexArray(WebGLVertexArrayObject? vertexArray)
void depthFunc(GLenum func)
void depthMask(GLboolean flag)
void depthRange(GLclampf zNear, GLclampf zFar)
void detachShader(WebGLProgram program, WebGLShader shader)
void disable(GLenum cap)
void disableVertexAttribArray(GLuint index)
void drawArrays(GLenum mode, GLint first, GLsizei count)
void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
void DrawBuffersARB(sizei n, const enum *bufs);
void drawElements(GLenum mode, GLsizei count,
GLenum type, GLsizeiptr offset)
void drawElementsInstanced(GLenum mode, GLsizei count,
GLenum type, GLintptr offset,
GLsizei instanceCount)
void drawRangeElements(GLenum mode,
GLuint start, GLuint end,
GLsizei count, GLenum type, GLintptr offset)
void enable(GLenum cap)
void enableVertexAttribArray(GLuint index)
void endTransformFeedback()
void finish()
void flush()
void framebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
WebGLRenderbuffer renderbuffer)
void framebufferTexture2D(GLenum target, GLenum attachment,
GLenum textarget, WebGLTexture texture,
GLint level)
void frontFace(GLenum mode)
void generateMipmap(GLenum target)
WebGLActiveInfo getActiveAttrib(WebGLProgram program, GLuint index)
WebGLActiveInfo getActiveUniform(WebGLProgram program, GLuint index)
WebGLShader[ ] getAttachedShaders(WebGLProgram program)
GLint getAttribLocation(WebGLProgram program, DOMString name)
any getBufferParameter(GLenum target, GLenum pname)
void getBufferSubData(GLenum target, GLintptr offset, ArrayBuffer? returnedData)
GLenum getError()
object? getExtension(DOMString name)
any getFramebufferAttachmentParameter(GLenum target, GLenum attachment,
GLenum pname)
any getParameter(GLenum pname)
DOMString getProgramInfoLog(WebGLProgram program)
any getProgramParameter(WebGLProgram program, GLenum pname)
DOMString getShaderInfoLog(WebGLShader shader)
any getShaderParameter(WebGLShader shader, GLenum pname)
DOMString getShaderSource(WebGLShader shader)
sequence<DOMString>? getSupportedExtensions()
any getTexParameter(GLenum target, GLenum pname)
WebGLActiveInfo? getTransformFeedbackVarying(WebGLProgram? program, GLuint index)
any getUniform(WebGLProgram program, WebGLUniformLocation location)
WebGLUniformLocation getUniformLocation(WebGLProgram program,
DOMString name)
void hint(GLenum target, GLenum mode)
GLboolean isBuffer(WebGLBuffer buffer)
GLboolean isEnabled(GLenum cap)
GLboolean isFramebuffer(WebGLFramebuffer framebuffer)
GLboolean isProgram(WebGLProgram program)
GLboolean isRenderbuffer(WebGLRenderbuffer renderbuffer)
GLboolean isShader(WebGLShader shader)
GLboolean isTexture(WebGLTexture texture)
GLboolean isTransformFeedback(WebGLTransformFeedback? vertexArray)
GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray)
void lineWidth(GLfloat width)
void linkProgram(WebGLProgram program)
void pauseTransformFeedback()
void pixelStorei(GLenum pname, GLint param)
void polygonOffset(GLfloat factor, GLfloat units)
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, ArrayBufferView pixels)
void renderbufferStorage(GLenum target, GLenum internalformat,
GLsizei width, GLsizei height)
void renderbufferStorageMultisample(GLenum target, GLsizei samples,
GLenum internalformat,
GLsizei width, GLsizei height)
void resumeTransformFeedback()
void sampleCoverage(GLclampf value, GLboolean invert)
void scissor(GLint x, GLint y, GLsizei width, GLsizei height)
void setSwapInterval(int interval)
Sets the swap interval, aka vsync. Ex: 1
for vsync and 0
for no sync.
This will normally be handled for you by the simpleWindow vsync
setting.
void shaderSource(WebGLShader shader, DOMString source)
void shaderSourceRaw(WebGLShader shader, DOMString source)
void stencilFunc(GLenum func, GLint ref, GLuint mask)
void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
void stencilMask(GLuint mask)
void stencilMaskSeparate(GLenum face, GLuint mask)
void stencilOp(GLenum fail, GLenum zfail, GLenum zpass)
void stencilOpSeparate(GLenum face, GLenum fail,
GLenum zfail, GLenum zpass)
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type, ArrayBufferView pixels)
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, ImageData pixels)
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, HTMLImageElement image)
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, HTMLCanvasElement canvas)
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, HTMLVideoElement video)
void texParameterf(GLenum target, GLenum pname, GLfloat param)
void texParameteri(GLenum target, GLenum pname, GLint param)
void transformFeedbackVaryings(WebGLProgram? program,
sequence<DOMString> varyings,
GLenum bufferMode)
void uniform1f(WebGLUniformLocation location, GLfloat x)
void uniform1fv(WebGLUniformLocation location, Float32Array v)
void uniform1fv(WebGLUniformLocation location, sequence v)
void uniform1i(WebGLUniformLocation location, GLint x)
void uniform1iv(WebGLUniformLocation location, Int32Array v)
void uniform1iv(WebGLUniformLocation location, sequence v)
void uniform2f(WebGLUniformLocation location, GLfloat x, GLfloat y)
void uniform2fv(WebGLUniformLocation location, Float32Array v)
void uniform2fv(WebGLUniformLocation location, sequence v)
void uniform2i(WebGLUniformLocation location, GLint x, GLint y)
void uniform2iv(WebGLUniformLocation location, Int32Array v)
void uniform2iv(WebGLUniformLocation location, sequence v)
void uniform3f(WebGLUniformLocation location, GLfloat x, GLfloat y,
GLfloat z)
void uniform3fv(WebGLUniformLocation location, Float32Array v)
void uniform3fv(WebGLUniformLocation location, sequence v)
void uniform3i(WebGLUniformLocation location, GLint x, GLint y, GLint z)
void uniform3iv(WebGLUniformLocation location, Int32Array v)
void uniform3iv(WebGLUniformLocation location, sequence v)
void uniform4f(WebGLUniformLocation location, GLfloat x, GLfloat y,
GLfloat z, GLfloat w)
void uniform4fv(WebGLUniformLocation location, Float32Array v)
void uniform4fv(WebGLUniformLocation location, sequence v)
void uniform4i(WebGLUniformLocation location, GLint x, GLint y,
GLint z, GLint w)
void uniform4iv(WebGLUniformLocation location, Int32Array v)
void uniform4iv(WebGLUniformLocation location, sequence v)
void uniformMatrix2fv(WebGLUniformLocation location, GLboolean transpose,
Float32Array value)
void uniformMatrix2fv(WebGLUniformLocation location, GLboolean transpose,
sequence value)
void uniformMatrix3fv(WebGLUniformLocation location, GLboolean transpose,
Float32Array value)
void uniformMatrix3fv(WebGLUniformLocation location, GLboolean transpose,
sequence value)
void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose,
Float32Array value)
void uniformMatrix4fv(WebGLUniformLocation location, GLboolean transpose,
sequence value)
void useProgram(WebGLProgram program)
void validateProgram(WebGLProgram program)
void vertexAttrib1f(GLuint indx, GLfloat x)
void vertexAttrib1fv(GLuint indx, Float32Array values)
void vertexAttrib1fv(GLuint indx, sequence values)
void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
void vertexAttrib2fv(GLuint indx, Float32Array values)
void vertexAttrib2fv(GLuint indx, sequence values)
void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
void vertexAttrib3fv(GLuint indx, Float32Array values)
void vertexAttrib3fv(GLuint indx, sequence values)
void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y,
GLfloat z, GLfloat w)
void vertexAttrib4fv(GLuint indx, Float32Array values)
void vertexAttrib4fv(GLuint indx, sequence values)
void vertexAttribDivisor(GLuint index, GLuint divisor)
void vertexAttribPointer(GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride,
GLsizeiptr offset)
void viewport(GLint x, GLint y, GLsizei width, GLsizei height)
void writeImage(filetype, filename, opts)
void associateMouse(bool connted)
Sets whether the mouse and the mouse cursor are connected (whether moving the mouse moves the cursor).
void center()
Position the window in the center of the screen.
static string getClipboardString()
Returns the string value from the current general clipboard.
void hide()
Hide the window.
void hideCursor()
Hide the cursor.
void popCursor(string name)
Pop the cursor from the top of the cursor stack.
void pushCursor(string name)
Sets the cursor to name
using the cursor stack.
object screenSize()
Returns an object {width: float, height: float} of the screen size of the main screen the window is currently on.
object[ ] screensInfo()
Returns an array of objects representing info about each screen. The objects have {id: int, width: float, height: float, highdpi: float}.
static bool setClipboardData(TypedArray data, string datatype)
Sets the data value for datatype in the current general clipboard. Returns true on success.
static bool setClipboardString(str)
Sets the string value for the current general clipboard. Returns true on success.
void setCursor(string name)
Sets the cursor to name
.
void setCursorPosition(float x, float y)
Set the cursor position (within the main display).
You should only really call this once, it's a pretty raw function.
void setFullscreen(bool fullscreen)
Switches the window in and out of "fullscreen". Fullscreen means that the window is borderless and on a higher window level.
void setTitle(string title)
Sets the title shown in the frame at the top of the window.
void show()
Un-hide the window.
void unhideCursor()
Un-hide the cursor.
void warpCursorPosition(float x, float y)
Set the cursor position (in global display coordinate space), without generating any events.
static SkCanvas create(width, height)
Create a bitmap SkCanvas with the specified size.
static SkCanvas createForPDF(filename, page_width, page_height, content_width, content_height)
Create a new vector-mode SkCanvas that can be written to a PDF with writePDF
.
static SkCanvas createFromImage(filename)
Create a bitmap SkCanvas with the size/pixels from an image filename
.
static SkCanvas createFromImageData(data)
Create a bitmap SkCanvas with the size/pixels from an image data
.
void clear(r, g, b, a)
Sets the entire canvas to a uniform color.
void clipPath(path)
Set the clipping path to the SkPath object path
. Setting the clipping path
will prevent any pixels to be drawn outside of this path.
The save() and restore() functions are the best way to manage or reset the clipping path.
void clipRect(left, top, right, bottom)
Set the clipping path to the rectangle of the upper-left and bottom-right corners specified. Setting the clipping path will prevent any pixels to be drawn outside of this path.
The save() and restore() functions are the best way to manage or reset the clipping path.
void concatMatrix(a, b, c, d, e, f, g, h, i)
Preconcat the current matrix with the specified matrix.
void drawCanvas(paint, source, dst_left, dst_top, dst_right, dst_bottom, src_left, src_top, src_right, src_bottom)
Draw one canvas on to another canvas. The paint
object controls settings
involved in the drawing, such as anti-aliasing. The source
parameter is the
source canvas to be drawn from. The first four parameters define the rectangle
within the destination canvas that the image will be drawn. The last four
parameters specify the rectangle within the source image. This allows for
drawing portions of the source image, scaling, etc.
The last four parameters are optional, and will default to the entire source image (0, 0, source.width, source.height).
var img = plask.SkCanvas.createFromImage('tex.png'); // Size 100x150.
// Draw the texture image scaled 2x larger.
canvas.drawCanvas(paint, img,
0, 0, 200, 300, // Draw at (0, 0) size 200x300.
0, 0, 100, 150) // Draw the entire source image.
void drawCircle(paint, x, y, radius)
Draw a circle centered at (x
, y
) of radius radius
.
void drawColor(r, g, b, a, blendmode)
Fill the entire canvas with a solid color. If blendmode
is not specified,
it defaults to SrcOver, which will blend with anything already on the canvas.
Use eraseColor() when you do not need any alpha blending.
void drawLine(paint, x0, y0, x1, y1)
Draw a line between (x0
, y0
) and (x1
, y1
).
void drawPaint(paint)
Fill the entire canvas with a solid color, specified by the paint's color and blending mode.
void drawPath(paint, path)
Draw an SkPath. The path will be stroked or filled depending on the paint's style (see SkPaint#setStyle).
void drawPoints(paint, mode, points)
An optimized drawing path for many points, lines, or polygons with many points.
The mode
parameter is one of kPointsPointMode, kLinesPointMode, or
kPolygonPointMode. The points
parameter is an array of points, in the form
of [x0, y0, x1, y1, ...].
void drawRect(paint, left, top, right, bottom)
Draw a rectangle specified by the upper-left and bottom-right corners.
void drawRoundRect(paint, left, top, right, bottom, xradius, yradius)
Draw a rectangle with rounded corners of radius xradius
and yradius
.
void drawText(paint, str, x, y)
Draw the string str
with the bottom left corner starting at (x
, y
).
void drawTextOnPathHV(paint, path, str, hoffset, voffset)
Draw the string str
along the path path
, starting along the path at
hoffset
and above or below the path by voffset
.
void flush()
Flushes any pending operations to the underlying surface, for example when using a GPU backed canvas. Normally this will be called for you at the appropriate place before drawing, so it is unlikely to call it directly.
void resetMatrix()
Reset the transform matrix to the identity.
void restore()
Restore the transform matrix from the matrix stack.
void rotate(degrees)
Rotate the canvas by degrees
degrees (not radians).
void save()
Save the transform matrix to the matrix stack.
void scale(x, y)
Scale the canvas by x
and y
.
void setMatrix(a, b, c, d, e, f, g, h, i)
Sets the the 3x3 homogeneous transformation matrix:
|a b c|
|d e f|
|g h i|
void skew(x, y)
Skew the canvas by x
and y
.
void translate(x, y)
Translate the canvas by x
and y
.
void writeImage(typestr, filename)
Write the current contents of the canvas as an image named filename
. The
typestr
parameter selects the image format. Currently only 'png' is
supported.
void writePDF()
Write the contents of a vector-mode SkCanvas (created with createForPDF) to the filename supplied when created with createForPDF.
The canvas is no longer usable after a call to writePDF. A PDF can only be written once and no further calls can be made on the canvas.
void clearPathEffect()
Clear any path effect.
void clearShader()
int getFilterLevel()
Get the filtering level (quality vs performance) for scaled images.
void getFlags()
Return the paint flags.
int getStrokeCap()
Return the current stroke cap.
int getStrokeJoin()
Returns the current stroke join setting.
float getStrokeMiter()
Returns the current stroke miter setting.
void getStrokeWidth()
Return the current stroke width.
void getStyle()
Return the current style.
void getTextPath(text, x, y, path)
float measureText(string text)
Measure the x-advance for the string text
using the current
paint settings.
float[ ] measureTextBounds(string text)
Returns an array of the bounds [left, top, right, bottom] for text
.
void reset()
Reset the paint to the default settings.
void setAlpha(float a)
Set the alpha of the paint color, leaving rgb unchanged.
void setAntiAlias(bool aa)
void setAutohinted(bool autohint)
void setColor(r, g, b, a)
Set the paint color, values are integers in the range of 0 to 255.
void setColorHSV(h, s, v, a)
Set the paint color from HSV values, the HSV values are floating point, hue from 0 to 360, and saturation and value from 0 to 1. The alpha value is an integer in the range of 0 to 255.
void setDevKernText(bool devkern)
void setDither(bool dither)
void setFakeBoldText(bool fakebold)
void setFill()
Sets the current paint style to fill.
void setFillAndStroke()
Sets the current paint style to fill and stroke.
void setFilterLevel(int level)
Set the filtering level (quality vs performance) for scaled images.
// kNoneFilterLevel
// kLowFilterLevel
// kMediumFilterLevel
// kHighFilterLevel
void setFlags(flags)
Set the paint flags, such as whether to perform anti-aliasing.
// The follow flags are supported. They should be OR'd together to set
// multiple settings.
// kAntiAliasFlag
// kFilterBitmapFlag
// kDitherFlag
// kUnderlineTextFlag
// kStrikeThruTextFlag
// kFakeBoldTextFlag
// kLinearTextFlag
// kSubpixelTextFlag
// kDevKernTextFlag
paint.setFlags(paint.kAntiAliasFlag | paint.kFilterBitmapFlag);
void setFontFamily(family)
Set the text font family.
void setLCDRenderText(bool lcd)
void setLinearGradientShader(x0, y0, x1, y1, float[ ] colorpositions)
void setRadialGradientShader(x, y, radius, float[ ] colorpositions)
void setStrikeThruText(bool strike)
void setStroke()
Sets the current paint style to stroke.
void setStrokeCap(int cap)
Set the stroke cap.
// The follow caps are supported:
// kButtCap
// kRoundCap
// kSquareCap
// kDefaultCap
paint.setStrokeCape(paint.kRoundCap);
void setStrokeJoin(int join)
float setStrokeMiter(float miter)
void setStrokeWidth(width)
Set the current stroke width to the floating point value width
. A width of
0 causes Skia to draw in a special 'hairline' stroking mode.
void setStyle(style)
Set the paint style, for example whether to stroke, fill, or both.
// The follow styles are supported:
// kFillStyle
// kStrokeStyle
// kStrokeAndFillStyle
paint.setStyle(paint.kStrokeStyle);
void setSubpixelText(bool subpixel)
void setTextSize(size)
Set the text size.
void setUnderlineText(bool underline)
void setXfermodeMode(mode)
Set the alpha blending (porter duff transfer) mode.
// The following blending modes are supported:
// kClearMode
// kSrcMode
// kDstMode
// kSrcOverMode
// kDstOverMode
// kSrcInMode
// kDstInMode
// kSrcOutMode
// kDstOutMode
// kSrcATopMode
// kDstATopMode
// kXorMode
// kPlusMode
// kMultiplyMode
// kScreenMode
// kOverlayMode
// kDarkenMode
// kLightenMode
// kColorDodgeMode
// kColorBurnMode
// kHardLightMode
// kSoftLightMode
// kDifferenceMode
// kExclusionMode
paint.setXfermodeMode(paint.kPlusMode); // Additive blending.
void SkPath(SkPath? path_to_copy)
Construct a new path object, optionally based off of an existing path.
void arcTo(float x0, float y0, float x1, float y1,
float startAngle, float sweepAngle, float forceMoveto)
Create an arc inside the rectangle (x0, y0) (x1, y1), sweeping clockwise from startAngle by the amount sweepAngle (in degrees).
void arct(float x0, float y0, float x1, float y1, float radius);
Like HTML5
void close()
Close the path, connecting the path to the beginning.
bool contains(float x, float y)
Returns true of (x, y) is contained in the path, taking the winding on the path into account.
void cubicTo(c0x, c0y, c1x, c1y, ex, ey)
A cubic bezier curve with control points (c0x
, c0y
) and (c1x
, c1y
) and
endpoint (ex
, ey
).
bool fromSVGString(string svgpath)
Sets the path from an SVG path data representation. Returns true on success.
float[ ] getBounds()
Returns an array of [left, top, right, bottom], the bounding rectangle of the path.
int getFillType()
float[] getPoints()
float[] getVerbs()
void lineTo(x, y)
Line to (x
, y
).
void moveTo(x, y)
Move to (x
, y
).
void offset(x, y)
Offset the path by (x
, y
).
bool op(SkPath one, SkPath two, int pathop)
Sets the path to the result of the operation pathop
on one
and two
.
void quadTo(cx, cy, ex, ey)
A quadratic bezier curve with control point (cx
, cy
) and endpoint (ex
,
ey
).
void rLineTo(rx, ry)
Similar to lineTo(), except rx
and ry
are relative to the previous point.
void reset()
Reset the path to an empty path.
void rewind()
Reset the path to an empty path, but keeping the internal memory previously allocated for the point storage.
void setFillType(int)
bool simplify(SkPath one)
Sets the path to the result of simplifying one
.
string toSVGString()
Returns the path as a SVG path data representation.
void transform(a, b, c, d, e, f, g, h, i)
Transforms the path by the 3x3 homogeneous transformation matrix:
|a b c|
|d e f|
|g h i|
new Vec2(x, y)
Constructs a 2d vector (x, y).
this add(Vec2 b)
Add a Vec2, this = this + b.
this add2(Vec2 a, Vec2 b)
Add two Vec2s, this = a + b.
Vec2 added(Vec2 b)
Add a Vec2, returning the result as a new Vec2.
Vec2 det(Vec2 b)
Returns the scalar value of the determinant det(a, b)
.
This is often referred to as the 2D cross product, which is not defined for
2D, so this is an extension to 2D by taking the z component of the 3d cross
product:
.
This is also the "Perp Dot Product", equivalent to perped().dot(b)
float dist(Vec2 b)
Distance to Vec2 b
.
float distSquared(Vec2 b)
Squared Distance to Vec2 b
.
float dot(Vec2 b)
Returns the dot product, this . b.
Vec2 dup()
Return a new copy of the vector.
float length()
Magnitude (length).
float lengthSquared()
Magnitude squared.
this lerp(Vec2 b, float t)
Interpolate between this and another Vec2 b
, based on t
.
Vec2 lerped(Vec2 b, float t)
this mul(Vec2 b)
Multiply by another Vec2, this = this * b.
this mul2(Vec2 a, Vec2 b)
Multiply two Vec2s, this = a * b.
Vec2 mulled(Vec2 b)
this negate()
Vec2 negated()
this normalize()
Normalize, scaling so the magnitude is 1. Invalid for a zero vector.
Vec2 normalized()
this perp()
Make perpendicular (rotated 90 degrees ccw) in place: this = thisâź‚
Vec2 perped()
Return a new perpendicular vector (rotated 90 degrees ccw).
this reflect(Vec2 n)
Reflect a vector about the normal n
. The vectors should both be unit.
Vec2 reflected(Vec2 n)
this rotate(float theta)
Rotate around the origin by theta
radians (counter-clockwise).
Vec2 rotated(float theta)
this scale(float s)
Multiply by a scalar.
Vec2 scaled(float s)
this set(float x, float y)
this setVec2(Vec2 v)
this sub(Vec2 b)
Subtract another Vec2, this = this - b.
this sub2(Vec2 a, Vec2 b)
Subtract two Vec2s, this = a - b.
Vec2 subbed(Vec2 b)
new Vec3(x, y, z)
A class representing a 3 dimensional point and/or vector. There isn't a good reason to differentiate between the two, and you often want to change how you think about the same set of values. So there is only "vector".
The class is designed without accessors or individual mutators, you should access the x, y, and z values directly on the object.
Almost all of the core operations happen in place, writing to the current
object. If you want a copy, you can call dup
. For convenience, many
operations have a passed-tense version that returns a new object. Most
methods return this
to support chaining.
this add(Vec3 b)
Add a Vec3, this = this + b.
this add2(Vec3 a, Vec3 b)
Add two Vec3s, this = a + b.
Vec3 added(Vec3 b)
this cross(Vec3 b)
Cross product, this = this x b.
this cross2(Vec3 a, Vec3 b)
Cross product, this = a x b.
float dist(Vec3 b)
Distance to Vec3 b
.
float distSquared(Vec3 b)
Squared Distance to Vec3 b
.
float dot(Vec3 b)
Returns the dot product, this . b.
Vec3 dup()
Return a new copy of the vector.
float length()
Magnitude (length).
float lengthSquared()
Magnitude squared.
this lerp(Vec3 b, float t)
Interpolate between this and another Vec3 b
, based on t
.
Vec3 lerped(Vec3 b, float t)
this mul(Vec3 b)
Multiply by another Vec3, this = this * b.
this mul2(Vec3 a, Vec3 b)
Multiply two Vec3s, this = a * b.
Vec3 mulled(Vec3 b)
this normalize()
Normalize, scaling so the magnitude is 1. Invalid for a zero vector.
Vec3 normalized()
this scale(float s)
Multiply by a scalar.
Vec3 scaled(float s)
this set(x, y, z)
this setVec3(Vec3 v)
this sub(Vec3 b)
Subtract another Vec3, this = this - b.
this sub2(Vec3 a, Vec3 b)
Subtract two Vec3s, this = a - b.
Vec3 subbed(Vec3 b)
new Vec4(x, y, z, w)
Vec4 dup()
Return a new copy of the vector.
this scale(float s)
Multiply by a scalar.
Vec4 scaled(float s)
this set(x, y, z, w)
this setVec4(Vec4 v)
Vec3 toVec3()
Return a new vector of (x, y, z), dropping w.
float clamp(float v, float vmin, float vmax)
GLSL clamp. Keep the value v
in the range vmin
.. vmax
.
float clamp01(float v)
Convenient for clamp(v, 0, 1)
.
float clamp11(float v)
Convenient for clamp(v, -1, 1)
.
float fract(float x)
Like GLSL fract(), returns x - floor(x). NOTE, for negative numbers, this is a positive value, ex fract(-1.3) == 0.7.
float fract2(float x)
Returns the part of the number to the right of the radix point. For negative numbers, this is a positive value, ex fract(-1.25) == 0.25
float fract3(float x)
Returns the signed part of the number to the right of the radix point. For negative numbers, this is a negative value, ex fract(-1.25) == -0.25
float lerp(float a, float b, float t)
Linear interpolation on the line along points (0, a
) and (1, b
). The
position t
is the x coordinate, where 0 is a
and 1 is b
.
float max(float a, float b)
float min(float a, float b)
float smootherstep(edge0, edge1, x)
Ken Perlin's "smoother" step function, with zero 1st and 2nd derivatives at the endpoints (whereas smoothstep has a 2nd derivative of +/- 6). This is also for example used by Patel and Taylor in smooth simulation noise.
float smoothstep(edge0, edge1, x)
GLSL smoothstep. NOTE: Undefined if edge0 == edge1.