The art studio
phantom.aj.artStudioMaking art
The art studio: canvas, grid, painting pictures stroke by stroke, pottery, prints.
Scripts and plugins
A script has all of it, as phantom.aj.artStudio, and so does a plugin, from ctx.phantom(): the SDK runs in the plugin's own frame. Each call is marked with what it needs: game:read for what the area knows and hears, which "game": "read" in the manifest grants, and game:act for doing things in it as the player, which needs "game": "act" (see Permissions).
Overview
| Member | What it does | Plugins |
|---|---|---|
close() | Leaves the studio at once, as the yes to its own Are you sure does (onExit_Yes), unsaved work and all, and resolves once it has gone. | game:act |
current() | The studio on screen as it stands, or null when the game on screen is none of the four: its canvas, tool, brush and colour for the painting and grid studios, the pot or picture for the others, all in one message. | game:read |
isOpen() | Whether one of the four studios is the game on screen. | game:read |
open() | Opens a studio as clicking its easel does (MinigameManager.handleGameClick, with the game the client knows by that studio's movie), and resolves with it once it is built. | game:act |
print() | Prints what the studio shows, at once: the canvas (onPrintButton), the pot, or the print. | game:act |
onClose() | Hears a studio close (end), which every way out goes through. | game:read |
onOpen() | Hears a studio open, once it is built and can be drawn on (sceneLoaded, at its end, with _sceneLoaded set). | game:read |
onPrint() | Hears a studio send something to the printer: a canvas studio's Print with a picture and no question up (onPrintButton), the pottery studio's yes to printing (onPrint_Yes), and the print studio once the page has loaded (printImageMediaHandler). | game:read |
artStudio.canvas: The canvas of the painting or grid drawing studio: phantom.aj.artStudio.canvas.
| Member | What it does | Plugins |
|---|---|---|
brush() | The brush as it would draw now: tool, width, the airbrush's spray and the smudge's reach at that width (_airbrushes, _smudges), colour, and whether a stroke is under way. | game:read |
clear() | Clears the canvas at once, as the studio's own Clear does after its question (handleClear): the picture goes, the one step of undo holds it, and the buttons grey out. | game:act |
current() | The canvas studio on screen as it stands, or null when none is. | game:read |
fill() | Pours the fill bucket at a point (BitmapData.floodFill), as clicking there with it does. | game:act |
markSaved() | Marks the picture saved or unsaved (_needsSave), which decides whether leaving asks to save first and whether the storage dialog's Save is lit. | game:act |
openSketches() | Opens what the studio's sketch button opens (onSketchButton): list 77 of Animal Jam's own lists. | game:act |
palette() | The brush widths and the swatches kept in the studio's picker (saveColors). | game:act |
picture() | The canvas as a PNG data: URL, on white: the studio's own bitmap (_drawBitmap), which is the picture it would submit. | game:read |
redo() | Puts back what undo took, which is the undo arrow pressed again: the studio keeps one step, and swaps it back and forth. | game:act |
setBrushSize() | Chooses a brush width, 1 to 6 as the interface numbers them (2, 5, 10, 20, 35 and 50 pixels in the painting studio), and resolves with it once the studio holds it. | game:act |
setBrushWidths() | Sets how thick each of the painting studio's six brushes is (_drawSizes), thinnest first, each a whole 1 to 255. | game:act |
setColor() | Mixes a colour in the picker: the red, green and blue every tool reads, and the brush tip's tint the airbrush and the grid pencil draw through. | game:act |
setTool() | Chooses a tool, as clicking it in the studio's tool row does (currentTool), and resolves with it once the studio holds it. | game:act |
shape() | Draws one of the painting studio's outlines, as dragging that tool from one corner to another does: a line, a rectangle, an ellipse around from, or a triangle. | game:act |
stroke() | Draws a stroke through the points, as dragging the brush or the airbrush across the canvas does, finished through the studio's own endDraw, which is what lights Submit and the rest. | game:act |
undo() | Takes the last stroke back, as the undo arrow does: the studio swaps its canvas for its one undo copy on its next frame (heartbeat). | game:act |
onBrushChange() | Hears the tool, brush width or colour change. | game:read |
onClear() | Hears the canvas cleared (handleClear): the Clear button, a picture sent, or clear. | game:read |
onFileLoaded() | Hears a picture loaded from a .ajart file onto the canvas, or failing to (handleLoad, handleLoadError), some time after the player picks it in the storage dialog. | game:read |
onSaved() | Hears the picture saved to a file (handleSaveComplete). | game:read |
onStroke() | Hears every stroke as it starts: the player's, by hooking the studio's own startDraw, and the SDK's own, as stroke, shape, fill, grid.setCells and painter draw them. | game:read |
onStrokeEnd() | Hears a stroke finish (endDraw), the player's and the SDK's alike, told only while one was under way (_drawing), since the studio runs it for every mouse release. | game:read |
onUndoChange() | Hears the one step of undo change (_undoable): a stroke or a clear makes the canvas undoable, the arrow makes it not, and the arrow again puts it back. | game:read |
artStudio.grid: The grid drawing studio's squares: phantom.aj.artStudio.grid.
| Member | What it does | Plugins |
|---|---|---|
current() | The grid: the square, how many the canvas holds, and the studio's pan and zoom; or null. | game:read |
setCells() | Fills squares with the pencil, one stroke for all of them, finished through the studio's endDraw as a stroke of the player's is. | game:act |
setCellSize() | Sets the square a stroke snaps to (_gridPixelSize), read only by moveMouse. | game:act |
setView() | Pans and zooms the studio's own idea of where the pointer lands on the grid (_scrollX, _scrollY, _zoomFactor), which moveMouse reads and nothing else does. | game:act |
artStudio.painter: Painting whole pictures onto the canvas, stroke by stroke: phantom.aj.artStudio.painter.
| Member | What it does | Plugins |
|---|---|---|
current() | How far the painting running now has got, or null when none is. | game:read |
paint() | Starts painting a picture onto the open canvas, and resolves once it has begun with the run: call it or stop() to end it, hear onProgress, and await done for what was painted. | game:act |
plan() | What a picture would come out as, drawing nothing: its colours, every cell's colour, a preview at a pixel a cell, and the runs each colour takes. | game:read |
onDone() | Hears every painting end: completed, stopped, or failed because the studio went. | game:read |
onProgress() | Hears every painting as it goes, whoever started it: once for each batch of strokes. | game:read |
artStudio.submissions: Sending pictures to Animal Jam from the canvas studios: phantom.aj.artStudio.submissions.
| Member | What it does | Plugins |
|---|---|---|
current() | How many pictures this computer has sent, and when the next may go: the client keeps the times of the last five in its saved settings (_sharedObject.data.userSubmits) and sends another only once the oldest is a day old. | game:read |
submit() | Sends the picture to Animal Jam at once, as the yes of the studio's Send this? | game:act |
onResult() | Hears what became of every picture packed up, Submit's and a masterpiece's alike: taken (onSendComplete), failed or refused (onSendError), or not sent at all because of the daily limit or missing settings (asyncEncodingComplete), when the client still shows its thank you. | game:read |
onStart() | Hears a picture start on its way, as the studio packs it up (encodeImage): Submit, or a masterpiece being bought. | game:read |
artStudio.masterpiece: Making the picture on the canvas a masterpiece for the den, through the studio's own chooser: phantom.aj.artStudio.masterpiece.
| Member | What it does | Plugins |
|---|---|---|
choose() | Previews the picture in one of the four frames showing, 0 to 3 from the left, as clicking it does (onPreviewIcon); the preview's Buy is the player's. | game:act |
close() | Closes the chooser, as its X does (onChooseMasterpiecePopupClose). | game:act |
current() | The chooser: whether it is up, the frames (empty until Animal Jam sends the list, lists 416 and 424), the page, the frame previewed, the tokens held and the price. | game:read |
open() | Opens the chooser, as the studio's masterpiece button does (onCreateMasterpieceBtn), and resolves with it once it is on screen; its art loads the first time. | game:act |
page() | Turns to the next or the last page of four frames, by pressing the chooser's own arrow (arrowRBtn, arrowLBtn), wrapping round. | game:act |
onBought() | Hears a masterpiece bought, as the studio's own purchase is answered (onPreviewItemBuy): whether it went through, the diamonds left, and the den item it arrived as. | game:read |
onChange() | Hears the chooser step by step: opened and closed (onChooseMasterpiecePopupLoaded, onChooseMasterpiecePopupClose), the frames laid out (setupMasterpieceWindows, as they arrive and as the page turns), a preview up and down with buying when the player pressed Buy (onPreviewIcon, onPreviewClose), the submission rules answered (onSubmissionRulesClose), and the masterpiece arriving in the den inventory (onPreviewBuyInventoryResponse). | game:read |
artStudio.dialogs: The studios' own dialogs: phantom.aj.artStudio.dialogs.
| Member | What it does | Plugins |
|---|---|---|
answer() | Answers the dialog that is up by calling what its own button calls (onExit_Yes, onExit_No, onSubmit_Yes, onClear_Yes, onStorage_Close, onPrint_Yes, onPrint_No), and resolves with the answer given. | game:act |
ask() | Puts up one of the studio's dialogs by pressing the button that asks it (onCloseButton, onSubmitButton, onClearAllButton, onStorageButton, the pottery studio's onButtonPrint), for the player to answer, and resolves with it once it is up. | game:act |
current() | The dialog the open studio shows, or null when none is up (activeDlgMC). | game:read |
onChange() | Hears the dialogs go up and be answered, by the buttons that ask them and the ones that answer them. | game:read |
artStudio.pottery: The pottery studio: phantom.aj.artStudio.pottery.
| Member | What it does | Plugins |
|---|---|---|
browse() | Steps through the designs, as the studio's own arrows do (onButtonLeft, onButtonRight), wrapping round, and resolves with the one now showing once it has loaded. | game:act |
browseTo() | Goes straight to one design, from 0, as stepping there with the arrows would: the index set and the studio's own loadImage run, so everything that follows the arrows follows this. | game:act |
colour() | Takes the pot showing to the colouring stage, as the paint button does (onButtonColor), and resolves once it is there. | game:act |
current() | The pot showing, its two movies, and whether it is being coloured; or null. | game:read |
print() | Prints what is showing, at once: the pottery studio's yes to its print question (onPrint_Yes), the print studio's Print (onButtonPrint, which prints once the page has loaded). | game:act |
onBrowse() | Hears a design shown once it has loaded (artStudioImageMediaHandler, printMediaHandler). | game:read |
onColouring() | Hears a pot taken to the colouring stage (onButtonColor, when the studio acts on it). | game:read |
artStudio.prints: The print studio: phantom.aj.artStudio.prints.
| Member | What it does | Plugins |
|---|---|---|
browse() | Steps through the designs, as the studio's own arrows do (onButtonLeft, onButtonRight), wrapping round, and resolves with the one now showing once it has loaded. | game:act |
browseTo() | Goes straight to one design, from 0, as stepping there with the arrows would: the index set and the studio's own loadImage run, so everything that follows the arrows follows this. | game:act |
current() | The picture showing, its page and where it is printed on it; or null. | game:read |
print() | Prints what is showing, at once: the pottery studio's yes to its print question (onPrint_Yes), the print studio's Print (onButtonPrint, which prints once the page has loaded). | game:act |
onBrowse() | Hears a design shown once it has loaded (artStudioImageMediaHandler, printMediaHandler). | game:read |
artStudio.portraits: The play portrait prints (game.artPrintPlayPortrait.ArtPrintPlayPortrait): phantom.aj.artStudio.portraits.
| Member | What it does | Plugins |
|---|---|---|
browse() | Steps the row by one, as the arrows and the arrow keys do, wrapping; resolves with the row. | game:act |
close() | Leaves them, as their own X does (onExit); they do not ask first. | game:act |
current() | The pictures on offer, how many have loaded, and the three showing; null when not up. | game:read |
open() | Opens the prints as clicking them in their room does (handleGameClick), and resolves with them once built. | game:act |
print() | Prints one of the three showing, 0 to 2 from the left, as clicking it does (onPage0 to onPage2); the computer's print dialog is the player's to answer. | game:act |
showFrom() | Shows the row from one picture on, as stepping round to it would: the index set and the row redrawn (updateButtonImages). | game:act |
onChange() | Hears the row change (updateButtonImages): a picture loaded, or the row stepped. | game:read |
onClose() | Hears them close (end). | game:read |
onOpen() | Hears them built (sceneLoaded, at exit); the pictures start loading then. | game:read |
onPrint() | Hears a picture pressed (onPage0 to onPage2), and whether it had loaded and so printed. | game:read |
Methods
close
close(options?: ActOptions) => Promise<ArtStudioKind>Leaves the studio at once, as the yes to its own Are you sure does (onExit_Yes), unsaved work and all, and resolves once it has gone. To let the player decide, dialogs.ask('exit').
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ArtStudioKind>
Types
current
current() => Promise<ArtStudio | null>The studio on screen as it stands, or null when the game on screen is none of the four: its canvas, tool, brush and colour for the painting and grid studios, the pot or picture for the others, all in one message. ready is false while it is still being built.
Returns
Promise<ArtStudio \| null>
Types
ArtCanvasState · ArtCanvasKind · ArtPotteryState · ArtPrintState
isOpen
isOpen() => Promise<boolean>Whether one of the four studios is the game on screen.
Returns
Promise<boolean>
open
open(kind: ArtStudioKind, options?: ArtOpenOptions) => Promise<ArtStudio>Opens a studio as clicking its easel does (MinigameManager.handleGameClick, with the game the client knows by that studio's movie), and resolves with it once it is built. The server seats the player and has the last word, so a refusal shows as TIMEOUT (30 seconds by default).
Parameters
| Name | Type | |
|---|---|---|
kind | ArtStudioKind | |
options optional | ArtOpenOptions |
Returns
Promise<ArtStudio>
Types
ArtStudioKind · ArtOpenOptions · ActOptions · ArtStudio
Example
print
print(options?: ActOptions) => Promise<ArtStudioKind>Prints what the studio shows, at once: the canvas (onPrintButton), the pot, or the print. The computer's own print dialog follows, the player's to answer. NOT_READY with nothing drawn, REFUSED while one of the studio's questions is up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ArtStudioKind>
Types
Events
onClose
onClose(listener: (kind: ArtStudioKind) => void) => () => voidHears a studio close (end), which every way out goes through.
Parameters
| Name | Type | |
|---|---|---|
listener | (kind: ArtStudioKind) => void |
Returns
() => void. Call it to stop listening.
Types
onOpen
onOpen(listener: (kind: ArtStudioKind) => void) => () => voidHears a studio open, once it is built and can be drawn on (sceneLoaded, at its end, with _sceneLoaded set).
Parameters
| Name | Type | |
|---|---|---|
listener | (kind: ArtStudioKind) => void |
Returns
() => void. Call it to stop listening.
Types
onPrint
onPrint(listener: (kind: ArtStudioKind) => void) => () => voidHears a studio send something to the printer: a canvas studio's Print with a picture and no question up (onPrintButton), the pottery studio's yes to printing (onPrint_Yes), and the print studio once the page has loaded (printImageMediaHandler).
Parameters
| Name | Type | |
|---|---|---|
listener | (kind: ArtStudioKind) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.canvas
The canvas of the painting or grid drawing studio: phantom.aj.artStudio.canvas. What is on it and what it paints with, and drawing on it as the player does, through the studio's own objects and its own endDraw, so what is drawn here is what the studio saves and sends.
await phantom.aj.artStudio.canvas.setColor(0xff8800);
await phantom.aj.artStudio.canvas.stroke([{ x: 40, y: 40 }, { x: 300, y: 220 }], { size: 3 });brush
brush() => Promise<ArtBrush | null>The brush as it would draw now: tool, width, the airbrush's spray and the smudge's reach at that width (_airbrushes, _smudges), colour, and whether a stroke is under way.
Returns
Promise<ArtBrush \| null>
Types
clear
clear(options?: ActOptions) => Promise<void>Clears the canvas at once, as the studio's own Clear does after its question (handleClear): the picture goes, the one step of undo holds it, and the buttons grey out. To ask the player first, dialogs.ask('clear').
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<ArtCanvasState | null>The canvas studio on screen as it stands, or null when none is.
Returns
Promise<ArtCanvasState \| null>
Types
fill
fill(point: ArtPoint, options?: ActOptions & { color?: number | undefined; }) => Promise<ArtStroke>Pours the fill bucket at a point (BitmapData.floodFill), as clicking there with it does. As in the studio, a fill alone does not count as drawn: Submit stays grey until a stroke is made.
Parameters
| Name | Type | |
|---|---|---|
point | ArtPoint | |
options optional | ActOptions & { color?: number | undefined; } |
Returns
Promise<ArtStroke>
Types
markSaved
markSaved(saved: boolean, options?: ActOptions) => Promise<void>Marks the picture saved or unsaved (_needsSave), which decides whether leaving asks to save first and whether the storage dialog's Save is lit. The next stroke marks it unsaved again. This screen only.
Parameters
| Name | Type | |
|---|---|---|
saved | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
openSketches
openSketches(options?: ActOptions) => Promise<void>Opens what the studio's sketch button opens (onSketchButton): list 77 of Animal Jam's own lists. REFUSED while one of its questions is up, when the button does nothing.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
palette
palette() => Promise<ArtPalette | null>The brush widths and the swatches kept in the studio's picker (saveColors).
Returns
Promise<ArtPalette \| null>
Types
picture
picture(options?: { scale?: number | undefined; maxSize?: number | undefined; }) => Promise<string | null>The canvas as a PNG data: URL, on white: the studio's own bitmap (_drawBitmap), which is the picture it would submit. Null when no canvas studio is built.
Parameters
| Name | Type | |
|---|---|---|
options optional | { scale?: number | undefined; maxSize?: number | undefined; } |
Returns
Promise<string \| null>
redo
redo(options?: ActOptions) => Promise<void>Puts back what undo took, which is the undo arrow pressed again: the studio keeps one step, and swaps it back and forth. NOT_READY when there is a stroke to undo instead.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
setBrushSize
setBrushSize(size: number, options?: ActOptions) => Promise<number>Chooses a brush width, 1 to 6 as the interface numbers them (2, 5, 10, 20, 35 and 50 pixels in the painting studio), and resolves with it once the studio holds it.
Parameters
| Name | Type | |
|---|---|---|
size | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
setBrushWidths
setBrushWidths(widths: readonly number[], options?: ActOptions) => Promise<number[]>Sets how thick each of the painting studio's six brushes is (_drawSizes), thinnest first, each a whole 1 to 255. Exactly six, since the airbrush and smudge tips are kept six to match. Until the studio is left; this screen only.
Parameters
| Name | Type | |
|---|---|---|
widths | readonly number[] | |
options optional | ActOptions |
Returns
Promise<number[]>
Types
setColor
setColor(color: number, options?: ActOptions) => Promise<number>Mixes a colour in the picker: the red, green and blue every tool reads, and the brush tip's tint the airbrush and the grid pencil draw through. Resolves with it, 0xRRGGBB.
Parameters
| Name | Type | |
|---|---|---|
color | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
setTool
setTool(tool: ArtTool, options?: ActOptions) => Promise<ArtTool>Chooses a tool, as clicking it in the studio's tool row does (currentTool), and resolves with it once the studio holds it. REFUSED for a tool this studio has not got.
Parameters
| Name | Type | |
|---|---|---|
tool | ArtTool | |
options optional | ActOptions |
Returns
Promise<ArtTool>
Types
shape
shape(shape: ArtShape, from: ArtPoint, to: ArtPoint, options?: ActOptions & { color?: number | undefined; size?: number | undefined; }) => Promise<ArtStroke>Draws one of the painting studio's outlines, as dragging that tool from one corner to another does: a line, a rectangle, an ellipse around from, or a triangle. NOT_READY in the grid studio, which has no shapes.
Parameters
| Name | Type | |
|---|---|---|
shape | ArtShape | |
from | ArtPoint | |
to | ArtPoint | |
options optional | ActOptions & { color?: number | undefined; size?: number | undefined; } |
Returns
Promise<ArtStroke>
Types
ArtShape · ActOptions · ArtPoint · ArtStroke
stroke
stroke(points: readonly ArtPoint[], options?: ArtStrokeOptions) => Promise<ArtStroke>Draws a stroke through the points, as dragging the brush or the airbrush across the canvas does, finished through the studio's own endDraw, which is what lights Submit and the rest. In the grid studio each point fills the square it is in. Resolves with the stroke drawn.
Parameters
| Name | Type | |
|---|---|---|
points | readonly ArtPoint[] | |
options optional | ArtStrokeOptions |
Returns
Promise<ArtStroke>
Types
ArtPoint · ArtStrokeOptions · ArtStroke
Example
await phantom.aj.artStudio.canvas.stroke([{ x: 60, y: 60 }, { x: 160, y: 120 }], { color: 0x000000, size: 2 });undo
undo(options?: ActOptions) => Promise<void>Takes the last stroke back, as the undo arrow does: the studio swaps its canvas for its one undo copy on its next frame (heartbeat). NOT_READY when there is nothing to undo.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
onBrushChange
onBrushChange(listener: (brush: ArtBrushChange) => void) => () => voidHears the tool, brush width or colour change. The studio's tool row and picker are in its interface movie, which calls nothing in the client, so this is watched a few times a second.
Parameters
| Name | Type | |
|---|---|---|
listener | (brush: ArtBrushChange) => void |
Returns
() => void. Call it to stop listening.
Types
onClear
onClear(listener: (kind: ArtCanvasKind) => void) => () => voidHears the canvas cleared (handleClear): the Clear button, a picture sent, or clear.
Parameters
| Name | Type | |
|---|---|---|
listener | (kind: ArtCanvasKind) => void |
Returns
() => void. Call it to stop listening.
Types
onFileLoaded
onFileLoaded(listener: (loaded: ArtFileLoaded) => void) => () => voidHears a picture loaded from a .ajart file onto the canvas, or failing to (handleLoad, handleLoadError), some time after the player picks it in the storage dialog.
Parameters
| Name | Type | |
|---|---|---|
listener | (loaded: ArtFileLoaded) => void |
Returns
() => void. Call it to stop listening.
Types
onSaved
onSaved(listener: (kind: ArtCanvasKind) => void) => () => voidHears the picture saved to a file (handleSaveComplete).
Parameters
| Name | Type | |
|---|---|---|
listener | (kind: ArtCanvasKind) => void |
Returns
() => void. Call it to stop listening.
Types
onStroke
onStroke(listener: (stroke: ArtStroke) => void) => () => voidHears every stroke as it starts: the player's, by hooking the studio's own startDraw, and the SDK's own, as stroke, shape, fill, grid.setCells and painter draw them.
Parameters
| Name | Type | |
|---|---|---|
listener | (stroke: ArtStroke) => void |
Returns
() => void. Call it to stop listening.
Types
onStrokeEnd
onStrokeEnd(listener: (stroke: ArtStrokeEnd) => void) => () => voidHears a stroke finish (endDraw), the player's and the SDK's alike, told only while one was under way (_drawing), since the studio runs it for every mouse release. A fill has no end.
Parameters
| Name | Type | |
|---|---|---|
listener | (stroke: ArtStrokeEnd) => void |
Returns
() => void. Call it to stop listening.
Types
onUndoChange
onUndoChange(listener: (change: ArtUndoChange) => void) => () => voidHears the one step of undo change (_undoable): a stroke or a clear makes the canvas undoable, the arrow makes it not, and the arrow again puts it back. Watched, since the swap is in the studio's every-frame heartbeat.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: ArtUndoChange) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.grid
The grid drawing studio's squares: phantom.aj.artStudio.grid. Drawing is a square at a time with the studio's own pencil, counted in squares from the top left, as clicking each one does.
const grid = await phantom.aj.artStudio.grid.current();
if (grid) await phantom.aj.artStudio.grid.setCells([{ column: 0, row: 0, color: 0xff0000 }]);current
current() => Promise<ArtGrid | null>The grid: the square, how many the canvas holds, and the studio's pan and zoom; or null.
Returns
Promise<ArtGrid \| null>
Types
setCells
setCells(cells: readonly ArtCell[], options?: ActOptions) => Promise<number>Fills squares with the pencil, one stroke for all of them, finished through the studio's endDraw as a stroke of the player's is. Resolves with how many were filled.
Parameters
| Name | Type | |
|---|---|---|
cells | readonly ArtCell[] | |
options optional | ActOptions |
Returns
Promise<number>
Types
setCellSize
setCellSize(size: number, options?: ActOptions) => Promise<ArtGrid>Sets the square a stroke snaps to (_gridPixelSize), read only by moveMouse. The grid on screen and the pencil's stamp keep the studio's own size, so another leaves them out of step. Until the studio is left; this screen only.
Parameters
| Name | Type | |
|---|---|---|
size | number | |
options optional | ActOptions |
Returns
Promise<ArtGrid>
Types
setView
setView(view: { scrollX?: number | undefined; scrollY?: number | undefined; zoom?: number | undefined; }, options?: ActOptions) => Promise<ArtGrid>Pans and zooms the studio's own idea of where the pointer lands on the grid (_scrollX, _scrollY, _zoomFactor), which moveMouse reads and nothing else does. The grid on screen does not move with it, so strokes land away from the pointer. Each is left as it is when left out; a zoom below 1 is refused. This screen only.
Parameters
| Name | Type | |
|---|---|---|
view | { scrollX?: number | undefined; scrollY?: number | undefined; zoom?: number | undefined; } | |
options optional | ActOptions |
Returns
Promise<ArtGrid>
Types
artStudio.painter
Painting whole pictures onto the canvas, stroke by stroke: phantom.aj.artStudio.painter.
A picture is fitted to the canvas, cut into cells the size of the brush (or the grid's square), and reduced to a few dozen colours chosen from the picture itself. Each colour is one pass of the studio's own brush, finished through its own endDraw, which snaps every pixel the pass changed to that colour. What comes out is drawn with the studio's tools, in colours its picker mixes.
const plan = await phantom.aj.artStudio.painter.plan(png, { colors: 16 });
const run = await phantom.aj.artStudio.painter.paint(png, { colors: 16, speed: 'steady' });
run.onProgress(({ strokes, totalStrokes }) => bar.value = strokes / totalStrokes);
const { outcome } = await run.done;current
current() => ArtPaintProgress | nullHow far the painting running now has got, or null when none is.
Returns
ArtPaintProgress \| null
Types
paint
paint(image: ArtPictureInput, options?: ArtPaintOptions) => Promise<ArtPaintRun>Starts painting a picture onto the open canvas, and resolves once it has begun with the run: call it or stop() to end it, hear onProgress, and await done for what was painted. REFUSED while another painting runs; NOT_READY with no canvas studio built.
Parameters
| Name | Type | |
|---|---|---|
image | ArtPictureInput | |
options optional | ArtPaintOptions |
Returns
Promise<ArtPaintRun>
Types
ArtPaintOptions · ArtPaintRun · ArtPaintStart · ArtPaintResult · ArtPaintProgress · ArtPictureInput
plan
plan(image: ArtPictureInput, options?: ArtPlanFor) => Promise<ArtPaintingPlan>What a picture would come out as, drawing nothing: its colours, every cell's colour, a preview at a pixel a cell, and the runs each colour takes. For the canvas on screen, or for canvas when given (the painting studio's brush widths are used for brushSize).
Parameters
| Name | Type | |
|---|---|---|
image | ArtPictureInput | |
options optional | ArtPlanFor |
Returns
Promise<ArtPaintingPlan>
Types
ArtPictureInput · ArtImage · ArtPlanFor · ArtPlanOptions · ArtPaintingPlan · ArtRun
onDone
onDone(listener: (result: ArtPaintResult) => void) => () => voidHears every painting end: completed, stopped, or failed because the studio went.
Parameters
| Name | Type | |
|---|---|---|
listener | (result: ArtPaintResult) => void |
Returns
() => void. Call it to stop listening.
Types
onProgress
onProgress(listener: (progress: ArtPaintProgress) => void) => () => voidHears every painting as it goes, whoever started it: once for each batch of strokes.
Parameters
| Name | Type | |
|---|---|---|
listener | (progress: ArtPaintProgress) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.submissions
Sending pictures to Animal Jam from the canvas studios: phantom.aj.artStudio.submissions. The picture is packed by the client's own JPEG encoder and uploaded by its own code, so Animal Jam's own limit of five a day applies, and the canvas is cleared afterwards, as for a player.
const sent = await phantom.aj.artStudio.submissions.current();
if (sent?.left) await phantom.aj.artStudio.submissions.submit();current
current() => Promise<ArtSubmissions | null>How many pictures this computer has sent, and when the next may go: the client keeps the times of the last five in its saved settings (_sharedObject.data.userSubmits) and sends another only once the oldest is a day old. Masterpieces are not counted. Null with no canvas.
Returns
Promise<ArtSubmissions \| null>
Types
submit
submit(options?: ActOptions) => Promise<ArtSubmitResult>Sends the picture to Animal Jam at once, as the yes of the studio's Send this? does (onSubmit_Yes), and resolves once Animal Jam has taken it. Throws REFUSED with the reason when it is not sent: the upload failed, the account was refused, or five went within a day, which the client itself says nothing about. To let the player answer the question, dialogs.ask('submit'). Sixty seconds by default.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ArtSubmitResult>
Types
onResult
onResult(listener: (result: ArtSubmitResult) => void) => () => voidHears what became of every picture packed up, Submit's and a masterpiece's alike: taken (onSendComplete), failed or refused (onSendError), or not sent at all because of the daily limit or missing settings (asyncEncodingComplete), when the client still shows its thank you.
Parameters
| Name | Type | |
|---|---|---|
listener | (result: ArtSubmitResult) => void |
Returns
() => void. Call it to stop listening.
Types
onStart
onStart(listener: (start: ArtSubmitStart) => void) => () => voidHears a picture start on its way, as the studio packs it up (encodeImage): Submit, or a masterpiece being bought.
Parameters
| Name | Type | |
|---|---|---|
listener | (start: ArtSubmitStart) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.masterpiece
Making the picture on the canvas a masterpiece for the den, through the studio's own chooser: phantom.aj.artStudio.masterpiece. The frames, the preview of the picture in one, and the diamonds or token it costs. Buying is the player's own click on the studio's own popup, and stays that way: this opens, pages and previews, and hears the purchase.
await phantom.aj.artStudio.masterpiece.open();
phantom.aj.artStudio.masterpiece.onBought(({ ok, diamonds }) => console.log(ok, diamonds));choose
choose(slot: 0 | 1 | 2 | 3, options?: ActOptions) => Promise<ArtMasterpieceChooser>Previews the picture in one of the four frames showing, 0 to 3 from the left, as clicking it does (onPreviewIcon); the preview's Buy is the player's. NOT_READY while that frame's art has not loaded, before which the client does not listen for the click.
Parameters
| Name | Type | |
|---|---|---|
slot | 0 | 1 | 2 | 3 | |
options optional | ActOptions |
Returns
Promise<ArtMasterpieceChooser>
Types
close
close(options?: ActOptions) => Promise<void>Closes the chooser, as its X does (onChooseMasterpiecePopupClose).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<ArtMasterpieceChooser | null>The chooser: whether it is up, the frames (empty until Animal Jam sends the list, lists 416 and 424), the page, the frame previewed, the tokens held and the price. Null with no canvas.
Returns
Promise<ArtMasterpieceChooser \| null>
Types
open
open(options?: ActOptions) => Promise<ArtMasterpieceChooser>Opens the chooser, as the studio's masterpiece button does (onCreateMasterpieceBtn), and resolves with it once it is on screen; its art loads the first time. NOT_READY with nothing drawn, REFUSED while one of the studio's questions is up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ArtMasterpieceChooser>
Types
page
page(step: 1 | -1, options?: ActOptions) => Promise<ArtMasterpieceChooser>Turns to the next or the last page of four frames, by pressing the chooser's own arrow (arrowRBtn, arrowLBtn), wrapping round. NOT_READY before the frames have arrived.
Parameters
| Name | Type | |
|---|---|---|
step | 1 | -1 | |
options optional | ActOptions |
Returns
Promise<ArtMasterpieceChooser>
Types
onBought
onBought(listener: (bought: ArtMasterpieceBought) => void) => () => voidHears a masterpiece bought, as the studio's own purchase is answered (onPreviewItemBuy): whether it went through, the diamonds left, and the den item it arrived as.
Parameters
| Name | Type | |
|---|---|---|
listener | (bought: ArtMasterpieceBought) => void |
Returns
() => void. Call it to stop listening.
Types
onChange
onChange(listener: (event: ArtMasterpieceEvent) => void) => () => voidHears the chooser step by step: opened and closed (onChooseMasterpiecePopupLoaded, onChooseMasterpiecePopupClose), the frames laid out (setupMasterpieceWindows, as they arrive and as the page turns), a preview up and down with buying when the player pressed Buy (onPreviewIcon, onPreviewClose), the submission rules answered (onSubmissionRulesClose), and the masterpiece arriving in the den inventory (onPreviewBuyInventoryResponse).
Parameters
| Name | Type | |
|---|---|---|
listener | (event: ArtMasterpieceEvent) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.dialogs
The studios' own dialogs: phantom.aj.artStudio.dialogs. Every studio asks before leaving; the canvas studios ask before clearing and sending, say thank you after sending, and have a storage dialog; the pottery studio asks before printing. While a question is up its buttons do nothing.
await phantom.aj.artStudio.dialogs.ask('clear');
const stop = phantom.aj.artStudio.dialogs.onChange(({ dialog, answer }) => console.log(dialog, answer));answer
answer(answer: "yes" | "no", options?: ActOptions) => Promise<ArtDialogAnswer>Answers the dialog that is up by calling what its own button calls (onExit_Yes, onExit_No, onSubmit_Yes, onClear_Yes, onStorage_Close, onPrint_Yes, onPrint_No), and resolves with the answer given. Yes to submit uploads the picture and yes to exit leaves, as for a player. The thank you's one button is either answer; the storage dialog has only no, its close. NOT_READY with no dialog up; REFUSED for an answer it has not got.
Parameters
| Name | Type | |
|---|---|---|
answer | "yes" | "no" | |
options optional | ActOptions |
Returns
Promise<ArtDialogAnswer>
Types
ask
ask(dialog: "exit" | "submit" | "print" | "clear" | "storage", options?: ActOptions) => Promise<ArtDialog>Puts up one of the studio's dialogs by pressing the button that asks it (onCloseButton, onSubmitButton, onClearAllButton, onStorageButton, the pottery studio's onButtonPrint), for the player to answer, and resolves with it once it is up. Leaving with unsaved work asks save-exit instead of exit. REFUSED when the studio would not ask: another question is up, or there is nothing drawn to send or clear.
Parameters
| Name | Type | |
|---|---|---|
dialog | "exit" | "submit" | "print" | "clear" | "storage" | |
options optional | ActOptions |
Returns
Promise<ArtDialog>
Types
current
current() => Promise<ArtDialog | null>The dialog the open studio shows, or null when none is up (activeDlgMC).
Returns
Promise<ArtDialog \| null>
Types
onChange
onChange(listener: (event: ArtDialogEvent) => void) => () => voidHears the dialogs go up and be answered, by the buttons that ask them and the ones that answer them. A button that asks is told only when the studio acts on it (no other question up, something drawn to send or clear). onExit_No is the no of three dialogs and the OK of the thank you, so an answer is given the dialog last asked in that studio.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: ArtDialogEvent) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.pottery
The pottery studio: phantom.aj.artStudio.pottery. Choose a pot, take it to the colouring stage, print it. Colouring a pot in happens inside the pot's own movie, which the client does not script, so it cannot be painted from here.
browse
browse(step: 1 | -1, options?: ActOptions) => Promise<number>Steps through the designs, as the studio's own arrows do (onButtonLeft, onButtonRight), wrapping round, and resolves with the one now showing once it has loaded.
Parameters
| Name | Type | |
|---|---|---|
step | 1 | -1 | |
options optional | ActOptions |
Returns
Promise<number>
Types
browseTo
browseTo(index: number, options?: ActOptions) => Promise<number>Goes straight to one design, from 0, as stepping there with the arrows would: the index set and the studio's own loadImage run, so everything that follows the arrows follows this. Resolves with it once it has loaded. REFUSED for one the studio has not got.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
colour
colour(options?: ActOptions) => Promise<ArtPot>Takes the pot showing to the colouring stage, as the paint button does (onButtonColor), and resolves once it is there. REFUSED while a pot loads, a question is up, or it already is.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ArtPot>
Types
current
current() => Promise<ArtPot | null>The pot showing, its two movies, and whether it is being coloured; or null.
Returns
Promise<ArtPot \| null>
Types
print
print(options?: ActOptions) => Promise<void>Prints what is showing, at once: the pottery studio's yes to its print question (onPrint_Yes), the print studio's Print (onButtonPrint, which prints once the page has loaded). The computer's print dialog that follows is the player's to answer.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
onBrowse
onBrowse(listener: (browsed: ArtBrowsed) => void) => () => voidHears a design shown once it has loaded (artStudioImageMediaHandler, printMediaHandler).
Parameters
| Name | Type | |
|---|---|---|
listener | (browsed: ArtBrowsed) => void |
Returns
() => void. Call it to stop listening.
Types
onColouring
onColouring(listener: (design: number) => void) => () => voidHears a pot taken to the colouring stage (onButtonColor, when the studio acts on it).
Parameters
| Name | Type | |
|---|---|---|
listener | (design: number) => void |
Returns
() => void. Call it to stop listening.
artStudio.prints
The print studio: phantom.aj.artStudio.prints. Choose a picture and print it. Most offer ten; games 89 and 152 offer one, the second being the refer a friend print with the player's code.
browse
browse(step: 1 | -1, options?: ActOptions) => Promise<number>Steps through the designs, as the studio's own arrows do (onButtonLeft, onButtonRight), wrapping round, and resolves with the one now showing once it has loaded.
Parameters
| Name | Type | |
|---|---|---|
step | 1 | -1 | |
options optional | ActOptions |
Returns
Promise<number>
Types
browseTo
browseTo(index: number, options?: ActOptions) => Promise<number>Goes straight to one design, from 0, as stepping there with the arrows would: the index set and the studio's own loadImage run, so everything that follows the arrows follows this. Resolves with it once it has loaded. REFUSED for one the studio has not got.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
current
current() => Promise<ArtPrintPicture | null>The picture showing, its page and where it is printed on it; or null.
Returns
Promise<ArtPrintPicture \| null>
Types
print
print(options?: ActOptions) => Promise<void>Prints what is showing, at once: the pottery studio's yes to its print question (onPrint_Yes), the print studio's Print (onButtonPrint, which prints once the page has loaded). The computer's print dialog that follows is the player's to answer.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
onBrowse
onBrowse(listener: (browsed: ArtBrowsed) => void) => () => voidHears a design shown once it has loaded (artStudioImageMediaHandler, printMediaHandler).
Parameters
| Name | Type | |
|---|---|---|
listener | (browsed: ArtBrowsed) => void |
Returns
() => void. Call it to stop listening.
Types
artStudio.portraits
The play portrait prints (game.artPrintPlayPortrait.ArtPrintPlayPortrait): phantom.aj.artStudio.portraits. A game of its own beside the studios: a row of finished pictures, three showing at a time, and clicking one prints it. Several rooms have their own set.
await phantom.aj.artStudio.portraits.open();
await phantom.aj.artStudio.portraits.print(0);browse
browse(step: 1 | -1, options?: ActOptions) => Promise<ArtPortraits>Steps the row by one, as the arrows and the arrow keys do, wrapping; resolves with the row.
Parameters
| Name | Type | |
|---|---|---|
step | 1 | -1 | |
options optional | ActOptions |
Returns
Promise<ArtPortraits>
Types
close
close(options?: ActOptions) => Promise<void>Leaves them, as their own X does (onExit); they do not ask first.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<ArtPortraits | null>The pictures on offer, how many have loaded, and the three showing; null when not up.
Returns
Promise<ArtPortraits \| null>
Types
open
open(options?: ActOptions & { gameDefId?: number | undefined; }) => Promise<ArtPortraits>Opens the prints as clicking them in their room does (handleGameClick), and resolves with them once built. gameDefId asks for one room's set; the client's first is asked otherwise. The server has the last word, so a refusal shows as TIMEOUT (30 seconds by default).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions & { gameDefId?: number | undefined; } |
Returns
Promise<ArtPortraits>
Types
print
print(slot: 0 | 1 | 2, options?: ActOptions) => Promise<ArtPortraitPrinted>Prints one of the three showing, 0 to 2 from the left, as clicking it does (onPage0 to onPage2); the computer's print dialog is the player's to answer. NOT_READY for a picture that has not loaded yet, which the client ignores a click on.
Parameters
| Name | Type | |
|---|---|---|
slot | 0 | 1 | 2 | |
options optional | ActOptions |
Returns
Promise<ArtPortraitPrinted>
Types
showFrom
showFrom(first: number, options?: ActOptions) => Promise<ArtPortraits>Shows the row from one picture on, as stepping round to it would: the index set and the row redrawn (updateButtonImages). REFUSED for a picture there is not.
Parameters
| Name | Type | |
|---|---|---|
first | number | |
options optional | ActOptions |
Returns
Promise<ArtPortraits>
Types
onChange
onChange(listener: (portraits: ArtPortraits) => void) => () => voidHears the row change (updateButtonImages): a picture loaded, or the row stepped.
Parameters
| Name | Type | |
|---|---|---|
listener | (portraits: ArtPortraits) => void |
Returns
() => void. Call it to stop listening.
Types
onClose
onClose(listener: () => void) => () => voidHears them close (end).
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onOpen
onOpen(listener: (portraits: ArtPortraits) => void) => () => voidHears them built (sceneLoaded, at exit); the pictures start loading then.
Parameters
| Name | Type | |
|---|---|---|
listener | (portraits: ArtPortraits) => void |
Returns
() => void. Call it to stop listening.
Types
onPrint
onPrint(listener: (printed: ArtPortraitPrinted) => void) => () => voidHears a picture pressed (onPage0 to onPage2), and whether it had loaded and so printed.
Parameters
| Name | Type | |
|---|---|---|
listener | (printed: ArtPortraitPrinted) => void |
Returns
() => void. Call it to stop listening.
Types
Types
The types the calls above take and give, with every field. Import any of them in a plugin from @phantomclient/plugin/sdk, or use them as they are in a script.
ArtCanvasState
A canvas studio as it stands.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
ready | boolean | Whether the room is built (_sceneLoaded): before that almost nothing of it exists. |
width | number | The canvas's size in its own pixels. |
height | number | |
tool | ArtTool | null | The tool chosen now, or null for one the studio numbers and this does not. |
brushSize | number | Which brush width is chosen, 1 to 6 as the interface numbers them. |
brushWidth | number | That brush's width in canvas pixels, or the grid's square. |
cellSize | number | null | The grid studio's square in pixels; null in the painting studio. |
color | number | The colour chosen now, 0xRRGGBB. |
hasDrawn | boolean | Whether anything has been drawn since the last clear: what lights Submit, Print and Clear. |
needsSave | boolean | Whether the studio counts the picture as unsaved work. |
undoable | boolean | Whether the studio's one step of undo would put something back. |
asking | boolean | Whether the studio is waiting on one of its questions, when its buttons do nothing. |
ArtCanvasKind
The two studios with a canvas: the painting studio and the grid drawing studio.
type ArtCanvasKind = 'painting' | 'grid'ArtPotteryState
The pottery studio as it stands.
| Field | Type | |
|---|---|---|
kind | "pottery" | |
ready | boolean | |
design | number | Which pot is showing, from 0, and how many there are. |
designs | number | |
colouring | boolean | Whether the pot is at the colouring stage, where its own movie is painted. |
asking | boolean |
ArtPrintState
The print studio as it stands.
| Field | Type | |
|---|---|---|
kind | "print" | |
ready | boolean | |
picture | number | Which picture is showing, from 0, and how many there are. |
pictures | number | |
loading | boolean | Whether a picture is loading, during which its buttons do nothing. |
asking | boolean |
ArtStudioKind
One of the art studio's rooms.
type ArtStudioKind = 'painting' | 'grid' | 'pottery' | 'print'ArtOpenOptions
What open takes besides the act's own options.
type ArtOpenOptions = ActOptions & {
/** One particular game where a room has its own (the print studios differ by land). */
gameDefId?: number;
}ActOptions
How long something that acts may take, and what may end it first.
| Field | Type | |
|---|---|---|
timeoutMs optional | number | undefined | 10 seconds by default. |
signal optional | AbortSignal | undefined |
ArtStudio
Whichever studio is open, as it stands.
type ArtStudio = ArtCanvasState | ArtPotteryState | ArtPrintStateArtPalette
What a canvas studio offers to paint with.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
brushWidths | number[] | The brush widths in canvas pixels, smallest first: brushSize 1 is the first. |
swatches | number[] | The colours the player has kept in the studio's picker, 0xRRGGBB. |
ArtBrush
The brush of a canvas studio, as it would draw now.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
tool | ArtTool | null | |
size | number | Which brush width is chosen, 1 to 6; always 1 in the grid studio. |
width | number | That width in canvas pixels (_drawSizes), or the grid's square. |
airbrushWidth | number | null | How wide the airbrush sprays at this size; null in the grid studio. |
airbrushOpacity | number | null | How much colour one stamp of the airbrush lays down, 0 to 1; null in the grid studio. |
smudgeRadius | number | null | How far the smudge reaches at this size; null in the grid studio. |
color | number | |
drawing | boolean | Whether a stroke is under way at this moment (_drawing). |
lastTool | ArtTool | null | The tool the last stroke was started with; null before the first. |
ArtTool
A tool, as the studios' interface numbers them (currentTool). The grid drawing studio has two: pencil, which fills one square, and fill.
type ArtTool = | 'brush'
| 'line'
| 'airbrush'
| 'rectangle'
| 'fill'
| 'ellipse'
| 'smudge'
| 'triangle'
| 'pencil'ArtPoint
A point on the canvas, in its own pixels from the top left.
| Field | Type | |
|---|---|---|
x | number | |
y | number |
ArtStrokeOptions
Options for drawing a stroke.
type ArtStrokeOptions = ActOptions & {
/** `brush` (the default) or `airbrush`; the grid studio always draws with its pencil. */
tool?: 'brush' | 'airbrush';
/** `0xRRGGBB`; the studio's own colour when left out. */
color?: number;
/** The brush width, 1 to 6; the studio's own when left out. */
size?: number;
}ArtStroke
A stroke on the canvas.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
tool | ArtTool | null | |
color | number | The colour it was drawn in, 0xRRGGBB. |
brushSize | number | The brush width chosen, 1 to 6. |
by | "player" | "plugin" | Who drew it: the player at the mouse, or the SDK. |
ArtShape
The four outlines the painting studio draws.
type ArtShape = 'line' | 'rectangle' | 'ellipse' | 'triangle'ArtStrokeEnd
A stroke finishing, as the studio's own endDraw starts on it.
type ArtStrokeEnd = Omit<ArtStroke, 'by'> & {
/** Whether it is the first stroke since the canvas was last empty, which lights the buttons. */
first: boolean;
}ArtBrushChange
The tool, brush width or colour of a canvas studio, as onBrushChange hears them.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
tool | ArtTool | null | |
brushSize | number | |
color | number |
ArtUndoChange
The studio's one step of undo changing.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
undoable | boolean | |
undone | boolean | It went from undoable to not: the arrow was pressed, or a picture was loaded. |
ArtFileLoaded
A picture loaded from a file onto the canvas, or failing to.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
ok | boolean | |
messageId | number | null | The localization id of the message the client shows when it fails; null otherwise. |
ArtGrid
The grid drawing studio's grid.
| Field | Type | |
|---|---|---|
cellSize | number | One square's side in canvas pixels (_gridPixelSize). |
columns | number | |
rows | number | |
linesShowing | boolean | Whether its lines are showing, which they do while the mouse is over the canvas. |
view | { scrollX: number; scrollY: number; zoom: number; } | The studio's own pan and zoom of where the pointer lands (_scrollX, _scrollY, _zoomFactor). |
ArtCell
A square of the grid and the colour to fill it.
| Field | Type | |
|---|---|---|
column | number | |
row | number | |
color | number |
ArtPictureInput
A picture as a plugin or script has it: its pixels already read (an ImageData, or anything of that shape), the bytes of a PNG or JPEG file, or a data: URL of one.
type ArtPictureInput = ArtImage | Uint8Array | ArrayBuffer | stringArtImage
A picture's pixels: width * height of them, four bytes each, red, green, blue and alpha.
| Field | Type | |
|---|---|---|
width | number | |
height | number | |
data | ArrayLike<number> |
ArtPlanFor
What plan takes: the paint options, and a canvas to plan for when no studio is open.
type ArtPlanFor = ArtPaintOptions & {
canvas?: { width: number; height: number; cellSize?: number };
}ArtPlanOptions
What a painting is worked out from, beside the picture itself.
| Field | Type | |
|---|---|---|
colors optional | number | undefined | The most colours to paint with, chosen from the picture itself; 32 if left out, between 2 and 256. Fewer colours paint faster, since each one is a pass of its own. |
palette optional | readonly number[] | undefined | The colours to paint with, as 0xRRGGBB, instead of choosing them from the picture. |
dither optional | boolean | undefined | Spread each pixel's rounding error to its neighbours (Floyd and Steinberg), for smoother shading. |
fit optional | ArtFit | undefined | contain (the default) shows all of the picture, cover fills the canvas, stretch both. |
background optional | number | undefined | What shows where the picture is see-through or does not reach: white, as the canvas, if left out. |
ArtPaintingPlan
A painting worked out: which colour goes in each cell, and the runs that draw them.
| Field | Type | |
|---|---|---|
columns | number | Cells across and down: the canvas divided by cellSize. |
rows | number | |
cellSize | number | The side of one cell in canvas pixels: the brush's width, or the grid's square. |
palette | number[] | The colours painted with, as 0xRRGGBB, most used first. |
cells | Uint16Array<ArrayBufferLike> | For each cell, row by row, its colour's place in palette. |
preview | { width: number; height: number; data: Uint8ClampedArray<ArrayBufferLike>; } | The picture as it will come out, one pixel per cell: what a preview shows. |
runs | ArtRun[][] | For each colour in palette, the runs of cells on one row that it paints. |
ArtRun
Cells next to each other on one row, of one colour: one stroke of the brush.
| Field | Type | |
|---|---|---|
row | number | |
from | number | |
to | number |
ArtPaintOptions
type ArtPaintOptions = ArtPlanOptions & {
/**
* The brush width to paint in, 1 to 6; 1, the 2 pixel brush, when left out. A wider brush paints
* in fewer, larger cells and finishes far sooner. The grid studio paints in its own square.
*/
brushSize?: number;
/** `fast` when left out. */
speed?: ArtPaintSpeed;
/**
* Clear the canvas first, as its own Clear does, and leave the cells that are the canvas's white
* unpainted. True when left out; false paints over what is there.
*/
clearFirst?: boolean;
/** Ends the painting, as `stop()` does. */
signal?: AbortSignal;
}ArtPaintRun
A painting under way. Call it (or stop) to end it after the stroke being drawn; what is on the canvas stays, finished as a stroke of the player's own would be.
const run = await phantom.aj.artStudio.painter.paint(png, { colors: 24 });
run.onProgress(({ strokes, totalStrokes }) => console.log(`${strokes}/${totalStrokes}`));
const result = await run.done;type ArtPaintRun = Running<{
readonly plan: ArtPaintStart;
/** Resolves with what was painted, however it ended (stopped too). Never rejects. */
readonly done: Promise<ArtPaintResult>;
/** How far it has got now. */
progress(): ArtPaintProgress;
/** Hears each batch of strokes drawn. */
onProgress(listener: (progress: ArtPaintProgress) => void): () => void;
}>ArtPaintStart
What a painting is going to be, as it starts.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
columns | number | |
rows | number | |
cellSize | number | |
colors | number | |
totalStrokes | number |
ArtPaintResult
What a painting came to, once it ended.
type ArtPaintResult = ArtPaintProgress & {
/** Every stroke was drawn, rather than stopped or interrupted. */
completed: boolean;
/** `stopped` by `stop()` or the signal; `failed` when the game would not draw (`error` says why). */
outcome: 'completed' | 'stopped' | 'failed';
error: string | null;
}ArtPaintProgress
How far a painting has got.
| Field | Type | |
|---|---|---|
color | number | How many of the picture's colours have been started, and how many it is painted in. |
colors | number | |
strokes | number | Strokes drawn so far, of the strokes the picture takes. |
totalStrokes | number |
ArtSubmissions
How many pictures the player has sent to Animal Jam from this computer.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
available | boolean | Whether the studio could open its saved settings; without them it sends nothing. |
sent | number[] | When each of the last five was sent, in ms since 1970, oldest first. |
limit | number | |
left | number | How many more it would send now. |
nextAt | number | null | When the next may go; null when one may go now. |
sinceClear | number | Seconds since the canvas was last cleared, which the client sends with the picture. |
ArtSubmitResult
What became of a picture the studio packed up.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
target | ArtSubmitTarget | |
outcome | "limit" | "sent" | "refused" | "failed" | "unavailable" | sent: Animal Jam took it. failed: the upload failed. refused: Animal Jam refused the account (an HTTP 403). limit: five were sent within a day, so the client sent nothing. unavailable: the studio has no saved settings to count in, so the client sent nothing. |
masterpieceId | string | null | The masterpiece's id, when one was uploaded; null otherwise. |
nextAt | number | null | For limit: when the next may go, in ms since 1970. |
ArtSubmitTarget
Where a picture is going: Animal Jam's own art submission, or a masterpiece for the den.
type ArtSubmitTarget = 'animal-jam' | 'masterpiece'ArtSubmitStart
A picture starting on its way, as the studio packs it up (encodeImage).
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
target | ArtSubmitTarget |
ArtMasterpieceChooser
The masterpiece chooser of a canvas studio.
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
open | boolean | |
frames | number[] | Every frame on offer, by media id, in the order shown; empty until the list arrives. |
frameNames | number[] | Each frame's name, as a localization id, in the same order. |
page | number | The page of four showing, from 0, and how many there are. |
pages | number | |
chosen | number | null | The place in frames of the frame being previewed; null for none. |
version | number | null | The den item version that frame is bought as; null with chosen. |
previewing | boolean | |
rulesShowing | boolean | Whether the submission rules, with the choice of diamonds or a token, are up. |
tokens | number | Masterpiece tokens in the player's den inventory. |
price | number | null | What a masterpiece costs in diamonds; null before the diamond shop has arrived. |
masterpieceId | string | null | The id Animal Jam gave the uploaded picture; null until one is uploaded. |
ArtMasterpieceEvent
One step of the masterpiece chooser, as masterpiece.onChange hears it.
type ArtMasterpieceEvent = | { kind: ArtCanvasKind; type: 'opened' | 'closed' | 'received' }
| { kind: ArtCanvasKind; type: 'frames'; frames: number[]; page: number; tokens: number }
| {
kind: ArtCanvasKind;
type: 'preview';
open: boolean;
/** The place in the chooser's frames of the one previewed. */
frame: number;
version: number;
/** On closing: the player pressed Buy, which starts the upload. */
buying: boolean;
}
| { kind: ArtCanvasKind; type: 'rules'; accepted: boolean; usingTokens: boolean }ArtMasterpieceBought
A masterpiece bought, as the studio's own purchase answers (onPreviewItemBuy).
| Field | Type | |
|---|---|---|
kind | ArtCanvasKind | |
ok | boolean | |
diamonds | number | The diamonds left, as the server counts them. |
denItemInvId | number | The den item it arrived as. |
ArtDialog
The dialog an open studio is showing.
| Field | Type | |
|---|---|---|
kind | ArtStudioKind | |
name | ArtDialogName | null | Which, or null for one this does not name. |
movie | string | Its movie, as the client asks for it (ArtStudioColor_SubmitDlg). |
asking | boolean | Whether it is one of the questions (_exitConfirmationActive) that stop the buttons. |
ArtDialogAnswer
How a dialog was answered.
type ArtDialogAnswer = 'yes' | 'no' | 'ok' | 'save' | 'load' | 'close'ArtDialogEvent
A dialog going up or being answered.
| Field | Type | |
|---|---|---|
kind | ArtStudioKind | |
dialog | ArtDialogName | |
event | "answered" | "asked" | |
answer | ArtDialogAnswer | null |
ArtDialogName
One of the studios' own dialogs.
type ArtDialogName = 'exit' | 'save-exit' | 'submit' | 'clear' | 'storage' | 'submitted' | 'print'ArtPot
The pottery studio's pot.
| Field | Type | |
|---|---|---|
design | number | |
designs | number | |
imageId | number | The media id of the pot as it is coloured (_imageIDs). |
previewId | number | The media id of the pot as it is shown while choosing (_previewIDs). |
colouring | boolean | |
loading | boolean |
ArtBrowsed
A pot or a print shown, once it has loaded.
| Field | Type | |
|---|---|---|
kind | "pottery" | "print" | |
index | number | |
count | number |
ArtPrintPicture
The print studio's picture.
| Field | Type | |
|---|---|---|
picture | number | |
pictures | number | |
imageId | number | The media id of the picture on screen (_imageIDs). |
printId | number | The media id of the page printed for it (_printIDs). |
offset | { x: number; y: number; } | Where on the page it is printed (_printOffsets). |
loading | boolean | |
forCode | boolean | The refer a friend print, with the player's own code written on it (_isForCode). |
ArtPortraits
The play portrait prints.
| Field | Type | |
|---|---|---|
ready | boolean | |
pictures | number[] | Every picture on offer, by media id. |
loaded | number | How many have loaded; a picture cannot be printed before it has. |
showing | [number, number, number] | The three showing, left to right, as places in pictures. |
ArtPortraitPrinted
One of the play portraits pressed.
| Field | Type | |
|---|---|---|
slot | number | Which of the three, 0 to 2 from the left. |
picture | number | Its place in pictures. |
printed | boolean | Whether it had loaded, so that it printed. |