2.0.3 • Published 3 years ago
image-filler v2.0.3
Image Filler
Fills a canvas with a pattern, using the canvas package.
Usage
Install this package by
npm i image-fillerImport the package in your script by
import { fillCanvasRegion, fillNewCanvas, fillCanvas } from "image-filler"The functions are defined as follows
function fillCanvasRegion(pattern: string | Buffer, canvas: Canvas, start: Vec2, dimension: Vec2, offset = VEC2_ZERO, shiftX = 0): Promise<Canvas>
function fillNewCanvas(pattern: string | Buffer, dimension: Vec2, offset = VEC2_ZERO, shiftX = 0): Promise<Canvas>
function fillCanvas(pattern: string | Buffer, canvas: Canvas, offset = VEC2_ZERO, shiftX = 0): Promise<Canvas>All parameters sharing the same name have the same meaning.
pattern: Path or Buffer of the patterncanvas: User-created canvasstart: Starting coordinates of the regiondimension: Width and height of the regionoffset: Gap (both x and y, in pixels) between 2 patternsshiftX: Horizontal shift when filling patterns on next line
Vec2 is an interface that can be created by { x: number, y: number }.
All functions return the resulted canvas.
Example/Testing
Check test/test.ts for example.
- Clone this repo
- Run
npm i - Run
npm run build - Run
npm test. This will executetest/test.ts.
License
GNU GPL v3