Skip to main content
Module

x/sdl2/mod.ts>Canvas

SDL2 module for Deno
Go to Latest
class Canvas
import { Canvas } from "https://deno.land/x/sdl2@0.6.0/mod.ts";

SDL2 canvas.

Methods

Clear the current rendering target with the drawing color.

copy(
texture: Texture,
source?: Rect,
dest?: Rect,
)

Copy a portion of the texture to the current rendering target.

drawLine(
x1: number,
y1: number,
x2: number,
y2: number,
)

Draw a line on the current rendering target.

drawLines(points: [number, number][])

Draw a series of connected lines on the current rendering target.

drawPoint(x: number, y: number)

Draw a point on the current rendering target.

drawPoints(points: [number, number][])

Draw multiple points on the current rendering target.

drawRect(
x: number,
y: number,
w: number,
h: number,
)

Draw a rectangle on the current rendering target.

drawRects(rects:
[
number,
number,
number,
number,
]
[]
)

Draw some number of rectangles on the current rendering target.

fillRect(
x: number,
y: number,
w: number,
h: number,
)

Fill a rectangle on the current rendering target with the drawing color.

fillRects(rects:
[
number,
number,
number,
number,
]
[]
)

Fill some number of rectangles on the current rendering target with the drawing color.

loadFont(path: string, size: number)

Create a font from a file, using a specified point size.

Update the screen with any rendering performed since the previous call.

setDrawColor(
r: number,
g: number,
b: number,
a: number,
)

Set the color used for drawing operations (Rect, Line and Clear).

TextureCreator is a helper class for creating textures.