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

Method setSV

src/dat/controllers/ColorController.js:219–246  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

217 this.updateDisplay();
218
219 function setSV(e) {
220 if (e.type.indexOf('touch') === -1) { e.preventDefault(); }
221
222 const fieldRect = _this.__saturation_field.getBoundingClientRect();
223 const { clientX, clientY } = (e.touches && e.touches[0]) || e;
224 let s = (clientX - fieldRect.left) / (fieldRect.right - fieldRect.left);
225 let v = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);
226
227 if (v > 1) {
228 v = 1;
229 } else if (v < 0) {
230 v = 0;
231 }
232
233 if (s > 1) {
234 s = 1;
235 } else if (s < 0) {
236 s = 0;
237 }
238
239 _this.__color.v = v;
240 _this.__color.s = s;
241
242 _this.setValue(_this.__color.toOriginal());
243
244
245 return false;
246 }
247
248 function setH(e) {
249 if (e.type.indexOf('touch') === -1) { e.preventDefault(); }

Callers

nothing calls this directly

Calls 2

toOriginalMethod · 0.80
setValueMethod · 0.45

Tested by

no test coverage detected