Implement till 2.50 and visualize picture language via pil
This commit is contained in:
26
picture_language/draw.scm
Normal file
26
picture_language/draw.scm
Normal file
@@ -0,0 +1,26 @@
|
||||
(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)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user