-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec_fretboard.PspScript
407 lines (342 loc) · 18.9 KB
/
vec_fretboard.PspScript
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
"""
Vector drawing of guitar fretboard
Bruce Wernick
24 November 2017
"""
from PSPApp import *
def ScriptProperties():
return {'Author': u'Bruce Wernick',
'Copyright': u'2017 Bruce Wernick',
'Description': u'Vector Drawing of Guitar Fretboard',
'Host': u'PaintShop Pro','Host Version': u'16.00'}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do(Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# File New
App.Do(Environment, 'NewFile', {'Width': 900, 'Height': 300,
'ColorDepth': App.Constants.Colordepth.SixteenMillionColor,
'DimensionUnits': App.Constants.DimensionType.Pixels,
'ResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn,
'Resolution': 100,
'FillMaterial': {'Color': (0,64,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'Transparent': True,
'LayerType': App.Constants.NewLayerType.Raster,
'ArtMediaTexture': {'Category': u'Art Media', 'Name': u'Corel_15_013', 'EnableFill': False,
'FillColor': (255,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# SelectDocument
App.Do(Environment, 'SelectDocument', {
'SelectedImage': 0, 'Strict': False,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# Fill
App.Do(Environment, 'Fill', {
'BlendMode': App.Constants.BlendMode.Normal, 'MatchMode': App.Constants.MatchMode.RGBValue,
'Material': {'Color': (255,255,255), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'UseForeground': False, 'Opacity': 100, 'Point': (452.5,176.5), 'SampleMerged': False, 'Tolerance': 20,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# defaults
RootNote = 'A'
LabelKind = 'symbol' # symbol, note or index
ScaleKind = 'minpent'
Result = App.Do(Environment, 'GetString', {
'DefaultText': RootNote,
'DialogTitle': 'Enter Root Note',
'Prompt': 'E,F,F#,G,Ab,A,Bb,B,C,C#,D or Eb',
'MaxLength': 40,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Default}})
if Result['OKButton']:
RootNote = Result['EnteredText']
Result = App.Do(Environment, 'GetString', {
'DefaultText': ScaleKind,
'DialogTitle': 'Enter Scale Kind',
'Prompt': 'minpent, majpent, major, minor, ionian, dorian, phrygian, lydian, mixolydian, aeolian, locrian, wholestep',
'MaxLength': 40,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Default}})
if Result['OKButton']:
ScaleKind = Result['EnteredText']
Result = App.Do(Environment, 'GetString', {
'DefaultText': LabelKind,
'DialogTitle': 'Enter Label Kind',
'Prompt': 'symbol, note or index',
'MaxLength': 40,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Default}})
if Result['OKButton']:
LabelKind = Result['EnteredText']
# scales notes are defined by list of index numbers
if ScaleKind == 'minpent': ScaleNotes = [0,3,5,7,10]
elif ScaleKind == 'majpent': ScaleNotes = [0,2,4,7,9]
elif ScaleKind == 'major': ScaleNotes = [0,2,4,5,7,9,11]
elif ScaleKind == 'minor': ScaleNotes = [0,2,3,5,7,8,10]
elif ScaleKind == 'ionian': ScaleNotes = [0,2,4,5,7,9,11]
elif ScaleKind == 'dorian': ScaleNotes = [0,2,3,5,7,9,10]
elif ScaleKind == 'phrygian': ScaleNotes = [0,1,3,5,7,8,10]
elif ScaleKind == 'lydian': ScaleNotes = [0,2,4,6,7,9,11]
elif ScaleKind == 'mixolydian': ScaleNotes = [0,2,4,5,7,9,10]
elif ScaleKind == 'aeolian': ScaleNotes = [0,2,3,5,7,8,10]
elif ScaleKind == 'locrian': ScaleNotes = [0,1,3,5,6,8,10]
elif ScaleKind == 'wholestep': ScaleNotes = [0,2,4,6,8,10]
else: # fall through to major scale
ScaleKind = 'all'
ScaleNotes = [0,1,2,3,4,5,6,7,8,9,10,11]
NonScaleNotes = [i for i in range(12) if not i in ScaleNotes]
NoteSym = 'R,b2,2,b3,3,4,b5,5,b6,6,b7,7'.split(',')
NoteChr = 'E,F,F#,G,Ab,A,Bb,B,C,C#,D,Eb'.split(',')
k0 = [0,5,10,3,7,0] # E root open string note index
def rotate(a, n=0):
a[:] = a[-n:] + a[:-n]
def getchar(index):
if LabelKind == 'symbol':
return '{}'.format(NoteSym[index])
if LabelKind == 'note':
return '{}'.format(NoteChr[index])
LabelKind == 'index'
return '{}'.format(index)
index = NoteChr.index(RootNote)
rotate(NoteChr, -index)
for i in range(6):
k0[i] += 12-index
k0[i] = k0[i] % 12
k0.reverse() # reverse to match program string index
# fretboard dimensions
x0, y0 = 50.0, 50.0 # top left position
dx = 60.0 # fret step size
dy = dx/2.0 # string step size
m, n = 6, 14 # string and fret count
# -------------------------------------------------------------------
# Frets Layer
# -------------------------------------------------------------------
# New Vector Layer
App.Do(Environment, 'NewVectorLayer', {
'General': {'Opacity': 40, 'Name': u'Frets', 'IsVisible': True,
'IsTransparencyLocked': False, 'LinkSet': 0, 'UseHighlight': False,
'PaletteHighlightColor': (255,255,64), 'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal},
'BlendRanges': {'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
for i in range(1,n-1):
x = x0 + dx*i
FretWidth = 3
if i == 1:
FretWidth = 5
# NewDrawingObject
App.Do(Environment, 'NewDrawingObject', {
'Antialias': True, 'MiterLimit': 10, 'Join': App.Constants.JointStyle.Bevel, 'CreateAsVector': True,
'Fill': {'Color': None, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'LineStyle': {'Name': u'', 'FirstCap': (u'Butt',1,1), 'LastCap': (u'Butt',1,1), 'FirstSegCap': None,
'LastSegCap': None, 'UseSegmentCaps': False, 'Segments': None},
'LineWidth': FretWidth,
'Stroke': {'Color': (0,0,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'Path': None, 'ObjectName': u'New Path', 'Visibility': True,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# NodeEditOffset
App.Do(Environment, 'NodeEditOffset', {
'NodeEditOffsetPoint': (0,dy*(m-1)), 'NodeEditAddPoint': (x,y0),
'NodeEditNodeOffsetControlKeyState': False, 'NodeEditNodeOffsetShiftKeyState': True,
'NodeEditNodeOffsetAddNode': True, 'NodeEditNodeOffsetPart': 0,
'NodeEditNodeOffsetDoLine': True, 'NodeEditContinuous': True,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# -------------------------------------------------------------------
# Strings Layer
# -------------------------------------------------------------------
# New Vector Layer
App.Do(Environment, 'NewVectorLayer', {
'General': {'Opacity': 90, 'Name': u'Strings', 'IsVisible': True,
'IsTransparencyLocked': False, 'LinkSet': 0, 'UseHighlight': False,
'PaletteHighlightColor': (255,255,64), 'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal},
'BlendRanges': {'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
for i in range(m):
y = y0 + dy*i
# NewDrawingObject
App.Do(Environment, 'NewDrawingObject', {
'Antialias': True, 'MiterLimit': 10, 'Join': App.Constants.JointStyle.Bevel, 'CreateAsVector': True,
'Fill': {'Color': None, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'LineStyle': {'Name': u'', 'FirstCap': (u'Butt',1,1), 'LastCap': (u'Butt',1,1), 'FirstSegCap': None,
'LastSegCap': None, 'UseSegmentCaps': False, 'Segments': None},
'LineWidth': 2,
'Stroke': {'Color': (128,128,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'Path': None, 'ObjectName': u'New Path', 'Visibility': True,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# NodeEditOffset
App.Do(Environment, 'NodeEditOffset', {
'NodeEditOffsetPoint': (dx*(n-1),0), 'NodeEditAddPoint': (x0,y),
'NodeEditNodeOffsetControlKeyState': False, 'NodeEditNodeOffsetShiftKeyState': True,
'NodeEditNodeOffsetAddNode': True, 'NodeEditNodeOffsetPart': 0,
'NodeEditNodeOffsetDoLine': True, 'NodeEditContinuous': True,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# -------------------------------------------------------------------
# Nodes Layer
# -------------------------------------------------------------------
# New Vector Layer
App.Do(Environment, 'NewVectorLayer', {
'General': {'Opacity': 100, 'Name': u'Nodes', 'IsVisible': True,
'IsTransparencyLocked': False, 'LinkSet': 0, 'UseHighlight': False,
'PaletteHighlightColor': (255,255,64), 'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal},
'BlendRanges': {'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# Layer Properties
App.Do(Environment, 'LayerProperties', {
'General': None, 'BlendRanges': None, 'Path': None, 'ArtMediaTexture': None,
'Effects': {'Enabled': True,
'DropShadow': {'Enabled': True, 'Color': (127,127,127), 'Size': 0.2, 'Opacity': 0.8,
'OffsetX': 0.08, 'OffsetY': -0.08},
'InnerGlow': {'Enabled': False, 'Color': (255,255,255), 'Size': 0.3, 'Opacity': 0.5},
'OuterGlow': {'Enabled': False, 'Color': (255,255,255), 'Size': 0.43, 'Opacity': 0.8},
'Bevel': {'Enabled': False, 'Color': (255,255,255), 'Size': 0.1, 'Opacity': 0.5,
'LightX': -0.5, 'LightY': 0.5, 'LightZ': 0.5},
'Emboss': {'Enabled': False, 'Size': 0.1, 'Opacity': 0.5,
'LightX': -0.5, 'LightY': 0.5, 'LightZ': 0.5},
'Object': {'Enabled': True, 'Opacity': 1},
'Reflection': {'Enabled': False, 'Size': 0.5, 'Opacity': 0.5, 'Axis': 0}},
'BrightnessContrast': None, 'ChannelMixer': None, 'ColorBalance': None, 'CurveParams': None,
'HSL': None, 'Threshold': None, 'Levels': None, 'Posterize': None, 'Vibrancy': None,
'Overlay': None, 'LocalToneMapping': None, 'Invert': None, 'HistogramAdjustment': None,
'FillLightClarity': None,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
for j in range(m):
y = y0 + dy*j
k = k0[j]
for i in range(n-1):
x = x0 + dx/2.0 + dx*i
index = (i+k) % 12
color = (255,255,255)
linecolor = (128,128,128)
if index == 0: color = (255,128,128) # red
if index == 1: color = (230,128,204) # red voilet
if index == 2: color = (204,128,204) # violet
if index == 3: color = (179,128,204) # blue violet
if index == 4: color = (128,168,234) # blue
if index == 5: color = (133,218,225) # blue green
if index == 6: color = (128,204,128) # green
if index == 7: color = (179,230,128) # yellow green
if index == 8: color = (255,255,128) # yellow
if index == 9: color = (255,230,128) # yellow orange
if index == 10: color = (255,204,128) # orange
if index == 11: color = (255,179,128) # red orange
if index in NonScaleNotes:
# dont draw these nodes
continue
# CreateEllipseObject
App.Do(Environment, 'CreateEllipseObject', {'Antialias': True, 'MiterLimit': 10,
'Join': App.Constants.JointStyle.Bevel,
'CreateAsVector': True,
'Fill': {'Color': color, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'LineStyle': {'Name': u'', 'FirstCap': (u'Butt',7,7),
'LastCap': (u'Butt',1,1), 'FirstSegCap': None,
'LastSegCap': None, 'UseSegmentCaps': False, 'Segments': None},
'LineWidth': 1.6, 'Stroke': {'Color': linecolor, 'Pattern': None, 'Gradient': None,
'Texture': None, 'Art': None},
'ObjectName': u'New Ellipse', 'RadiusX': dy/2.0-1, 'RadiusY': dy/2.0-1,
'CenterX': x, 'CenterY': y, 'Matrix': None, 'Visibility': True,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Interactive,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# -------------------------------------------------------------------
# Labels Layer
# -------------------------------------------------------------------
# New Vector Layer
App.Do(Environment, 'NewVectorLayer', {
'General': {'Opacity': 100, 'Name': u'Labels', 'IsVisible': True,
'IsTransparencyLocked': False, 'LinkSet': 0, 'UseHighlight': False,
'PaletteHighlightColor': (255,255,64), 'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal},
'BlendRanges': {'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
for j in range(m):
y = y0 + dy*j
k = k0[j]
for i in range(n-1):
x = x0 + dx/2.0 + dx*i
# note index
index = (i+k) % 12
if index in NonScaleNotes:
# dont write these labels
continue
# index, NoteSym or NoteChr
c = getchar(index)
# Add label text
App.Do( Environment, 'TextEx', {'Visibility': True, 'CreateAs': App.Constants.CreateAs.Vector,
'Start': (x,y+dy/5.0), 'TextFlow': App.Constants.TextFlow.HorizontalDown,
'TextType': App.Constants.TextType.TextBase,
'Matrix': [1,0,0,0,1,0,0,0,1],
'AutoKern': True, 'Kerning': 75, 'Tracking': 0, 'Leading': 0,
'Font': u'Calibri', 'PointSize': 18.5,
'Italic': False, 'Bold': False, 'Underline': False, 'Strikethru': False,
'AntialiasStyle': App.Constants.AntialiasEx.Sharp, 'WarpText': True,
'SetText': App.Constants.Justify.Center,
'Fill': {'Color': (0,0,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'Stroke': {'Color': None, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'LineWidth': 1,
'LineStyle': {'Name': u'', 'FirstCap': (u'Butt',0.25,0.25), 'LastCap': (u'Butt',0.25,0.25),
'FirstSegCap': (u'',0.25,0.25), 'LastSegCap': (u'',0.25,0.25),
'UseSegmentCaps': False, 'Segments': None},
'Join': App.Constants.JointStyle.Miter, 'MiterLimit': 10,
'Characters': c, 'Strings': None, 'TextTarget': (0,0,[79],True), 'PathTarget': None,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# -------------------------------------------------------------------
# Title Layer
# -------------------------------------------------------------------
# New Vector Layer
App.Do(Environment, 'NewVectorLayer', {
'General': {'Opacity': 100, 'Name': u'Title', 'IsVisible': True,
'IsTransparencyLocked': False, 'LinkSet': 0, 'UseHighlight': False,
'PaletteHighlightColor': (255,255,64), 'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal},
'BlendRanges': {'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)},
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})
# Add title text
App.Do( Environment, 'TextEx', {'Visibility': True, 'CreateAs': App.Constants.CreateAs.Vector,
'Start': (200,264), 'TextFlow': App.Constants.TextFlow.HorizontalDown,
'TextType': App.Constants.TextType.TextBase,
'Matrix': [1,0,0,0,1,0,0,0,1],
'AutoKern': True, 'Kerning': 75, 'Tracking': 0, 'Leading': 0,
'Font': u'Calibri', 'PointSize': 24.5,
'Italic': False, 'Bold': True, 'Underline': False, 'Strikethru': False,
'AntialiasStyle': App.Constants.AntialiasEx.Sharp, 'WarpText': True,
'SetText': App.Constants.Justify.Center,
'Fill': {'Color': (24,24,24), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'Stroke': {'Color': None, 'Pattern': None, 'Gradient': None, 'Texture': None, 'Art': None},
'LineWidth': 1,
'LineStyle': {'Name': u'', 'FirstCap': (u'Butt',0.25,0.25), 'LastCap': (u'Butt',0.25,0.25),
'FirstSegCap': (u'',0.25,0.25), 'LastSegCap': (u'',0.25,0.25),
'UseSegmentCaps': False, 'Segments': None},
'Join': App.Constants.JointStyle.Miter, 'MiterLimit': 10,
'Characters': '{}: {}'.format(RootNote,ScaleKind), 'Strings': None,
'TextTarget': (0,0,[79],True), 'PathTarget': None,
'GeneralSettings': {'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((16,0,0),1)}})