]>
git.r.bdr.sh - rbdr/sumo/blob - lib/factories/pixi.js
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 smile
= new Graphics();
32 smile
.lineStyle(10, 0xff0080, 1)
40 const frown
= new Graphics();
42 frown
.visible
= false;
43 frown
.lineStyle(10, 0xff0080, 1)
52 const leftEye
= new Graphics();
53 leftEye
.beginFill(0xffffff)
54 .drawCircle(-radius
/ 3 - radius
/ 8, -radius
/ 4, radius
/ 5)
57 const rightEye
= new Graphics();
58 rightEye
.beginFill(0xffffff)
59 .drawCircle(radius
/ 3 + radius
/ 8, -radius
/ 4, radius
/ 5);
61 const leftPupil
= new Graphics();
62 leftPupil
.beginFill(0x11)
63 .drawCircle(-radius
/ 3 - radius
/ 8, -radius
/ 4, radius
/ 10);
65 const rightPupil
= new Graphics();
66 leftPupil
.beginFill(0x11)
67 .drawCircle(radius
/ 3 + radius
/ 8, -radius
/ 4, radius
/ 10);
69 body
.addChild(this.createBlush({ radius
}));
71 body
.addChild(this.createEffortMark({ radius
}));
72 body
.addChild(this.createShadow({ radius
}));
77 body
.addChild(leftEye
);
78 body
.addChild(rightEye
);
79 body
.addChild(leftPupil
);
80 body
.addChild(rightPupil
);
86 * Creates an empty graphic
88 * @function createEmptyGraphic
89 * @memberof PixiFactory
90 * @return {external:CreateJs.Container} the created container
92 createEmptyGraphic(config
) {
94 return new Graphics();
98 * Creates a harness graphic
100 * @function createHarness
101 * @memberof PixiFactory
102 * @return {external:CreateJs.Container} the created container
104 createHarness(config
) {
106 const radius
= config
.radius
;
108 const lineThickness
= 10;
111 const body
= new Graphics();
112 body
.lineStyle(lineThickness
, 0xe1e1e1, 1)
113 .drawCircle(0, 0, radius
);
115 const center
= new Graphics();
116 center
.beginFill(0xf1f1f1)
117 .drawCircle(0, 0, radius
- lineThickness
/ 2)
120 body
.addChild(center
);
126 * Creates an arena graphic
128 * @function createArena
129 * @memberof PixiFactory
130 * @return {external:CreateJs.Container} the created container
132 createArena(config
) {
134 const radius
= config
.radius
;
136 const lineThickness
= 20;
139 const arena
= new Graphics();
140 arena
.lineStyle(lineThickness
, 0xdfd4b2, 1)
141 .drawCircle(0, 0, radius
);
143 const leftLine
= new Graphics();
144 leftLine
.lineStyle(20, 0xbdb08b, 1)
145 .moveTo(-radius
/ 4, -radius
/ 8)
146 .lineTo(-radius
/ 4, radius
/ 8);
148 const rightLine
= new Graphics();
149 rightLine
.lineStyle(20, 0xbdb08b, 1)
150 .moveTo(radius
/ 4, -radius
/ 8)
151 .lineTo(radius
/ 4, radius
/ 8);
153 arena
.addChild(leftLine
);
154 arena
.addChild(rightLine
);
160 * Creates a blush for the face
162 * @function createBlush
163 * @memberof PixiFactory
164 * @return {external:CreateJs.Container} the created container
166 createBlush(config
) {
168 const radius
= config
.radius
;
170 const blush
= new Graphics();
172 blush
.name
= 'blush';
173 blush
.visible
= false;
175 const leftEyebrow
= new Graphics();
176 leftEyebrow
.lineStyle(4, 0x11, 1)
178 -radius
/ 3 - radius
/ 4, -radius
/ 2 - radius
/ 4,
184 const leftBlush
= new Graphics();
185 leftBlush
.lineStyle(4, 0xe7bfe6, 1)
186 .moveTo(-radius
/ 3 - radius
/ 4, radius
/ 10)
187 .lineTo(-radius
/ 3, 0);
189 const rightEyebrow
= new Graphics();
190 rightEyebrow
.lineStyle(4, 0x11, 1)
192 radius
/ 3 + radius
/ 4, -radius
/ 2 - radius
/ 4,
198 const rightBlush
= new Graphics();
199 rightBlush
.lineStyle(4, 0xe7bfe6, 1)
200 .moveTo(radius
/ 3 + radius
/ 4, radius
/ 10)
201 .lineTo(radius
/ 3, 0);
203 blush
.addChild(leftEyebrow
);
204 blush
.addChild(leftBlush
);
205 blush
.addChild(rightEyebrow
);
206 blush
.addChild(rightBlush
);
212 * Creates an effort mark
214 * @function createEffortMark
215 * @memberof PixiFactory
216 * @return {external:CreateJs.Container} the created container
218 createEffortMark(config
) {
220 const radius
= config
.radius
;
222 const effortMark
= new Graphics();
224 const centerX
= -3 * radius
/ 4;
225 const centerY
= -3 * radius
/ 4;
227 effortMark
.name
= 'effort';
228 effortMark
.visible
= false;
230 const color
= 0xff00ff;
233 const topRightArch
= new Graphics();
234 topRightArch
.lineStyle(lineWidth
, color
, 1)
236 centerX
+ 2 * radius
/ 7, centerY
- 2 * radius
/ 7,
242 const topLeftArch
= new Graphics();
243 topLeftArch
.lineStyle(lineWidth
, color
, 1)
245 centerX
- 2 * radius
/ 7, centerY
- radius
/ 4,
251 const bottomRightArch
= new Graphics();
252 bottomRightArch
.lineStyle(lineWidth
, color
, 1)
254 centerX
+ 2 * radius
/ 7, centerY
+ radius
/ 4,
260 const bottomLeftArch
= new Graphics();
261 bottomLeftArch
.lineStyle(lineWidth
, color
, 1)
263 centerX
- 2 * radius
/ 7, centerY
+ 2 * radius
/ 7,
269 effortMark
.addChild(topRightArch
);
270 effortMark
.addChild(topLeftArch
);
271 effortMark
.addChild(bottomRightArch
);
272 effortMark
.addChild(bottomLeftArch
);
278 * Creates a shadow for the eye
280 * @function createShadow
281 * @memberof PixiFactory
282 * @return {external:CreateJs.Container} the created container
284 createShadow(config
) {
286 const radius
= config
.radius
;
288 const shadow
= new Graphics();
290 const centerX
= radius
/ 2;
291 const centerY
= -3 * radius
/ 4;
293 shadow
.name
= 'shadow';
294 shadow
.visible
= false;
296 const color
= 0x9900ff;
299 shadow
.lineStyle(lineWidth
, color
, 1)
300 .moveTo(centerX
- radius
/ 4, centerY
- radius
/ 3)
301 .lineTo(centerX
- radius
/ 4, centerY
+ radius
/ 5)
302 .moveTo(centerX
- radius
/ 8, centerY
- radius
/ 4)
303 .lineTo(centerX
- radius
/ 8, centerY
+ radius
/ 5)
304 .moveTo(centerX
, centerY
- radius
/ 5)
305 .lineTo(centerX
, centerY
+ radius
/ 5)
306 .moveTo(centerX
+ radius
/ 8, centerY
- radius
/ 6)
307 .lineTo(centerX
+ radius
/ 8, centerY
+ radius
/ 6)
308 .moveTo(centerX
+ radius
/ 4, centerY
- radius
/ 5)
309 .lineTo(centerX
+ radius
/ 4, centerY
+ radius
/ 5);