質問編集履歴

1

コードの追加

2018/03/10 11:14

投稿

P5_USER
P5_USER

スコア73

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,97 @@
14
14
 
15
15
  copy(イメージ,[赤枠領域],[表示領域])で出来るはずなのですが......
16
16
 
17
+ ###コード
17
18
 
19
+ spd_number,spd_label_1,spd_label_10,spd_label_100はどれもPGraphics型です。
20
+
21
+ ```processing
22
+
23
+ void move_spd_num_label()
24
+
25
+ {
26
+
27
+ float divisor = spd_label_1.height / 2 - (spd_num_distance / 2) * 3;
28
+
29
+
30
+
31
+ float y_1 = map(kvc, 0, 20, -divisor, divisor);
32
+
33
+ float y_10 = map(floor(kvc / 10), 0, 20, -divisor, divisor);
34
+
35
+ float y_100 = map(floor(kvc / 100), 0, 20, -divisor, divisor);
36
+
37
+
38
+
39
+ if (kvc >= 10)
40
+
41
+ {
42
+
43
+ y_1 = y_1 % divisor;
44
+
45
+ }
46
+
47
+ if (floor(kvc / 10) >= 10)
48
+
49
+ {
50
+
51
+ y_10 = y_10 % divisor;
52
+
53
+ }
54
+
55
+ if (floor(kvc / 100) >= 10)
56
+
57
+ {
58
+
59
+ y_100 = y_100 % divisor;
60
+
61
+ }
62
+
63
+
64
+
65
+ translate(displayWidth/2, displayHeight/2);
66
+
67
+ stroke(0, 255, 0);
68
+
69
+ line(0, 0, displayWidth/2, 0);
70
+
71
+ //imageMode(CENTER);
72
+
73
+ //image(spd_label_1, spd_num_x, y_1 - font_size_large / 2);
74
+
75
+ //image(spd_label_10, -(spd_label_1.width + spd_label_10.width) / 2 + spd_num_x, y_10 - font_size_large /2);
76
+
77
+ //image(spd_label_100, -(spd_label_1.width + spd_label_100.width) / 2 - spd_label_10.width + spd_num_x, y_100 - font_size_large / 2);
78
+
79
+
80
+
81
+ imageMode(CORNER);
82
+
83
+ spd_number = createGraphics(spd_label_1.width + spd_label_10.width + spd_label_100.width, displayHeight / 10);
84
+
85
+ spd_number.beginDraw();
86
+
87
+ spd_number.imageMode(CORNER);
88
+
89
+ spd_number.image(spd_label_1, 0, y_1 - font_size_large / 2);
90
+
91
+ spd_number.image(spd_label_10, -spd_label_1.width, y_10 - font_size_large /2);
92
+
93
+ spd_number.image(spd_label_100, -(spd_label_1.width + spd_label_10.width), y_100 - font_size_large / 2);
94
+
95
+ spd_number.endDraw();
96
+
97
+
98
+
99
+ image(spd_number, 0, 0);
100
+
101
+ noFill();
102
+
103
+ translate(-displayWidth/2, -displayHeight/2);
104
+
105
+ }
106
+
107
+ ```
18
108
 
19
109
  ![イメージ説明](a22bc7cc6c0d870b150c004e0f37b303.png)
20
110