Skip to content

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 ​

ts
new PixelGrid(app, world): PixelGrid;

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

Parameters ​

ParameterType
appApplication
worldContainer

Returns ​

PixelGrid

Properties ​

text ​

ts
readonly text: SharpText;

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

Accessors ​

enabled ​

Get Signature ​

ts
get enabled(): boolean;

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

Returns ​

boolean

Methods ​

destroy() ​

ts
destroy(cam): void;

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

Parameters ​

ParameterType
camCamera

Returns ​

void


render() ​

ts
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 ​

ParameterTypeDefault value
camCameraundefined
enabledbooleanundefined
densitynumber1

Returns ​

void

Released under the MIT License.