Image
const image = require("@vectarine/image")ImageResource
Section titled “ImageResource”export type ImageResource = ...ImageResource:draw
Section titled “ImageResource:draw”ImageResource:draw(pos: Pos, size: Direction, color: Vec4.Vec4?): ()Draws the image at the position and with the size given You can optionally tint the image with the given color. The color of the pixels of the image are multiplied by the tint.
ImageResource:drawPart
Section titled “ImageResource:drawPart”ImageResource:drawPart( dest_p1: Pos, dest_p2: Pos, dest_p3: Pos, dest_p4: Pos, src_pos: Vec.Vec2, src_size: Vec.Vec2, color: Vec4.Vec4?,): Vec.Vec2Draws a rectangular part of the image delimited by a position and a size
This section is deformed to match the quadrilateral delimited by the 4 destination points
You can swap the destination points to rotate, flip the image.
Use src_pos = V2(0, 0) and src_size = V2(1, 1) to draw the full image.
ImageResource:getSize
Section titled “ImageResource:getSize”ImageResource:getSize(): Vec.Vec2Gets the size of the image in pixels
ImageResource:withTileset
Section titled “ImageResource:withTileset”ImageResource:withTileset(tileset: Tile.TilesetResource): ImageWithTilesetCombine an image with a tileset to be able to easily draw tiles from the image.
Methods using the ImageWithTileset require that both the image and the tileset are loaded.
They provide convenience over having to specify src_pos and src_size using drawPart.
ImageWithTileset
Section titled “ImageWithTileset”export type ImageWithTileset = ...ImageWithTileset:drawTile
Section titled “ImageWithTileset:drawTile”ImageWithTileset:drawTile( tileIdOrType: number | string, pos: Pos, size: Direction, color: Vec4.Vec4?,): ()Draw a part of the image corresponding to the tile specified by its id or type. If there are multiple tiles with the same type, one of them will be choosen in an unspecified manner.
ImageWithTileset:drawTileQuad
Section titled “ImageWithTileset:drawTileQuad”ImageWithTileset:drawTileQuad( tileIdOrType: number | string, dest_p1: Pos, dest_p2: Pos, dest_p3: Pos, dest_p4: Pos, color: Vec4.Vec4?,): ()Draw a part of the image corresponding to the tile specified by its id or type. The part of the image corresponding to the tile is deformed to match the quadrilateral delimited by the 4 destination points. If there are multiple tiles with the same type, one of them will be choosen in an unspecified manner.
type Pos = ...Direction
Section titled “Direction”type Direction = ...