MCPcopy
hub / github.com/dataarts/dat.gui / updateDisplay

Method updateDisplay

src/dat/controllers/ColorController.js:269–320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

267 }
268
269 updateDisplay() {
270 const i = interpret(this.getValue());
271
272 if (i !== false) {
273 let mismatch = false;
274
275 // Check for mismatch on the interpreted value.
276
277 common.each(Color.COMPONENTS, function(component) {
278 if (!common.isUndefined(i[component]) && !common.isUndefined(this.__color.__state[component]) &&
279 i[component] !== this.__color.__state[component]) {
280 mismatch = true;
281 return {}; // break
282 }
283 }, this);
284
285 // If nothing diverges, we keep our previous values
286 // for statefulness, otherwise we recalculate fresh
287 if (mismatch) {
288 common.extend(this.__color.__state, i);
289 }
290 }
291
292 common.extend(this.__temp.__state, this.__color.__state);
293
294 this.__temp.a = 1;
295
296 const flip = (this.__color.v < 0.5 || this.__color.s > 0.5) ? 255 : 0;
297 const _flip = 255 - flip;
298
299 common.extend(this.__field_knob.style, {
300 marginLeft: 100 * this.__color.s - 7 + 'px',
301 marginTop: 100 * (1 - this.__color.v) - 7 + 'px',
302 backgroundColor: this.__temp.toHexString(),
303 border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip + ')'
304 });
305
306 this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px';
307
308 this.__temp.s = 1;
309 this.__temp.v = 1;
310
311 linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toHexString());
312
313 this.__input.value = this.__color.toString();
314
315 common.extend(this.__input.style, {
316 backgroundColor: this.__color.toHexString(),
317 color: 'rgb(' + flip + ',' + flip + ',' + flip + ')',
318 textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip + ',.7)'
319 });
320 }
321}
322
323const vendors = ['-moz-', '-o-', '-webkit-', '-ms-', ''];

Callers 1

constructorMethod · 0.95

Calls 5

interpretFunction · 0.85
linearGradientFunction · 0.85
getValueMethod · 0.80
toHexStringMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected