changed structure, commented, added CLI arguments
This commit is contained in:
parent
ad3a6bf2ae
commit
715cda17ab
2 changed files with 183 additions and 83 deletions
220
sigilize.py
220
sigilize.py
|
|
@ -1,13 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Copyright (c) 2020 Sublunar Psionics
|
||||
|
||||
---- MIT License ----
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import time
|
||||
import math
|
||||
import swisseph as swe
|
||||
import drawSvg as svg
|
||||
from openlocationcode import openlocationcode as olc
|
||||
|
||||
def planetaryMoment(lat, lon, epoch): # calculate planetary ephemeris + ascendant according to location and timestamp
|
||||
def astroChart(lat, lon, epoch, canvas, colors = ['violet', 'yellow', 'white', 'orange', 'green', 'red', 'royalblue', 'indigo']):
|
||||
|
||||
print("drawing astro chart for", epoch)
|
||||
planets = [0,1,2,3,4,5,6]
|
||||
tmp = time.gmtime(epoch) # convert epoch to time
|
||||
hours = tmp.tm_hour + tmp.tm_min / 60 + tmp.tm_sec / 3600 # convert hh:mm:ss to decimal hours
|
||||
|
|
@ -23,51 +46,22 @@ def planetaryMoment(lat, lon, epoch): # calculate planetary ephemeris + ascendan
|
|||
planets[i] = planets[i][0][0]
|
||||
|
||||
cusps = swe.houses_ex(jd, lat, lon, b'P',0) # get ecliptic ascendant degree
|
||||
planets.insert(0, cusps[0][0])
|
||||
planets.insert(0, cusps[0][0]) # add to list
|
||||
|
||||
return planets
|
||||
|
||||
def locationSigil(plusCode, planets, canvas): # draw arcs depending on planetary positions at the moment in time
|
||||
|
||||
colors = ['violet', 'yellow', 'white', 'orange', 'green', 'red', 'royalblue', 'indigo'] # black inner circle for ascendant and planetary colors
|
||||
|
||||
# draw rings for ascendant + planets and keep a small gap at the ecliptic degrees they are in
|
||||
# draw arcs for ascendant + planets
|
||||
for i in range(len(planets)):
|
||||
circleColor = colors[i]
|
||||
# circleColor = 'grey'
|
||||
degree = planets[i]
|
||||
startArc = degree + 90 # 0° is at the 12 o'clock position
|
||||
endArc = degree - 110 + 90
|
||||
radius = 180 + i * 10
|
||||
canvas.append(svg.ArcLine(0, 0, radius, startArc, endArc, stroke=circleColor, stroke_width=7, fill='none'))
|
||||
|
||||
def magicSquareSigil(plusCode, canvas, color='white'): # draw sigil based on OLC magic square
|
||||
|
||||
codeList = list(plusCode.replace('+', '')) # remove the + in the string
|
||||
|
||||
#draw global area sigil
|
||||
arrow2 = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
||||
arrow2.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke='red'))
|
||||
dot2 = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
||||
dot2.append(svg.Circle(0.0, 0.0, 0.4, stroke_width=0.2, stroke='red'))
|
||||
# set up sigil path
|
||||
p = svg.Path(stroke_width=7, stroke='red', fill='none', marker_start=dot2, marker_end=arrow2)
|
||||
# draw sigil
|
||||
drawGlobalSigil(codeList, p, 4)
|
||||
canvas.append(p)
|
||||
|
||||
del codeList[0:4] # delete area code from list
|
||||
|
||||
#draw local fractal sigil
|
||||
arrow = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
||||
arrow.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke='white'))
|
||||
dot = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
||||
dot.append(svg.Circle(0.0, 0.0, 0.4, stroke_width=0.2, stroke='white'))
|
||||
# set up sigil path
|
||||
p = svg.Path(stroke_width=7, stroke='white', fill='none', marker_start=dot, marker_end=arrow)
|
||||
# draw sigil
|
||||
drawLocalSigil(codeList, p, 5)
|
||||
canvas.append(p)
|
||||
|
||||
def drawLocalSigil(points, p, length): # draw sigil based on OLC magic square
|
||||
print("sigilizing", codeList)
|
||||
length = len(codeList)
|
||||
grid = {
|
||||
'R' : [-103, 112], 'V' : [-35, 112], 'W' : [35, 112], 'X' : [103, 112], # | R | V | W | X |
|
||||
'J' : [-103, 56], 'M' : [-35, 56], 'P' : [35, 56], 'Q' : [103, 56], # | J | M | P | Q |
|
||||
|
|
@ -75,27 +69,50 @@ def drawLocalSigil(points, p, length): # draw sigil based on OLC magic square
|
|||
'6' : [-103, -56], '7' : [-35, -56], '8' : [35, -56], '9' : [103, -56], # | 6 | 7 | 8 | 9 |
|
||||
'2' : [-103, -112], '3' : [-35, -112], '4' : [35, -112], '5' : [103, -112] # | 2 | 3 | 4 | 5 |
|
||||
}
|
||||
# get the starting point
|
||||
originX = grid[points[0]][0]
|
||||
originY = grid[points[0]][1]
|
||||
p.M(originX, originY)
|
||||
del points[0] # delete starting point from list
|
||||
|
||||
# setup sigil
|
||||
dash = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
||||
dash.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke=color))
|
||||
dot = svg.Marker(-0.8, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
||||
dot.append(svg.Circle(-0.3, 0.0, 0.3, stroke_width=0.2, stroke=color, fill='none'))
|
||||
p = svg.Path(stroke_width=7, stroke=color, fill='none', marker_start=dot, marker_end=dash)
|
||||
|
||||
# draw sigil
|
||||
for c in range(length):
|
||||
x = grid[points[c]][0] - originX # abs. to rel. coords
|
||||
y = grid[points[c]][1] - originY # abs. to rel. coords
|
||||
p.l(x, y) # draw
|
||||
originX = grid[points[c]][0]
|
||||
originY = grid[points[c]][1]
|
||||
if c == 0:
|
||||
originX = grid[codeList[0]][0]
|
||||
originY = grid[codeList[0]][1]
|
||||
p.M(originX, originY)
|
||||
else:
|
||||
x = grid[codeList[c]][0] - originX # abs. to rel. coords
|
||||
y = grid[codeList[c]][1] - originY # abs. to rel. coords
|
||||
p.l(x, y) # draw
|
||||
originX = grid[codeList[c]][0]
|
||||
originY = grid[codeList[c]][1]
|
||||
|
||||
def drawGlobalSigil(points, p, length): # draw sigil based on concentric circle positions
|
||||
# add to canvas
|
||||
canvas.append(p)
|
||||
|
||||
def radialSigil(plusCode, canvas, color='red'): # draw sigil based on concentric circle positions
|
||||
|
||||
codeList = list(plusCode.replace('+', '')) # remove the + in the string
|
||||
print("sigilizing", codeList)
|
||||
length = len(codeList)
|
||||
decoder = ['2', '3', '4', '5', '6', '7', '8', '9', 'C', 'F', 'G', 'H', 'J', 'M', 'P', 'Q', 'R', 'V', 'W', 'X']
|
||||
|
||||
#draw global area sigil
|
||||
arrow2 = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
||||
arrow2.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke=color))
|
||||
dot2 = svg.Marker(-0.8, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
||||
dot2.append(svg.Circle(-0.3, 0.0, 0.3, stroke_width=0.2, stroke=color, fill='none'))
|
||||
# set up sigil path
|
||||
p = svg.Path(stroke_width=7, stroke=color, fill='none', marker_start=dot2, marker_end=arrow2)
|
||||
|
||||
for c in range(length):
|
||||
index = decoder.index(points[c])
|
||||
index = decoder.index(codeList[c])
|
||||
|
||||
# find coordinates on circle every 18° (360° / 20 digits)
|
||||
radius = 150 - c * 20
|
||||
radius = 145 - c * 20
|
||||
angle = 18 * index
|
||||
x = radius * math.cos(angle)
|
||||
y = radius * math.sin(angle)
|
||||
|
|
@ -108,28 +125,103 @@ def drawGlobalSigil(points, p, length): # draw sigil based on concentric circle
|
|||
p.l(x - originX, y - originY) # draw
|
||||
originX = x
|
||||
originY = y
|
||||
|
||||
canvas.append(p)
|
||||
|
||||
def nameToPlusCode(name):
|
||||
vowels = [ 'A', 'E', 'I', 'O', 'U']
|
||||
translate = {
|
||||
'B' : '2',
|
||||
'D' : '3',
|
||||
'K' : '4',
|
||||
'L' : '5',
|
||||
'N' : '6',
|
||||
'S' : '7',
|
||||
'T' : '8',
|
||||
'Z' : '9',
|
||||
'Y' : 'J'
|
||||
}
|
||||
newName = name.upper().replace(" ", "")
|
||||
for x in newName:
|
||||
if x in vowels:
|
||||
newName = newName.replace(x,"")
|
||||
if x in translate.keys():
|
||||
newName = newName.replace(x, translate[x])
|
||||
return newName
|
||||
|
||||
def drawSigil(lat, lon, epoch, squareSigilize, radialSigilize, fileName):
|
||||
|
||||
# set up SVG canvas
|
||||
d = svg.Drawing(600, 600, origin='center') # define canvas
|
||||
|
||||
# Create gradients
|
||||
gradient = svg.RadialGradient(0,0,260)
|
||||
gradient.addStop(0, '#211d05', 1)
|
||||
gradient.addStop(1, 'black', 1)
|
||||
rusty = svg.RadialGradient(0,0,260)
|
||||
rusty.addStop(0.5, '#d17b0a', 1)
|
||||
rusty.addStop(1, '#453905', 1)
|
||||
silver = svg.RadialGradient(0,0,260)
|
||||
silver.addStop(0.5, 'white', 0.8)
|
||||
silver.addStop(1, 'grey', 1)
|
||||
|
||||
# Background circle
|
||||
c = svg.Circle(0, 0, 260, fill=gradient, stroke_width=0)
|
||||
d.append(c)
|
||||
|
||||
# draw astro chart for epoch moment
|
||||
astroChart(lat, lon, epoch, d, [rusty, rusty, rusty, rusty, rusty, rusty, rusty, rusty])
|
||||
|
||||
# draw sigils
|
||||
radialSigil(radialSigilize, d)
|
||||
magicSquareSigil(squareSigilize, d)
|
||||
|
||||
# save sigil to SVG file
|
||||
d.saveSvg(fileName)
|
||||
|
||||
def main():
|
||||
|
||||
lat = 37.223187
|
||||
lon = 38.922438
|
||||
epoch = time.time() # now
|
||||
argNo = len(sys.argv) - 1
|
||||
|
||||
# calculate OLC and ephemeris
|
||||
plusCode = olc.encode(lat,lon,10) # generate Open Location Code aka. plus code from coordinates
|
||||
planets = planetaryMoment(lat, lon, epoch) # generate planetary ephemeris
|
||||
if argNo == 5: # if coordinates, timestamp, and two strings (first + last name)are provided
|
||||
|
||||
# set up SVG canvas
|
||||
d = svg.Drawing(600, 600, origin='center', displayInline=False) # define canvas
|
||||
d.append(svg.Circle(0, 0, 260, fill='black', stroke_width=0))
|
||||
lat = float(sys.argv[1])
|
||||
lon = float(sys.argv[2])
|
||||
epoch = float(sys.argv[3])
|
||||
squareSigilize = nameToPlusCode(sys.argv[4]) # first name
|
||||
radialSigilize = nameToPlusCode(sys.argv[5]) # last name
|
||||
fileName = '%s_%s.svg' % (sys.argv[5], sys.argv[4])
|
||||
drawSigil(lat, lon, epoch, squareSigilize, radialSigilize, fileName)
|
||||
|
||||
# draw sigil
|
||||
locationSigil(plusCode, planets, d) # draw sigil SVG
|
||||
if argNo == 3: # if coordinates, and timestamp are provided
|
||||
|
||||
# save sigil to SVG file
|
||||
fileName = '%s-%s.svg' % (plusCode, epoch)
|
||||
fileName = 'test.svg'
|
||||
d.saveSvg(fileName)
|
||||
lat = float(sys.argv[1])
|
||||
lon = float(sys.argv[2])
|
||||
epoch = float(sys.argv[3])
|
||||
plusCode = olc.encode(lat,lon,10) # generate Open Location Code aka. plus code from coordinates
|
||||
squareSigilize = plusCode[4:]
|
||||
radialSigilize = plusCode[0:4]
|
||||
fileName = '%s-%s.svg' % (plusCode, epoch)
|
||||
drawSigil(lat, lon, epoch, squareSigilize, radialSigilize, fileName)
|
||||
|
||||
|
||||
if argNo == 2: # if just coordinates are provided
|
||||
|
||||
lat = float(sys.argv[1])
|
||||
lon = float(sys.argv[2])
|
||||
epoch = time.time()
|
||||
plusCode = olc.encode(lat,lon,10) # generate Open Location Code aka. plus code from coordinates
|
||||
squareSigilize = plusCode[4:]
|
||||
radialSigilize = plusCode[0:4]
|
||||
fileName = '%s-%s.svg' % (plusCode, epoch)
|
||||
drawSigil(lat, lon, epoch, squareSigilize, radialSigilize, fileName)
|
||||
else:
|
||||
print("--------------------------------------------")
|
||||
print("Please provide arguments: <decimal latitude> <decimal longitude> (<epoch timestamp> <first name> <last name>)")
|
||||
print("--------------------------------------------")
|
||||
print("If you only provide latitude and longitude, the timestamp is calculated automatically for this moment.")
|
||||
print("If you provice first- and last name of a person, please provide their birth-location coordinates and birth-time as geospatial arguments")
|
||||
print("--------------------------------------------")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
46
test.svg
46
test.svg
|
|
@ -2,28 +2,36 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="600" height="600" viewBox="-300.0 -300.0 600 600">
|
||||
<defs>
|
||||
<marker markerWidth="5.0" markerHeight="5.0" viewBox="-0.5 -0.5 1.0 1.0" orient="auto" id="d0">
|
||||
<circle cx="0.0" cy="-0.0" r="0.4" stroke-width="0.2" stroke="red" />
|
||||
</marker>
|
||||
<marker markerWidth="5.0" markerHeight="5.0" viewBox="-0.5 -0.5 1.0 1.0" orient="auto" id="d1">
|
||||
<path d="M-0.0,0.5 L0.0,-0.5" stroke-width="0.2" stroke="red" />
|
||||
</marker>
|
||||
<marker markerWidth="5.0" markerHeight="5.0" viewBox="-0.5 -0.5 1.0 1.0" orient="auto" id="d2">
|
||||
<circle cx="0.0" cy="-0.0" r="0.4" stroke-width="0.2" stroke="white" />
|
||||
<radialGradient cx="0" cy="0" r="260" gradientUnits="userSpaceOnUse" id="d0">
|
||||
<stop offset="0" stop-color="#211d05" stop-opacity="1" />
|
||||
<stop offset="1" stop-color="black" stop-opacity="1" />
|
||||
</radialGradient>
|
||||
<radialGradient cx="0" cy="0" r="260" gradientUnits="userSpaceOnUse" id="d1">
|
||||
<stop offset="0.5" stop-color="#d17b0a" stop-opacity="1" />
|
||||
<stop offset="1" stop-color="#453905" stop-opacity="1" />
|
||||
</radialGradient>
|
||||
<marker markerWidth="6.5" markerHeight="5.0" viewBox="-0.8 -0.5 1.3 1.0" orient="auto" id="d2">
|
||||
<circle cx="-0.3" cy="-0.0" r="0.3" stroke-width="0.2" stroke="red" fill="none" />
|
||||
</marker>
|
||||
<marker markerWidth="5.0" markerHeight="5.0" viewBox="-0.5 -0.5 1.0 1.0" orient="auto" id="d3">
|
||||
<path d="M-0.0,0.5 L0.0,-0.5" stroke-width="0.2" stroke="red" />
|
||||
</marker>
|
||||
<marker markerWidth="6.5" markerHeight="5.0" viewBox="-0.8 -0.5 1.3 1.0" orient="auto" id="d4">
|
||||
<circle cx="-0.3" cy="-0.0" r="0.3" stroke-width="0.2" stroke="white" fill="none" />
|
||||
</marker>
|
||||
<marker markerWidth="5.0" markerHeight="5.0" viewBox="-0.5 -0.5 1.0 1.0" orient="auto" id="d5">
|
||||
<path d="M-0.0,0.5 L0.0,-0.5" stroke-width="0.2" stroke="white" />
|
||||
</marker>
|
||||
</defs>
|
||||
<circle cx="0" cy="0" r="260" fill="black" stroke-width="0" />
|
||||
<circle cx="0" cy="0" r="180" stroke-dasharray="785.3981633974483 345.5751918948772" stroke-dashoffset="-611.7689848594903" stroke="violet" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="190" stroke-dasharray="829.0313946973066 364.7738136668148" stroke-dashoffset="-1077.3414489697823" stroke="yellow" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="200" stroke-dasharray="872.6646259971649 383.9724354387524" stroke-dashoffset="-155.4435945077978" stroke="white" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="210" stroke-dasharray="916.297857297023 403.17105721069015" stroke-dashoffset="-1145.6101047542002" stroke="orange" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="220" stroke-dasharray="959.9310885968813 422.36967898262776" stroke-dashoffset="-1145.2295665673755" stroke="green" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="230" stroke-dasharray="1003.5643198967396 441.56830075456537" stroke-dashoffset="-194.32135261741215" stroke="red" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="240" stroke-dasharray="1047.1975511965977 460.76692252650287" stroke-dashoffset="-346.66820676838495" stroke="royalblue" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="250" stroke-dasharray="1090.830782496456 479.96554429844036" stroke-dashoffset="-340.59431884378057" stroke="indigo" stroke-width="7" fill="none" />
|
||||
<path d="M56.326439665051815,-139.02277581266776 l-134.12624864257336,243.1726184580657 l181.6380642842761,-140.44883346951397 l-186.16397132093834,72.6648605751885" stroke-width="7" stroke="red" fill="none" marker-start="url(#d0)" marker-end="url(#d1)" />
|
||||
<path d="M-103,56 l138,-168 l-70,112 l-68,0 l68,56 l138,-168" stroke-width="7" stroke="white" fill="none" marker-start="url(#d2)" marker-end="url(#d3)" />
|
||||
<circle cx="0" cy="0" r="260" fill="url(#d0)" stroke-width="0" />
|
||||
<circle cx="0" cy="0" r="180" stroke-dasharray="785.3981633974483 345.5751918948772" stroke-dashoffset="-1032.0604797195665" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="190" stroke-dasharray="829.0313946973066 364.7738136668148" stroke-dashoffset="-50.51345312640888" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="200" stroke-dasharray="872.6646259971646 383.97243543875265" stroke-dashoffset="-924.527778673677" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="210" stroke-dasharray="916.297857297023 403.17105721069015" stroke-dashoffset="-150.70099710238122" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="220" stroke-dasharray="959.9310885968813 422.36967898262776" stroke-dashoffset="-1266.285248454271" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="230" stroke-dasharray="1003.5643198967396 441.56830075456537" stroke-dashoffset="-936.1477798329598" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="240" stroke-dasharray="1047.1975511965977 460.76692252650287" stroke-dashoffset="-955.8976439659806" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<circle cx="0" cy="0" r="250" stroke-dasharray="1090.830782496456 479.96554429844036" stroke-dashoffset="-904.1969047438342" stroke="url(#d1)" stroke-width="7" fill="none" />
|
||||
<path d="M75.08036035436793,124.04813375886901 l-164.82849585058213,-211.05544480198296 l-11.813176272543458,60.35585795310013 l31.069975975389895,74.14852224240119 l41.366550744971704,-105.60685228642365 l46.022716947911604,16.402950390235937" stroke-width="7" stroke="red" fill="none" marker-start="url(#d2)" marker-end="url(#d3)" />
|
||||
<path d="M35,56 l-138,56 l68,-56 l0,-56 l-68,-112 l68,224 l-68,-224 l138,224" stroke-width="7" stroke="white" fill="none" marker-start="url(#d4)" marker-end="url(#d5)" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue