Skip to content

1681-engine / index / PixelGrid

Class: PixelGrid ​

Defined in: src/core/PixelGrid.ts:16

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. The camera scrolls by whole world pixels meanwhile (Camera.apply), the grid the roots are snapped to: it glided a backing pixel at a time until 0.6.8, and the followed body, snapped to world pixels under it, jittered and read as blurred. 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 ​

ts
new PixelGrid(app, world): PixelGrid;

Defined in: src/core/PixelGrid.ts:23

Parameters ​

ParameterType
appApplication
worldContainer

Returns ​

PixelGrid

Properties ​

text ​

ts
readonly text: SharpText;

Defined in: src/core/PixelGrid.ts:19

Accessors ​

enabled ​

Get Signature ​

ts
get enabled(): boolean;

Defined in: src/core/PixelGrid.ts:30

Returns ​

boolean

Methods ​

destroy() ​

ts
destroy(cam): void;

Defined in: src/core/PixelGrid.ts:54

Parameters ​

ParameterType
camCamera

Returns ​

void


render() ​

ts
render(
   cam, 
   enabled, 
   density?
): void;

Defined in: src/core/PixelGrid.ts:35

Once a frame, after the camera wrote the world's transform and before Pixi draws the screen.

Parameters ​

ParameterTypeDefault value
camCameraundefined
enabledbooleanundefined
densitynumber1

Returns ​

void

Released under the MIT License.