]>
git.r.bdr.sh - rbdr/sumo/blob - lib/factories/pixi.js
839e59315620949541cf3b2f502469349d4bbd44
1 import { Graphics
} from 'pixi.js';
4 * Factory object that contains many methods to create prefab pixi
13 * Creates a sumo container
15 * @function createSumo
16 * @memberof PixiFactory
17 * @return {external:CreateJs.Container} the created container
21 const radius
= config
.radius
;
24 const body
= new Graphics();
25 body
.beginFill(0x87c5ea)
26 .drawCircle(0, 0, radius
)
30 const mouth
= new Graphics();
31 mouth
.lineStyle(10, 0xff0080, 1)
39 const leftEye
= new Graphics();
40 leftEye
.beginFill(0xffffff)
41 .drawCircle(-radius
/ 3 - radius
/ 8, -radius
/ 4, radius
/ 5)
44 const rightEye
= new Graphics();
45 rightEye
.beginFill(0xffffff)
46 .drawCircle(radius
/ 3 + radius
/ 8, -radius
/ 4, radius
/ 5);
48 const leftPupil
= new Graphics();
49 leftPupil
.beginFill(0x11)
50 .drawCircle(-radius
/ 3 - radius
/ 8, -radius
/ 4, radius
/ 10);
52 const rightPupil
= new Graphics();
53 leftPupil
.beginFill(0x11)
54 .drawCircle(radius
/ 3 + radius
/ 8, -radius
/ 4, radius
/ 10);
58 body
.addChild(leftEye
);
59 body
.addChild(rightEye
);
60 body
.addChild(leftPupil
);
61 body
.addChild(rightPupil
);
67 * Creates an empty graphic
69 * @function createEmptyGraphic
70 * @memberof PixiFactory
71 * @return {external:CreateJs.Container} the created container
73 createEmptyGraphic(config
) {
75 return new Graphics();
79 * Creates a harness graphic
81 * @function createHarness
82 * @memberof PixiFactory
83 * @return {external:CreateJs.Container} the created container
85 createHarness(config
) {
87 const radius
= config
.radius
;
89 const lineThickness
= 10;
92 const body
= new Graphics();
93 body
.lineStyle(lineThickness
, 0xe1e1e1, 1)
94 .drawCircle(0, 0, radius
);
96 const center
= new Graphics();
97 center
.beginFill(0xf1f1f1)
98 .drawCircle(0, 0, radius
- lineThickness
/ 2)
101 body
.addChild(center
);