MCPcopy Create free account
hub / github.com/melonjs/melonJS / onResetEvent

Method onResetEvent

packages/melonjs/src/renderable/text/text.js:118–192  ·  view source on GitHub ↗

@ignore

(x, y, settings)

Source from the content-addressed store, hash-verified

116
117 /** @ignore */
118 onResetEvent(x, y, settings) {
119 if (typeof this.fillStyle === "undefined") {
120 this.fillStyle = colorPool.get(0, 0, 0);
121 }
122
123 if (typeof this.strokeStyle === "undefined") {
124 this.strokeStyle = colorPool.get(0, 0, 0);
125 }
126
127 if (typeof settings.fillStyle !== "undefined") {
128 if (settings.fillStyle instanceof Color) {
129 this.fillStyle.copy(settings.fillStyle);
130 } else {
131 // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
132 this.fillStyle.parseCSS(settings.fillStyle);
133 }
134 }
135
136 if (typeof settings.strokeStyle !== "undefined") {
137 if (settings.strokeStyle instanceof Color) {
138 this.strokeStyle.copy(settings.strokeStyle);
139 } else {
140 // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
141 this.strokeStyle.parseCSS(settings.strokeStyle);
142 }
143 }
144
145 this.lineWidth = settings.lineWidth || 0;
146 this.textAlign = settings.textAlign || "left";
147 this.textBaseline = settings.textBaseline || "top";
148 this.lineHeight = settings.lineHeight || 1.0;
149 this.wordWrapWidth = settings.wordWrapWidth || -1;
150 this.fontSize = 10;
151
152 // anchor point
153 if (typeof settings.anchorPoint !== "undefined") {
154 this.anchorPoint.set(settings.anchorPoint.x, settings.anchorPoint.y);
155 } else {
156 this.anchorPoint.set(0, 0);
157 }
158
159 // if floating was specified through settings
160 if (typeof settings.floating !== "undefined") {
161 this.floating = !!settings.floating;
162 }
163
164 // font name and type
165 this.setFont(settings.font, settings.size);
166
167 // additional font styles
168 if (settings.bold === true) {
169 this.bold();
170 }
171 if (settings.italic === true) {
172 this.italic();
173 }
174
175 // the canvas Texture used to render this text

Callers 1

constructorMethod · 0.95

Calls 8

setFontMethod · 0.95
boldMethod · 0.95
italicMethod · 0.95
setTextMethod · 0.95
parseCSSMethod · 0.80
getMethod · 0.65
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected