Just a small script to generate word wheel puzzles: run from the command line by giving the any number of letters (central letter first) and redirecting its output to a file. Output is as an SVG file.
$ python make_word_wheel.py eeialctrh >wordwheel.svg
import sys
import math
try:
letters = sys.argv[1]
except IndexError:
print('usage: {} <letters>'.format(sys.argv[0]))
print('The central letter should be given first.')
sys.exit(1)
# The coordinates of the centre of the 300x300 image
cx, cy = 150, 150
# SVG preamble and styles
print("""<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300" >
<defs>
<style type="text/css"><![CDATA[
circle {
fill: #fff;
stroke: #000;
stroke-width: 3px;
}
.central_circle {
fill: #000;
}
text {
font-size: 18pt;
font-family: sans-serif;
text-anchor: middle;
dominant-baseline: middle;
}
text.central_letter {
fill: #fff;
stroke: #fff;
}
]]></style>
</defs>
""")
# The central letter
print('<circle cx="150" cy="150" r="30" class="central_circle"/>')
print('<text x="150" y="150" class="central_letter">{}</text>'
.format(letters[0].upper()))
# The surrounding letters.
m = len(letters)-1
for i in range(0, m):
letter = letters[i+1].upper()
x = cx + 85*math.cos(i * 2*math.pi/m)
y = cy + 85*math.sin(i * 2*math.pi/m)
print('<circle cx="{}" cy="{}" r="30"/>'.format(x, y))
print('<text x="{}" y="{}">{}</text>'.format(x, y, letter))
# Close tag and we're done.
print('</svg>')
Comments
Comments are pre-moderated. Please be patient and your comment will appear soon.
There are currently no comments
New Comment