소스 검색

copypast setRgb fixed

vladislavaSim 1 년 전
부모
커밋
048f5b420e
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      tuner/index.js

+ 4 - 4
tuner/index.js

@@ -68,10 +68,10 @@ function setRGB(value, n){
 }
 
 const red  = new Control(container2, {min: 0, max: 255})
-red.onchange = (value) => setRGB(value,0)
 const green  = new Control(container2, {min: 0, max: 255})
-green.onchange = (value) => setRGB(value,1)
 const blue  = new Control(container2, {min: 0, max: 255})
-blue.onchange = (value) => setRGB(value,2)
-
+const colors = [red, green, blue];
+for(let i = 0; i < colors.length; i++) {
+    colors[i].onchange = value => setRGB(value, i)
+}