27 lines
821 B
Scheme
27 lines
821 B
Scheme
|
(define (draw-to-py painter name)
|
||
|
(define py-name (string-append "picture_language/" name ".py"))
|
||
|
(define img-name (string-append name ".png"))
|
||
|
(define head (string-append
|
||
|
"from PIL import Image, ImageDraw\n"
|
||
|
"im = Image.new('RGB', (1921, 1081))\n"
|
||
|
"draw = ImageDraw.Draw(im)\n"))
|
||
|
(define tail (string-append
|
||
|
"im.save('" img-name "', 'PNG')\n"))
|
||
|
(let ((port (open-output-file py-name)))
|
||
|
(define (draw-line v1 v2)
|
||
|
(define n2s number->string)
|
||
|
(display
|
||
|
(string-append
|
||
|
"draw.line(("
|
||
|
(n2s (xcor-vect v1)) ", "
|
||
|
(n2s (ycor-vect v1)) ", "
|
||
|
(n2s (xcor-vect v2)) ", "
|
||
|
(n2s (ycor-vect v2)) "), "
|
||
|
"fill=128)\n") port))
|
||
|
(display head port)
|
||
|
(painter draw-line)
|
||
|
(display tail port)
|
||
|
(close-output-port port)))
|
||
|
|
||
|
|