-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHello_Gradient_Spirograph.py
53 lines (48 loc) · 1.75 KB
/
Hello_Gradient_Spirograph.py
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
notice = """
Hello Gradient Spirograph Demo
-----------------------------------
| Copyright 2022 by Joel C. Alcarez |
| [joelalcarez1975@gmail.com] |
|-----------------------------------|
| We make absolutely no warranty |
| of any kind, expressed or implied |
|-----------------------------------|
| This graphics library outputs |
| to a bitmap file. |
-----------------------------------
"""
from pythonbmp.BITMAPlib import(
newBMP,
pi,
centercoord,
gradplotlines as g,
spirographvert as f,
getX11RGBfactors as c,
getfuncmetastr as meta,
saveBMP
)
import subprocess as proc
from os import path
def main():
print(f'{notice}\n{meta(f)}\n{meta(g)}\n')
imgedt = 'mspaint' # replace with another editor if Unix
rootdir = path.dirname(__file__) # get path of this script
mx = my = 500 # bitmap size
bmp = newBMP(mx, my, 24) # RGB
(x, y) = centercoord(bmp) # How to get center of the bitmap
file = f'Hello{f.__name__}{g.__name__}.bmp' # file name
d = 1/120 # angle increment
lim = pi * 10 + d # angle limit
g(bmp, f(x, y, # control spirograph location
200, # control spirograph size
1.8, .3, # controls spirograph shape
d, lim), # angle step and limit
7, # pen radius
[255, 0], # luminosity range
c()['gold']) # connect the dots with lines
saveBMP(file, bmp) # save file
print('Saved to %s in %s\nAll done close %s to finish' % \
(file, rootdir, imgedt)) # tell user we are done
ret = proc.call([imgedt, file])
if __name__=="__main__":
main()