hershey text
This commit is contained in:
parent
7d7afe1439
commit
355073f7d8
|
@ -4,3 +4,39 @@ from .paths import simplify_paths, sort_paths, join_paths, load_paths
|
||||||
from .planner import Planner
|
from .planner import Planner
|
||||||
from .turtle import Turtle
|
from .turtle import Turtle
|
||||||
from .util import draw, reset
|
from .util import draw, reset
|
||||||
|
|
||||||
|
from .hershey import text
|
||||||
|
from .hershey_fonts import (
|
||||||
|
ASTROLOGY,
|
||||||
|
CURSIVE,
|
||||||
|
CYRILC_1,
|
||||||
|
CYRILLIC,
|
||||||
|
FUTURAL,
|
||||||
|
FUTURAM,
|
||||||
|
GOTHGBT,
|
||||||
|
GOTHGRT,
|
||||||
|
GOTHICENG,
|
||||||
|
GOTHICGER,
|
||||||
|
GOTHICITA,
|
||||||
|
GOTHITT,
|
||||||
|
GREEK,
|
||||||
|
GREEKC,
|
||||||
|
GREEKS,
|
||||||
|
JAPANESE,
|
||||||
|
MARKERS,
|
||||||
|
MATHLOW,
|
||||||
|
MATHUPP,
|
||||||
|
METEOROLOGY,
|
||||||
|
MUSIC,
|
||||||
|
ROWMAND,
|
||||||
|
ROWMANS,
|
||||||
|
ROWMANT,
|
||||||
|
SCRIPTC,
|
||||||
|
SCRIPTS,
|
||||||
|
SYMBOLIC,
|
||||||
|
TIMESG,
|
||||||
|
TIMESI,
|
||||||
|
TIMESIB,
|
||||||
|
TIMESR,
|
||||||
|
TIMESRB,
|
||||||
|
)
|
||||||
|
|
|
@ -8,7 +8,7 @@ from serial.tools.list_ports import comports
|
||||||
|
|
||||||
from .planner import Planner
|
from .planner import Planner
|
||||||
|
|
||||||
TIMESLICE_MS = 20
|
TIMESLICE_MS = 15
|
||||||
|
|
||||||
MICROSTEPPING_MODE = 2
|
MICROSTEPPING_MODE = 2
|
||||||
STEP_DIVIDER = 2 ** (MICROSTEPPING_MODE - 1)
|
STEP_DIVIDER = 2 ** (MICROSTEPPING_MODE - 1)
|
||||||
|
@ -24,7 +24,7 @@ PEN_DOWN_POSITION = 40
|
||||||
PEN_DOWN_SPEED = 150
|
PEN_DOWN_SPEED = 150
|
||||||
PEN_DOWN_DELAY = 0
|
PEN_DOWN_DELAY = 0
|
||||||
|
|
||||||
ACCELERATION = 8
|
ACCELERATION = 4
|
||||||
MAX_VELOCITY = 2
|
MAX_VELOCITY = 2
|
||||||
CORNER_FACTOR = 0.001
|
CORNER_FACTOR = 0.001
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
from .hershey_fonts import *
|
||||||
|
|
||||||
|
def text(string, font=FUTURAL, spacing=0):
|
||||||
|
result = []
|
||||||
|
x = 0
|
||||||
|
for ch in string:
|
||||||
|
i = ord(ch) - 32
|
||||||
|
if i < 0 or i >= 96:
|
||||||
|
x += spacing
|
||||||
|
continue
|
||||||
|
lt, rt, coords = font[i]
|
||||||
|
for path in coords:
|
||||||
|
path = [(x + i - lt, j) for i, j in path]
|
||||||
|
if path:
|
||||||
|
result.append(path)
|
||||||
|
x += rt - lt + spacing
|
||||||
|
return result
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
||||||
|
import axi
|
||||||
|
|
||||||
|
def main():
|
||||||
|
text = 'Hello, world!'
|
||||||
|
font = axi.FUTURAL
|
||||||
|
d = axi.Drawing(axi.text(text, font))
|
||||||
|
# d = d.rotate_and_scale_to_fit(12, 8.5, step=90)
|
||||||
|
d = d.scale(0.01, 0.01)
|
||||||
|
d = d.center(12, 8.5)
|
||||||
|
d.render().write_to_png('out.png')
|
||||||
|
# axi.draw(d)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue