NPM: npm i @litecanvas/plugin-frogblock
CDN: https://unpkg.com/@litecanvas/plugin-frogblock/dist/dist.js
import litecanvas from "litecanvas"
import pluginFrogBlock from "@litecanvas/plugin-frogblock"
litecanvas({
width: 128,
height: 128,
pixelart: true,
})
use(pluginFrogBlock, {
scale: 1, // tileset scale (always integer)
fg: 3, // default tile color
bg: null, // default tile background color (null == transparent)
})
function draw() {
cls(0)
// optional: wait the tileset loading
if (frog.LOADING) return
// use the font to write message
// note: supports line break (\n)
frog.print(2, 2, "Hello\nWorld")
// or just draw a char from a ASCII code
const SWORD = 16
frog.spr(7, 5, SWORD)
// get the char image
const sprite = frog.img(SWORD)
image(0, 0, sprite)
}
Preview:
By default, tiles are drawn using grid-based coordinates. Every grid cell, by default, is 8x8. You can turn off this feature using frog.usegrid(false)
.
// disable the grid
frog.usegrid(false)
// now will print "YEAH!" in X=2 and Y=1
frog.print(2, 1, "YEAH!")
// enable the grid (enabled by default)
frog.usegrid(true)
// now will print "YEAH!" in X=24 and Y=8
frog.print(3, 1, "YEAH!")
You can change the color of the tiles by passing extra arguments. This will create a cache for each tile in memory.
const RED = 4
const YELLOW = 5
// print a red text with yellow background
frog.print(0, 0, "cool!", RED, YELLOW)
// print a red sword (char #16) with yellow background
frog.print(0, 1, 16, RED, YELLOW)
FROGBLOCK is a monospaced textmode font create by Polyducks for general use with additional special characters for drawing artwork with your text. Please consider support the Polyducks project if you're able to.
FROGBLOCK | ASCII |
---|---|
|
Font License: Free with attribution for commercial and non-commercial. Redistributing the font as an asset is prohibited. This product may not be used to create blockchain content, including all forms of crypto and NFTs. More detail available inside the license.txt.