Familiar territory. Bitmap keeps the RPG Maker MZ API, so existing MZ knowledge, tutorials and plugin code apply. Reactor's additions are marked with descriptions below.
The basic object that represents an image.
function Bitmap()
Quick Reference
Setup & Creation 2
| initialize() | Sets up a new instance. |
| load() | Loads a image file. |
Getting Information 4
| getPixel() | Returns pixel color at the specified point. |
| getAlphaPixel() | Returns alpha pixel value at the specified point. |
| measureTextWidth() | Returns the width of the specified text. |
| textShadow() | System.json advanced.rrTextShadow: text casts a sharp 1 px drop shadow instead of an outline, as 2000/2003 dr… |
Checks (True / False) 5
| isReady() | Checks whether the bitmap is ready to render. |
| isError() | Checks whether a loading error has occurred. |
| hasApngAnimation() | Whether an image file carries APNG animation, i.e. |
| isAnimated() | Whether this bitmap is playing a decoded animation. |
| isAnimationPaused() | Whether the animation is held. |
Actions 7
| destroy() | Destroys the bitmap. |
| clearRect() | Clears the specified rectangle. |
| clear() | Clears the entire bitmap. |
| addLoadListener() | Adds a callback function that will be called when the bitmap is loaded. |
| pauseAnimation() | Holds the animation on the frame it is showing. |
| playAnimation() | Resumes a held animation from the frame it is showing. |
| setAnimationLoopCount() | Overrides how many times the animation plays, ignoring the count the file asked for. |
Updating & Drawing 3
| drawCircle() | Draws a bitmap in the shape of a circle. |
| drawText() | Draws the outline text to the bitmap. |
| paintLegacyGlyph() | Paint one source System colour cell through a monochrome glyph mask. |
Other 15
| defaultOutlineWidth() | System.json advanced.textOutlineWidth (a 16 px game draws a 1 px shadow); 3 when the data is not loaded. |
| snap() | Takes a snapshot of the game screen. |
| resize() | Resizes the bitmap. |
| blt() | Performs a block transfer. |
| fillRect() | Fills the specified rectangle. |
| fillAll() | Fills the entire bitmap. |
| strokeRect() | Draws the specified rectangular frame. |
| retry() | Tries to load the image again. |
| pixelText() | System.json advanced.pixelatedRendering: text is placed on whole pixels. |
| legacyFontInfo() | RPG Maker 2000/2003 (System.json rrLegacyWindows): every text is drawn at the font's own size (advanced.fontS… |
| fixedFontSize() | Fixed font size. |
| parseApng() | Splits an APNG into one standalone PNG per frame. |
| parseGif() | Splits an animated GIF into one standalone single-frame GIF per frame. |
| seekAnimation() | Jumps to a frame. Earlier frames are replayed rather than skipped, because a frame in either format is a diff… |
| restartAnimation() | Replays the animation from its first frame, loop count included. |
Setup & Creation
initialize
method sourceBitmap.prototype.initialize(width, height)
Sets up a new instance. (Same as the RPG Maker MZ method of this name.)
load
static sourceBitmap.load(url, fallbackUrls)
Loads a image file.
Details
Loads a image file.
Getting Information
getPixel
method sourceBitmap.prototype.getPixel(x, y)
Returns pixel color at the specified point.
Details
Returns pixel color at the specified point.
getAlphaPixel
method sourceBitmap.prototype.getAlphaPixel(x, y)
Returns alpha pixel value at the specified point.
Details
Returns alpha pixel value at the specified point.
measureTextWidth
method sourceBitmap.prototype.measureTextWidth(text)
Returns the width of the specified text.
Details
Returns the width of the specified text.
textShadow
static sourceBitmap.textShadow()
System.json advanced.rrTextShadow: text casts a sharp 1 px drop shadow instead of an outline, as 2000/2003 drew it.
Checks (True / False)
isReady
method sourceBitmap.prototype.isReady()
Checks whether the bitmap is ready to render.
Details
Checks whether the bitmap is ready to render.
isError
method sourceBitmap.prototype.isError()
Checks whether a loading error has occurred.
Details
Checks whether a loading error has occurred.
hasApngAnimation
static sourceBitmap.hasApngAnimation(source)
Whether an image file carries APNG animation, i.e.
Details
Whether an image file carries APNG animation, i.e. an acTL chunk ahead of
the first IDAT. A file with acTL after IDAT is malformed and reads as a
plain PNG, which is what the specification asks for.
isAnimated
method sourceBitmap.prototype.isAnimated()
Whether this bitmap is playing a decoded animation.
Details
Whether this bitmap is playing a decoded animation.
isAnimationPaused
method sourceBitmap.prototype.isAnimationPaused()
Whether the animation is held.
Details
Whether the animation is held.
Actions
destroy
method sourceBitmap.prototype.destroy()
Destroys the bitmap.
clearRect
method sourceBitmap.prototype.clearRect(x, y, width, height)
Clears the specified rectangle.
Details
Clears the specified rectangle.
clear
method sourceBitmap.prototype.clear()
Clears the entire bitmap.
addLoadListener
method sourceBitmap.prototype.addLoadListener(listner)
Adds a callback function that will be called when the bitmap is loaded.
Details
Adds a callback function that will be called when the bitmap is loaded.
pauseAnimation
method sourceBitmap.prototype.pauseAnimation()
Holds the animation on the frame it is showing.
playAnimation
method sourceBitmap.prototype.playAnimation()
Resumes a held animation from the frame it is showing.
setAnimationLoopCount
method sourceBitmap.prototype.setAnimationLoopCount(count)
Overrides how many times the animation plays, ignoring the count the file asked for.
Details
Overrides how many times the animation plays, ignoring the count the file asked for. A GIF with no loop block asks to be shown once; this is how a plugin makes one loop forever.
Updating & Drawing
drawCircle
method sourceBitmap.prototype.drawCircle(x, y, radius, color)
Draws a bitmap in the shape of a circle.
Details
Draws a bitmap in the shape of a circle.
drawText
method sourceBitmap.prototype.drawText(text, x, y, maxWidth, lineHeight, align)
Draws the outline text to the bitmap.
Details
Draws the outline text to the bitmap.
paintLegacyGlyph
static sourceBitmap.paintLegacyGlyph(pixels, width, height, pad, ascent, paint, shadow)
Paint one source System colour cell through a monochrome glyph mask.
Other
defaultOutlineWidth
static sourceBitmap.defaultOutlineWidth()
System.json advanced.textOutlineWidth (a 16 px game draws a 1 px shadow); 3 when the data is not loaded.
snap
static sourceBitmap.snap(stage)
Takes a snapshot of the game screen.
Details
Takes a snapshot of the game screen.
resize
method sourceBitmap.prototype.resize(width, height)
Resizes the bitmap.
Details
Resizes the bitmap.
blt
method sourceBitmap.prototype.blt(source, sx, sy, sw, sh, dx, dy, dw, dh)
Performs a block transfer.
Details
Performs a block transfer.
fillRect
method sourceBitmap.prototype.fillRect(x, y, width, height, color)
Fills the specified rectangle.
Details
Fills the specified rectangle.
fillAll
method sourceBitmap.prototype.fillAll(color)
Fills the entire bitmap.
Details
Fills the entire bitmap.
strokeRect
method sourceBitmap.prototype.strokeRect(x, y, width, height, color)
Draws the specified rectangular frame.
Details
Draws the specified rectangular frame.
retry
method sourceBitmap.prototype.retry()
Tries to load the image again.
pixelText
static sourceBitmap.pixelText()
System.json advanced.pixelatedRendering: text is placed on whole pixels.
legacyFontInfo
static sourceBitmap.legacyFontInfo()
RPG Maker 2000/2003 (System.json rrLegacyWindows): every text is drawn at the font's own size (advanced.fontSize) and at its natural width, never squeezed; a pixel font at any other size blurs.
fixedFontSize
static sourceBitmap.fixedFontSize()
Fixed font size. (Same as the RPG Maker MZ method of this name.)
parseApng
static sourceBitmap.parseApng(source)
Splits an APNG into one standalone PNG per frame.
Details
Splits an APNG into one standalone PNG per frame.
Returns null for anything that is not a usable animation -- not a PNG, no
acTL, a single frame, a frame with no data -- so callers fall back to the
ordinary static path rather than failing on a file the engine can still show.
parseGif
static sourceBitmap.parseGif(source)
Splits an animated GIF into one standalone single-frame GIF per frame.
Details
Splits an animated GIF into one standalone single-frame GIF per frame.
The LZW data is copied across byte for byte, interlace flag included, so no decompression happens here -- each frame is handed back to the browser as a tiny GIF of its own. Returns null for a still GIF or anything unreadable, so callers fall back to the ordinary static path.
seekAnimation
method sourceBitmap.prototype.seekAnimation(index)
Jumps to a frame. Earlier frames are replayed rather than skipped, because a frame in either format is a difference against the ones before it, not a whole picture.
Details
Jumps to a frame. Earlier frames are replayed rather than skipped, because a frame in either format is a difference against the ones before it, not a whole picture.
restartAnimation
method sourceBitmap.prototype.restartAnimation()
Replays the animation from its first frame, loop count included.