I'm new to Pollen/Racket and I'm working on converting a small book project to an e-book as practice. The book is text and image, so I've been playing around with the pict and 2htdp libraries to draw the images for each page.
The drawings are based on a shared library of simple geometric shapes, so I thought I could define all of the components and color palette in pollen.rkt and then call the ones I need in my
html.pm pages (it's a long list for the entire book). I keep hitting a contract violation when I run the pages, and not sure why—tbh, contracts and how to troubleshoot them is a little out of my wheelhouse right now.
Any help is appreciated—thanks.
pollen,rkt:
#lang racket/base
(require (prefix-in htdp: 2htdp/image)
lang/posn
pict
racket/class pict)
; primary shape
(define rect (filled-rectangle 152 178))
(define bar-x (filled-rectangle 154 8))
(define bar-y (filled-rectangle 8 180))
; secondary shapes
(define half-moon (clip-ascent (filled-ellipse 75 75)))
(define patch (filled-rectangle 73 83))
; spacers
(define gutter 15)
(define deg 0.2)
; the color palette
(define orange (list 255 102 51))
(define purple (list 38 13 38))
(define green (list 10 41 26))
(provide pict-as-png)
(define (pict-as-png pict)
(let ([png-name (format "~a.png" (gensym))])
(send (pict->bitmap pict) save-file png-name 'png)
`(img ((src ,png-name)))))
#lang pollen
◊(pict-as-png
(hbl-append ◊|gutter|
(shear (colorize ◊|rect| ◊|orange|) 0 ◊|deg|)
(shear (colorize ◊|rect| ◊|orange|) 0 -0.2))
)
pict->bitmap: contract violation
expected: pict-convertible?
given: '(hbl-append 15 (shear (colorize #<procedure:pollen-tag:filled-rectangle> "orange") 0 0.2) (shear (colorize #<procedure:pollen-tag:filled-rectangle> "orange") 0 -0.2))
...
contract from: <pkgs>/pict-lib/pict/main.rkt