1681-engine / index / PixelGrid
Class: PixelGrid ​
Defined in: src/core/PixelGrid.ts:14
A pixel-perfect world (Stage.pixelPerfect): the world layer is taken off the stage and drawn each frame into a texture of one texel per world pixel (Stage.pixelDensity texels, when the art is finer), whose origin sits on a whole world pixel, then shown at the camera's zoom and moved by the scroll's fraction, so the camera still glides one backing pixel at a time. Everything turned, scaled or placed between pixels lands on the same grid as the rest of the art, so no pixel on screen is drawn at another size ("mixels"); the world is also filled at 1/zoom² of the screen's pixels. Roots placed with Camera.snapRoot land on whole world pixels meanwhile, and text stays at screen resolution (SharpText).
Constructors ​
Constructor ​
new PixelGrid(app, world): PixelGrid;Defined in: src/core/PixelGrid.ts:21
Parameters ​
| Parameter | Type |
|---|---|
app | Application |
world | Container |
Returns ​
PixelGrid
Properties ​
text ​
readonly text: SharpText;Defined in: src/core/PixelGrid.ts:17
Accessors ​
enabled ​
Get Signature ​
get enabled(): boolean;Defined in: src/core/PixelGrid.ts:28
Returns ​
boolean
Methods ​
destroy() ​
destroy(cam): void;Defined in: src/core/PixelGrid.ts:52
Parameters ​
| Parameter | Type |
|---|---|
cam | Camera |
Returns ​
void
render() ​
render(
cam,
enabled,
density?
): void;Defined in: src/core/PixelGrid.ts:33
Once a frame, after the camera wrote the world's transform and before Pixi draws the screen.
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
cam | Camera | undefined |
enabled | boolean | undefined |
density | number | 1 |
Returns ​
void