MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / setColor

Method setColor

data/src/emulator.js:328–353  ·  view source on GitHub ↗
(color)

Source from the content-addressed store, hash-verified

326 this.handleResize();
327 }
328 setColor(color) {
329 if (typeof color !== "string") color = "";
330 let getColor = function(color) {
331 color = color.toLowerCase();
332 if (color && /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(color)) {
333 if (color.length === 4) {
334 let rv = "#";
335 for (let i = 1; i < 4; i++) {
336 rv += color.slice(i, i + 1) + color.slice(i, i + 1);
337 }
338 color = rv;
339 }
340 let rv = [];
341 for (let i = 1; i < 7; i += 2) {
342 rv.push(parseInt("0x" + color.slice(i, i + 2), 16));
343 }
344 return rv.join(", ");
345 }
346 return null;
347 }
348 if (!color || getColor(color) === null) {
349 this.elements.parent.setAttribute("style", "--ejs-primary-color: 26,175,255;");
350 return;
351 }
352 this.elements.parent.setAttribute("style", "--ejs-primary-color:" + getColor(color) + ";");
353 }
354 setupAds(ads, width, height) {
355 const div = this.createElement("div");
356 const time = (typeof this.config.adMode === "number" && this.config.adMode > -1 && this.config.adMode < 3) ? this.config.adMode : 2;

Callers 1

constructorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected