-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfMain.frm
More file actions
512 lines (464 loc) · 13.3 KB
/
fMain.frm
File metadata and controls
512 lines (464 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
VERSION 5.00
Begin VB.Form fMain
Caption = "Mixing Colors like Pigments"
ClientHeight = 9015
ClientLeft = 120
ClientTop = 465
ClientWidth = 11535
BeginProperty Font
Name = "Tahoma"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 601
ScaleMode = 3 'Pixel
ScaleWidth = 769
StartUpPosition = 1 'CenterOwner
Begin VB.HScrollBar HPerc
Height = 375
Left = 3240
Max = 100
TabIndex = 22
Top = 3960
Width = 5175
End
Begin VB.PictureBox PIC5
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 975
Left = 3120
ScaleHeight = 945
ScaleWidth = 3225
TabIndex = 20
Top = 6600
Width = 3255
End
Begin VB.PictureBox PIC4
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 975
Left = 3120
ScaleHeight = 945
ScaleWidth = 3225
TabIndex = 9
Top = 7920
Width = 3255
End
Begin VB.PictureBox PIC1
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 975
Left = 360
ScaleHeight = 945
ScaleWidth = 3225
TabIndex = 8
Top = 2760
Width = 3255
End
Begin VB.PictureBox PIC3
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 975
Left = 3120
ScaleHeight = 945
ScaleWidth = 3225
TabIndex = 7
Top = 5160
Width = 3255
End
Begin VB.PictureBox PIC2
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 975
Left = 5760
ScaleHeight = 945
ScaleWidth = 3225
TabIndex = 6
Top = 2760
Width = 3255
End
Begin VB.HScrollBar HB
Height = 495
Index = 1
Left = 4920
Max = 255
TabIndex = 5
Top = 1680
Width = 3615
End
Begin VB.HScrollBar HG
Height = 495
Index = 1
Left = 4920
Max = 255
TabIndex = 4
Top = 960
Width = 3615
End
Begin VB.HScrollBar HR
Height = 495
Index = 1
Left = 4920
Max = 255
TabIndex = 3
Top = 240
Width = 3615
End
Begin VB.HScrollBar HB
Height = 495
Index = 0
Left = 120
Max = 255
TabIndex = 2
Top = 1680
Width = 3615
End
Begin VB.HScrollBar HG
Height = 495
Index = 0
Left = 120
Max = 255
TabIndex = 1
Top = 960
Width = 3615
End
Begin VB.HScrollBar HR
Height = 495
Index = 0
Left = 120
Max = 255
TabIndex = 0
Top = 240
Width = 3615
End
Begin VB.Label lPerc
Alignment = 2 'Center
Caption = "RGB 1"
Height = 375
Left = 8520
TabIndex = 23
Top = 3960
Width = 1335
End
Begin VB.Label lResult3
Alignment = 2 'Center
Caption = "R3"
Height = 375
Left = 240
TabIndex = 21
Top = 6240
Width = 9015
End
Begin VB.Label lResult1
Alignment = 2 'Center
Caption = "R1"
Height = 375
Left = 240
TabIndex = 19
Top = 4800
Width = 9015
End
Begin VB.Label lResult2
Alignment = 2 'Center
Caption = "R2"
Height = 375
Left = 240
TabIndex = 18
Top = 7560
Width = 9015
End
Begin VB.Label LR
Caption = "Label2"
Height = 375
Index = 1
Left = 8640
TabIndex = 17
Top = 360
Width = 615
End
Begin VB.Label LB
Caption = "Label2"
Height = 375
Index = 1
Left = 8640
TabIndex = 16
Top = 1920
Width = 615
End
Begin VB.Label LG
Caption = "Label2"
Height = 375
Index = 1
Left = 8640
TabIndex = 15
Top = 1080
Width = 615
End
Begin VB.Label LR
Caption = "Label2"
Height = 375
Index = 0
Left = 3840
TabIndex = 14
Top = 360
Width = 615
End
Begin VB.Label LB
Caption = "Label2"
Height = 375
Index = 0
Left = 3840
TabIndex = 13
Top = 1920
Width = 615
End
Begin VB.Label LG
Caption = "Label2"
Height = 375
Index = 0
Left = 3840
TabIndex = 12
Top = 1080
Width = 615
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "RGB 2"
Height = 375
Left = 5760
TabIndex = 11
Top = 2400
Width = 3255
End
Begin VB.Label lRGB1
Alignment = 2 'Center
Caption = "RGB 1"
Height = 375
Left = 360
TabIndex = 10
Top = 2400
Width = 3255
End
End
Attribute VB_Name = "fMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'https://stackoverflow.com/questions/1351442/is-there-an-algorithm-for-color-mixing-that-works-like-mixing-real-colors
Dim R1!, G1!, B1!
Attribute G1.VB_VarUserMemId = 1073938432
Attribute B1.VB_VarUserMemId = 1073938432
Dim R2!, G2!, B2!
Attribute R2.VB_VarUserMemId = 1073938435
Attribute G2.VB_VarUserMemId = 1073938435
Attribute B2.VB_VarUserMemId = 1073938435
Dim R3!, G3!, B3!
Attribute R3.VB_VarUserMemId = 1073938436
Attribute G3.VB_VarUserMemId = 1073938436
Attribute B3.VB_VarUserMemId = 1073938436
Private Sub Form_Activate()
HR.Item(0).Value = 255
HG.Item(0).Value = 255
HB.Item(0).Value = 1
HR.Item(1).Value = 1
HG.Item(1).Value = 1
HB.Item(1).Value = 255
HPerc = 50
End Sub
Private Sub Form_Load()
Dim I As Long
Dim rr!, GG!, bB!
LoadTables
PigmentMix 1, 0.95, 0, _
0.1, 0.1, 1, 0.5, rr, GG, bB
PigmentMix 0.5, 0.5, 0.5, _
0.1, 0.8, 1, 0.5, rr, GG, bB
Exit Sub
CreateWheels
'' End
Dim R!, G!, B!
Dim AA&, Re&
Dim J&, K&
For I = 0 To 7
For J = I + 1 To 7
R1 = -((I And &H1) = 1)
G1 = -((I And &H2) = 2)
B1 = -((I And &H4) = 4)
R2 = -((J And &H1) = 1)
G2 = -((J And &H2) = 2)
B2 = -((J And &H4) = 4)
CreateGradients R1, G1, B1, R2, G2, B2, K
K = K + 1
Next
Next
'Dim St!
'St = 1
'
'For R1 = 0 To 1 Step St
'For G1 = 0 To 1 Step St
'For B1 = 0 To 1 Step St
'
'For R2 = 0 To 1 Step St
'For G2 = 0 To 1 Step St
'For B2 = 0 To 1 Step St
'If R1 <> R2 Or G1 <> G2 Or B1 <> B2 Then
' CreateGradients R1, G1, B1, R2, G2, B2, K
' K = K + 1
'End If
'Next
'Next
'Next
'Next
'Next
'Next
End
End Sub
Private Sub SetMIXEDColor()
Dim P As Double
Dim Q As Double
P = HPerc.Value * 0.01
Q = 1 - P
PIC1.BackColor = RGB(R1, G1, B1)
PIC2.BackColor = RGB(R2, G2, B2)
PigmentMixREEXRE R1, G1, B1, R2, G2, B2, HPerc.Value * 0.01, R3, G3, B3
PIC3.BackColor = RGB(R3, G3, B3)
lResult1.Caption = "MY Pigment Mix (Subtractive): " & Round(R3) & "-" & Round(G3) & "-" & Round(B3)
PIC4.BackColor = RGB(R1 * Q + P * R2, G1 * Q + P * G2, B1 * Q + P * B2)
lResult2.Caption = "Light Mix (Additive): " & Round(R1 * Q + P * R2) & "-" & Round(G1 * Q + P * G2) & "-" & Round(B1 * Q + P * B2)
PigmentMix R1, G1, B1, R2, G2, B2, P, R3, G3, B3
PIC5.BackColor = RGB(R3, G3, B3)
lResult3.Caption = "Pigment Mix (Subtractive): " & Round(R3) & "-" & Round(G3) & "-" & Round(B3)
End Sub
Private Sub Form_Resize()
Dim W As Long
Dim I As Long
W = Me.ScaleWidth
If W < 10 Then Exit Sub
HR(0).Width = W * 0.5 - LR(0).Width - 8
HR(0).Left = 8
LR(0).Left = HR(0).Left + HR(0).Width
HR(1).Width = W * 0.5 - LR(1).Width - 8
HR(1).Left = W * 0.5 + 8
LR(1).Left = HR(1).Left + HR(1).Width
For I = 0 To 1
HG(I).Width = HR(I).Width
HG(I).Left = HR(I).Left
LG(I).Left = LR(I).Left
HB(I).Width = HR(I).Width
HB(I).Left = HR(I).Left
LB(I).Left = LR(I).Left
Next
PIC1.Left = W * 0.25 - PIC1.Width * 0.5
PIC2.Left = W * 0.75 - PIC2.Width * 0.5
lRGB1.Left = W * 0.25 - lRGB1.Width * 0.5
Label1.Left = W * 0.75 - Label1.Width * 0.5
lResult1.Left = W * 0.5 - lResult1.Width * 0.5
lResult2.Left = W * 0.5 - lResult2.Width * 0.5
lResult3.Left = W * 0.5 - lResult3.Width * 0.5
PIC3.Left = W * 0.5 - PIC3.Width * 0.5
PIC4.Left = W * 0.5 - PIC4.Width * 0.5
PIC5.Left = W * 0.5 - PIC5.Width * 0.5
HPerc.Left = W * 0.5 - HPerc.Width * 0.5
lPerc.Left = HPerc.Left + HPerc.Width + 2
End Sub
Private Sub HPerc_Change()
lPerc = HPerc & "%"
SetMIXEDColor
End Sub
Private Sub HPerc_Scroll()
lPerc = HPerc & "%"
SetMIXEDColor
End Sub
Private Sub HR_Change(Index As Integer)
HR_Scroll Index
End Sub
Private Sub HG_Change(Index As Integer)
HG_Scroll Index
End Sub
Private Sub HB_Change(Index As Integer)
HB_Scroll Index
End Sub
Private Sub HB_Scroll(Index As Integer)
If Index = 0 Then
B1 = HB.Item(Index).Value
Else
B2 = HB.Item(Index).Value
End If
LB(Index) = HB.Item(Index).Value
SetMIXEDColor
End Sub
Private Sub HG_Scroll(Index As Integer)
If Index = 0 Then
G1 = HG.Item(Index).Value
Else
G2 = HG.Item(Index).Value
End If
LG(Index) = HG.Item(Index).Value
SetMIXEDColor
End Sub
Private Sub HR_Scroll(Index As Integer)
If Index = 0 Then
R1 = HR.Item(Index).Value
Else
R2 = HR.Item(Index).Value
End If
LR(Index) = HR.Item(Index).Value
SetMIXEDColor
End Sub