]>
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
}));
74 body
.addChild(leftEye
);
75 body
.addChild(rightEye
);
76 body
.addChild(leftPupil
);
77 body
.addChild(rightPupil
);
83 * Creates an empty graphic
85 * @function createEmptyGraphic
86 * @memberof PixiFactory
87 * @return {external:CreateJs.Container} the created container
89 createEmptyGraphic(config
) {
91 return new Graphics();
95 * Creates a harness graphic
97 * @function createHarness
98 * @memberof PixiFactory
99 * @return {external:CreateJs.Container} the created container
101 createHarness(config
) {
103 const radius
= config
.radius
;
105 const lineThickness
= 10;
108 const body
= new Graphics();
109 body
.lineStyle(lineThickness
, 0xe1e1e1, 1)
110 .drawCircle(0, 0, radius
);
112 const center
= new Graphics();
113 center
.beginFill(0xf1f1f1)
114 .drawCircle(0, 0, radius
- lineThickness
/ 2)
117 body
.addChild(center
);
123 * Creates an arena graphic
125 * @function createArena
126 * @memberof PixiFactory
127 * @return {external:CreateJs.Container} the created container
129 createArena(config
) {
131 const radius
= config
.radius
;
133 const lineThickness
= 20;
136 const arena
= new Graphics();
137 arena
.lineStyle(lineThickness
, 0xdfd4b2, 1)
138 .drawCircle(0, 0, radius
);
140 const leftLine
= new Graphics();
141 leftLine
.lineStyle(20, 0xbdb08b, 1)
142 .moveTo(-radius
/ 4, -radius
/ 8)
143 .lineTo(-radius
/ 4, radius
/ 8);
145 const rightLine
= new Graphics();
146 rightLine
.lineStyle(20, 0xbdb08b, 1)
147 .moveTo(radius
/ 4, -radius
/ 8)
148 .lineTo(radius
/ 4, radius
/ 8);
150 arena
.addChild(leftLine
);
151 arena
.addChild(rightLine
);
157 * Creates a blush for the face
159 * @function createBlush
160 * @memberof PixiFactory
161 * @return {external:CreateJs.Container} the created container
163 createBlush(config
) {
165 const radius
= config
.radius
;
167 const blush
= new Graphics();
169 blush
.name
= 'blush';
170 blush
.visible
= false;
172 const leftEyebrow
= new Graphics();
173 leftEyebrow
.lineStyle(4, 0x11, 1)
175 -radius
/ 3 - radius
/ 4, -radius
/ 2 - radius
/ 4,
181 const leftBlush
= new Graphics();
182 leftBlush
.lineStyle(4, 0xe7bfe6, 1)
183 .moveTo(-radius
/ 3 - radius
/ 4, radius
/ 10)
184 .lineTo(-radius
/ 3, 0);
186 const rightEyebrow
= new Graphics();
187 rightEyebrow
.lineStyle(4, 0x11, 1)
189 radius
/ 3 + radius
/ 4, -radius
/ 2 - radius
/ 4,
195 const rightBlush
= new Graphics();
196 rightBlush
.lineStyle(4, 0xe7bfe6, 1)
197 .moveTo(radius
/ 3 + radius
/ 4, radius
/ 10)
198 .lineTo(radius
/ 3, 0);
200 blush
.addChild(leftEyebrow
);
201 blush
.addChild(leftBlush
);
202 blush
.addChild(rightEyebrow
);
203 blush
.addChild(rightBlush
);