Skip to content

1681-engine / index / Graphics

Class: Graphics ​

Defined in: src/core/Graphics.ts:13

Immediate-mode vector drawing with a current fill and line style (fillStyle + fillRect), on top of Pixi's shape-then-fill Graphics. Wrapped rather than subclassed: Pixi's Graphics owns fillStyle as a property.

Extends ​

  • Container<ContainerChild, this> & GameObjectMembers<this>

Extended by ​

Constructors ​

Constructor ​

ts
new Graphics(): Graphics;

Defined in: src/core/Graphics.ts:18

Returns ​

Graphics

Overrides ​

ts
GameObject(Container).constructor

Properties ​

active ​

ts
readonly active: boolean;

Defined in: src/core/gameObject.ts:42

False once destroyed.

Inherited from ​

ts
GameObject(Container).active

depth ​

ts
depth: number;

Defined in: src/core/gameObject.ts:44

The draw order in the world layer (zIndex): bigger is in front.

Inherited from ​

ts
GameObject(Container).depth

flipX ​

ts
flipX: boolean;

Defined in: src/core/gameObject.ts:48

Inherited from ​

ts
GameObject(Container).flipX

flipY ​

ts
flipY: boolean;

Defined in: src/core/gameObject.ts:49

Inherited from ​

ts
GameObject(Container).flipY

scaleX ​

ts
scaleX: number;

Defined in: src/core/gameObject.ts:46

Scale without the flip: stays positive on a mirrored sprite.

Inherited from ​

ts
GameObject(Container).scaleX

scaleY ​

ts
scaleY: number;

Defined in: src/core/gameObject.ts:47

Inherited from ​

ts
GameObject(Container).scaleY

scene ​

ts
scene: Stage;

Defined in: src/core/gameObject.ts:40

Inherited from ​

ts
GameObject(Container).scene

Methods ​

beginPath() ​

ts
beginPath(): this;

Defined in: src/core/Graphics.ts:84

Returns ​

this


clear() ​

ts
clear(): this;

Defined in: src/core/Graphics.ts:33

Returns ​

this


clearTint() ​

ts
clearTint(): this;

Defined in: src/core/gameObject.ts:64

Returns ​

this

Inherited from ​

ts
GameObject(Container).clearTint

closePath() ​

ts
closePath(): this;

Defined in: src/core/Graphics.ts:99

Returns ​

this


destroy() ​

Call Signature ​

ts
destroy(options?): void;

Defined in: node_modules/pixi.js/lib/scene/container/Container.d.ts:1343

Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.

Parameters ​
ParameterTypeDescription
options?DestroyOptionsOptions parameter. A boolean will act as if all options have been set to that value
Returns ​

void

Example ​
ts
container.destroy();
container.destroy(true);
container.destroy({ children: true });
container.destroy({ children: true, texture: true, textureSource: true });
Inherited from ​
ts
GameObject(Container).destroy

Call Signature ​

ts
destroy(): void;

Defined in: src/core/gameObject.ts:67

Returns ​

void

Inherited from ​
ts
GameObject(Container).destroy

fillCircle() ​

ts
fillCircle(
   x, 
   y, 
   r
): this;

Defined in: src/core/Graphics.ts:53

Parameters ​

ParameterType
xnumber
ynumber
rnumber

Returns ​

this


fillEllipse() ​

ts
fillEllipse(
   x, 
   y, 
   w, 
   h
): this;

Defined in: src/core/Graphics.ts:43

Parameters ​

ParameterType
xnumber
ynumber
wnumber
hnumber

Returns ​

this


fillPath() ​

ts
fillPath(): this;

Defined in: src/core/Graphics.ts:104

Returns ​

this


fillPoints() ​

ts
fillPoints(points, _closeShape?): this;

Defined in: src/core/Graphics.ts:68

Parameters ​

ParameterTypeDefault value
pointsVec2[]undefined
_closeShapebooleantrue

Returns ​

this


fillRect() ​

ts
fillRect(
   x, 
   y, 
   w, 
   h
): this;

Defined in: src/core/Graphics.ts:38

Parameters ​

ParameterType
xnumber
ynumber
wnumber
hnumber

Returns ​

this


fillStyle() ​

ts
fillStyle(color, alpha?): this;

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

Parameters ​

ParameterTypeDefault value
colornumberundefined
alphanumber1

Returns ​

this


lineBetween() ​

ts
lineBetween(
   x1, 
   y1, 
   x2, 
   y2
): this;

Defined in: src/core/Graphics.ts:63

Parameters ​

ParameterType
x1number
y1number
x2number
y2number

Returns ​

this


lineStyle() ​

ts
lineStyle(
   width, 
   color, 
   alpha?
): this;

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

Parameters ​

ParameterTypeDefault value
widthnumberundefined
colornumberundefined
alphanumber1

Returns ​

this


lineTo() ​

ts
lineTo(x, y): this;

Defined in: src/core/Graphics.ts:94

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

this


moveTo() ​

ts
moveTo(x, y): this;

Defined in: src/core/Graphics.ts:89

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

this


setAlpha() ​

ts
setAlpha(a?): this;

Defined in: src/core/gameObject.ts:55

Parameters ​

ParameterType
a?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setAlpha

setAngle() ​

ts
setAngle(a?): this;

Defined in: src/core/gameObject.ts:59

Parameters ​

ParameterType
a?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setAngle

setBlendMode() ​

ts
setBlendMode(mode): this;

Defined in: src/core/gameObject.ts:60

Parameters ​

ParameterType
modeBLEND_MODES

Returns ​

this

Inherited from ​

ts
GameObject(Container).setBlendMode

setDepth() ​

ts
setDepth(d): this;

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

Parameters ​

ParameterType
dnumber

Returns ​

this

Inherited from ​

ts
GameObject(Container).setDepth

setFlip() ​

ts
setFlip(x, y): this;

Defined in: src/core/gameObject.ts:53

Parameters ​

ParameterType
xboolean
yboolean

Returns ​

this

Inherited from ​

ts
GameObject(Container).setFlip

setFlipX() ​

ts
setFlipX(v): this;

Defined in: src/core/gameObject.ts:51

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(Container).setFlipX

setFlipY() ​

ts
setFlipY(v): this;

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

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(Container).setFlipY

setPosition() ​

ts
setPosition(x?, y?): this;

Defined in: src/core/gameObject.ts:57

Parameters ​

ParameterType
x?number
y?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setPosition

setRotation() ​

ts
setRotation(r?): this;

Defined in: src/core/gameObject.ts:58

Parameters ​

ParameterType
r?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setRotation

setScale() ​

ts
setScale(x, y?): this;

Defined in: src/core/gameObject.ts:50

Parameters ​

ParameterType
xnumber
y?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setScale

setScrollFactor() ​

ts
setScrollFactor(f): this;

Defined in: src/core/gameObject.ts:66

0 pins the object to the screen instead of the world.

Parameters ​

ParameterType
fnumber

Returns ​

this

Inherited from ​

ts
GameObject(Container).setScrollFactor

setTint() ​

ts
setTint(color?): this;

Defined in: src/core/gameObject.ts:61

Parameters ​

ParameterType
color?number

Returns ​

this

Inherited from ​

ts
GameObject(Container).setTint

setTintFill() ​

ts
setTintFill(color): this;

Defined in: src/core/gameObject.ts:63

Paints every opaque pixel in one solid colour (hit flash, silhouettes).

Parameters ​

ParameterType
colornumber

Returns ​

this

Inherited from ​

ts
GameObject(Container).setTintFill

setVisible() ​

ts
setVisible(v): this;

Defined in: src/core/gameObject.ts:56

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(Container).setVisible

slice() ​

ts
slice(
   x, 
   y, 
   r, 
   start, 
   end, 
   anticlockwise?
): this;

Defined in: src/core/Graphics.ts:79

A pie slice from the centre, for cone telegraphs.

Parameters ​

ParameterTypeDefault value
xnumberundefined
ynumberundefined
rnumberundefined
startnumberundefined
endnumberundefined
anticlockwisebooleanfalse

Returns ​

this


strokeCircle() ​

ts
strokeCircle(
   x, 
   y, 
   r
): this;

Defined in: src/core/Graphics.ts:58

Parameters ​

ParameterType
xnumber
ynumber
rnumber

Returns ​

this


strokeEllipse() ​

ts
strokeEllipse(
   x, 
   y, 
   w, 
   h
): this;

Defined in: src/core/Graphics.ts:48

Parameters ​

ParameterType
xnumber
ynumber
wnumber
hnumber

Returns ​

this


strokePath() ​

ts
strokePath(): this;

Defined in: src/core/Graphics.ts:109

Returns ​

this


strokePoints() ​

ts
strokePoints(points, closeShape?): this;

Defined in: src/core/Graphics.ts:73

Parameters ​

ParameterTypeDefault value
pointsVec2[]undefined
closeShapebooleanfalse

Returns ​

this

Released under the MIT License.