質問編集履歴
5
rgb の const を let に修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
const ctx = document.getElementById("canvas").getContext("2d");
|
6
6
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
7
7
|
const splText = String(dataText).split(",");
|
8
|
-
|
8
|
+
let rgb = 0;
|
9
9
|
for (let i = 0; i < 6; i++) {
|
10
10
|
for (let j = 0; j < 6; j++) {
|
11
11
|
const r = splText [rgb];
|
@@ -36,7 +36,7 @@
|
|
36
36
|
const ctx = document.getElementById("canvas").getContext("2d");
|
37
37
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
38
38
|
const splText = String(dataText).split(",");
|
39
|
-
|
39
|
+
let rgb = 0;
|
40
40
|
for (let i = 0; i < 6; i++) {
|
41
41
|
for (let j = 0; j < 6; j++) {
|
42
42
|
const r = splText [rgb];
|
4
rgb1をrgbに修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -39,9 +39,9 @@
|
|
39
39
|
const rgb = 0;
|
40
40
|
for (let i = 0; i < 6; i++) {
|
41
41
|
for (let j = 0; j < 6; j++) {
|
42
|
-
const r = splText [rgb
|
42
|
+
const r = splText [rgb];
|
43
|
-
const g = splText [(rgb
|
43
|
+
const g = splText [(rgb + 1)];
|
44
|
-
const b = splText [(rgb
|
44
|
+
const b = splText [(rgb + 2)];
|
45
45
|
ctx.beginPath();
|
46
46
|
ctx.fillStyle = "rgb(" + Number(r) + "," + Number(g) + "," + Number(b) + ")";
|
47
47
|
ctx.fillRect(j * 1, i * 1, 1, 1);
|
3
重ね重ね申し訳ありません。 追記部分の修正をしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -49,8 +49,8 @@
|
|
49
49
|
|
50
50
|
//追記部分
|
51
51
|
window.alert(Number(r) + "," + Number(g) + "," + Number(b));
|
52
|
-
c
|
52
|
+
ctx.beginPath();
|
53
|
-
const dataTest1 = c
|
53
|
+
const dataTest1 = ctx.getImageData(j * 1, i * 1, 1, 1);
|
54
54
|
const dataTest2 = dataTest1.data;
|
55
55
|
const dataTest3 = String(dataTest2).split(",", 3);
|
56
56
|
window.alert(dataTest3);
|
2
splText 追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
|
5
5
|
const ctx = document.getElementById("canvas").getContext("2d");
|
6
6
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
7
|
+
const splText = String(dataText).split(",");
|
7
8
|
const rgb = 0;
|
8
9
|
for (let i = 0; i < 6; i++) {
|
9
10
|
for (let j = 0; j < 6; j++) {
|
10
|
-
const r =
|
11
|
+
const r = splText [rgb];
|
11
|
-
const g =
|
12
|
+
const g = splText [(rgb + 1)];
|
12
|
-
const b =
|
13
|
+
const b = splText [(rgb + 2)];
|
13
14
|
ctx.beginPath();
|
14
15
|
ctx.fillStyle = "rgb(" + Number(r) + "," + Number(g) + "," + Number(b) + ")";
|
15
16
|
ctx.fillRect(j * 1, i * 1, 1, 1);
|
@@ -34,12 +35,13 @@
|
|
34
35
|
```
|
35
36
|
const ctx = document.getElementById("canvas").getContext("2d");
|
36
37
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
38
|
+
const splText = String(dataText).split(",");
|
37
39
|
const rgb = 0;
|
38
40
|
for (let i = 0; i < 6; i++) {
|
39
41
|
for (let j = 0; j < 6; j++) {
|
40
|
-
const r =
|
42
|
+
const r = splText [rgb1];
|
41
|
-
const g =
|
43
|
+
const g = splText [(rgb1 + 1)];
|
42
|
-
const b =
|
44
|
+
const b = splText [(rgb1 + 2)];
|
43
45
|
ctx.beginPath();
|
44
46
|
ctx.fillStyle = "rgb(" + Number(r) + "," + Number(g) + "," + Number(b) + ")";
|
45
47
|
ctx.fillRect(j * 1, i * 1, 1, 1);
|
1
const rgb が抜けていました。 申し訳ありません。
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,15 +4,17 @@
|
|
4
4
|
|
5
5
|
const ctx = document.getElementById("canvas").getContext("2d");
|
6
6
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
7
|
+
const rgb = 0;
|
7
8
|
for (let i = 0; i < 6; i++) {
|
8
9
|
for (let j = 0; j < 6; j++) {
|
9
|
-
const r = dataText[rgb
|
10
|
+
const r = dataText[rgb];
|
10
|
-
const g = dataText[(rgb
|
11
|
+
const g = dataText[(rgb + 1)];
|
11
|
-
const b = dataText[(rgb
|
12
|
+
const b = dataText[(rgb + 2)];
|
12
13
|
ctx.beginPath();
|
13
14
|
ctx.fillStyle = "rgb(" + Number(r) + "," + Number(g) + "," + Number(b) + ")";
|
14
15
|
ctx.fillRect(j * 1, i * 1, 1, 1);
|
15
16
|
ctx.stroke();
|
17
|
+
rgb = rgb + 3;
|
16
18
|
}
|
17
19
|
}
|
18
20
|
|
@@ -32,6 +34,7 @@
|
|
32
34
|
```
|
33
35
|
const ctx = document.getElementById("canvas").getContext("2d");
|
34
36
|
dataText = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18"
|
37
|
+
const rgb = 0;
|
35
38
|
for (let i = 0; i < 6; i++) {
|
36
39
|
for (let j = 0; j < 6; j++) {
|
37
40
|
const r = dataText[rgb1];
|
@@ -49,6 +52,9 @@
|
|
49
52
|
const dataTest2 = dataTest1.data;
|
50
53
|
const dataTest3 = String(dataTest2).split(",", 3);
|
51
54
|
window.alert(dataTest3);
|
55
|
+
//
|
56
|
+
|
57
|
+
rgb = rgb + 3;
|
52
58
|
}
|
53
59
|
}
|
54
60
|
```
|