Class Fz2D.CanvasWebGL
| Defined in: | src/renderer/canvas_webgl.coffee |
| Inherits: | Fz2D.Canvas |
Overview
Constant Summary
-
VERTEX_SHADER
=
Private: Vertex Shader.
-
"precision mediump float;\n\nuniform vec2 screen;\nuniform vec2 texture;\n\nattribute vec4 pos;\nattribute vec4 uv;\n\nvarying vec2 texture_coord;\nvarying float alpha;\n\nvoid main(void)\n{ \n texture_coord = uv.st * texture;\n alpha = uv.w;\n \n float r = radians(uv.z);\n float cosr = cos(r);\n float sinr = sin(r);\n\n vec2 pp = pos.xy - pos.zw;\n vec2 p = vec2(pp.x * cosr - pp.y * sinr, pp.x * sinr + pp.y * cosr);\n\n p += pos.zw;\n p *= screen;\n\n ###~Private~###\n gl_Position = vec4(p.x - 1.0, 1.0 - p.y, 0.0, 1.0);\n}" -
FRAGMENT_SHADER
=
Private: Fragment Shader.
-
"precision mediump float;\n\nuniform sampler2D texture_id;\nvarying vec2 texture_coord;\nvarying float alpha;\n \nvoid main(void)\n{\n vec4 color = texture2D(texture_id, texture_coord);\n color.a *= alpha;\n\n ###~Private~###\n gl_FragColor = color;\n}"
Instance Method Summary
- ::clear() Clears the canvas.
- ::constructor() Constructor.
- ::draw(texture, sx, sy, sw, sh, x, y, w, h, hw, hh, angle, alpha) Draws a Fz2D.Texture.
- ::fill(color) Fills the canvas with a solid color.
- ::flush() Flushes the canvas.
Inherited Method Summary
Methods inherited from Fz2D.Canvas
@getContext, .constructor, .fill, .clear, .flush, .draw, .toImage, .toElement
Constructor Details
::constructor() Source
Instance Method Details
::clear() Source
::draw(texture, sx, sy, sw, sh, x, y, w, h, hw, hh, angle, alpha) Source
::fill(color) Source
::flush() Source