Graphics class Graphics
Provides the core 2D rendering capabilities for the Bullseye2D engine.
Most applications will interact with this class through the app.gfx
instance provided by the App class.
Constructors
- Graphics(HTMLCanvasElement _canvas, {int batchCapacityInBytes = 65536})
- Initializes the graphics system with the given HTML canvas element.
Properties
Methods
-
clear(
[double? r, double? g, double? b, double? a]) → void - Clears the drawing canvas with the specified color.
-
dispose(
) → void - Releases WebGL resources used by the graphics system.
-
drawCircle(
double x, double y, double radius, {int segments = 32, ColorList? colors}) → void -
Draws a filled circle centered at
(x, y)
with the givenradius
. -
drawImage(
Images frames, [int frame = 0, double x = 0.0, double y = 0.0, double rotation = 0.0, double scaleX = 1.0, double scaleY = 1.0, ColorList? colors]) → void -
Draws a specific
frame
from an Images sequence (sprite sheet or animation). -
drawLine(
double x1, double y1, double x2, double y2, {ColorList? colors}) → void -
Draws a line segment between
(x1, y1)
and(x2, y2)
. -
drawLines(
List< double> vertices, {ColorList? colors}) → void - Draws a series of connected line segments (a line strip).
-
drawOval(
double x, double y, double radiusX, double radiusY, {int segments = 32, ColorList? colors}) → void -
Draws a filled oval (ellipse) centered at
(x, y)
. -
drawPoint(
double x, double y) → void -
Draws a single point at the specified coordinates
(x, y)
. -
drawPoly(
List< double> vertices, {List<double> ? uvs, Texture? texture, ColorList? colors}) → void - Draws a filled polygon defined by a list of vertices.
-
drawRect(
double x, double y, double width, double height, {Texture? texture, ColorList? colors}) → void -
Draws a filled rectangle at
(x, y)
with the givenwidth
andheight
. -
drawText(
BitmapFont font, String text, {dynamic x = 0.0, dynamic y = 0.0, dynamic alignX = 0.0, dynamic alignY = 0.0, dynamic scaleX = 1.0, dynamic scaleY = 1.0, dynamic alignXByLine = true, ColorList? colors}) → Point< num> -
Draws
text
using the specified BitmapFont and rendering parameters. -
drawTexture(
Texture tex, {double? srcX, double? srcY, double? srcWidth, double? srcHeight, double? x, double? y, double? width, double? height, ColorList? colors}) → void - Draws a Texture or a portion of it onto a quad.
-
drawTriangle(
double x1, double y1, double x2, double y2, double x3, double y3, double u1, double v1, double u2, double v2, double u3, double v3, {Texture? texture, ColorList? colors}) → void - Draws a filled triangle with the specified vertex coordinates and texture coordinates.
-
flush(
) → void - Flushes all batched drawing commands to the GPU.
-
measureText(
BitmapFont font, String text) → Point< num> -
Measures the bounding box of a given
text
string when rendered with the specified BitmapFont. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
popMatrix(
) → void - Pops the top transformation matrix from the stack and makes it current.
-
pushMatrix(
) → void - Pushes a copy of the current transformation matrix onto the matrix stack.
-
resetMatrix(
) → void - Resets the current transformation matrix to the identity matrix.
-
resetScissor(
) → void - Disables scissor testing.
-
rotate(
double degrees) → void - Rotates the current transformation matrix by the given angle in degrees.
-
scale(
double sx, double sy) → void - Scales the current transformation matrix by the given factors.
-
set2DProjection(
{double x = 0.0, double y = 0.0, double? width, double? height}) → void - Configures an orthographic 2D projection matrix.
-
setBlendMode(
BlendMode mode) → void - Sets the blend mode for subsequent drawing operations.
-
setColor(
[double r = 1.0, double g = 1.0, double b = 1.0, double a = 1.0]) → void - Sets the current drawing color using individual RGBA components.
-
setColorFrom(
Color color) → void - Sets the current drawing color using a Color object.
-
setLineWidth(
double width) → void - Sets the width for lines drawn by drawLine and drawLines.
-
setProjectionMatrix(
Matrix4 matrix) → void - Sets the projection matrix used by the shaders.
-
setScissor(
int x, int y, int width, int height) → void - Enables and defines a scissor rectangle for clipping rendering.
-
setViewport(
int x, int y, int width, int height) → void - Sets the viewport.
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
double ix, double iy, double jx, double jy, double tx, double ty) → void - Applies a 2D affine transformation to the current matrix.
-
translate(
double tx, double ty) → void - Translates the current transformation matrix by the given offsets.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited