Skip to content

invalid default drawing: #f #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Pytheas01 opened this issue Dec 30, 2024 · 2 comments
Open

invalid default drawing: #f #27

Pytheas01 opened this issue Dec 30, 2024 · 2 comments

Comments

@Pytheas01
Copy link

Hello,
thefollowing code generates an « invalid default drawing » error in LispPad 2.1 on IPadOs 18.2:

import (lispkit draw chart bar))

(draw-bar-chart 
  (list (bar "Jan" 0) (bar "Feb" 2) (bar "Mar" 6) (bar "Apr" 9) (bar "May" 14) (bar "Jun" 16) (bar "Jul" 19) (bar "Aug" 18) (bar "Sep" 15) (bar "Oct" 11) (bar "Nov" 5) (bar "Dec" 2)) 
  gray 5 "Temperature [C°]" "Month" 
  (point 50 105) (make-bar-chart-config 'size: (size 495 200))
  (make-legend-config 'font: (font "Helvetica" 7) 'stroke-width: 0.4 'entry-pad: 5 'sample-area-width: 16 'sample-length: 8 'horizontal-offset: 50))
@objecthub
Copy link
Owner

Functions whose name starts with draw- typically draw something into a drawing that is provided optionally as the last parameter. If the last parameter is missing (like in your example), the current drawing is used instead. It is implemented via the parameter object current-drawing of library (lispkit draw).

So you have two choices here: 1) provide a drawing parameter, or 2) make sure that current-drawing refers to a valid drawing (vs. #f — which is the default).

This is how approach 1 looks like:

(import (lispkit base) (lispkit draw) (lispkit draw chart bar))
(define d (make-drawing))
(draw-bar-chart 
  (list (bar "Jan" 0) (bar "Feb" 2) (bar "Mar" 6)
        (bar "Apr" 9) (bar "May" 14) (bar "Jun" 16)
        (bar "Jul" 19) (bar "Aug" 18) (bar "Sep" 15)
        (bar "Oct" 11) (bar "Nov" 5) (bar "Dec" 2))
  gray 5 "Temperature [C°]" "Month" (point 10 0)
  (make-bar-chart-config 'size: (size 500 200))
  #f d)
(save-drawing "test.pdf" d (size 520 210))
(open-file "test.pdf")

And here's the same example using the drawing syntax which creates a new empty drawing, assigns it to current-drawing and then invokes all the statements in the body of drawing:

(import (lispkit base) (lispkit draw) (lispkit draw chart bar))
(define d
  (drawing
    (draw-bar-chart 
      (list (bar "Jan" 0) (bar "Feb" 2) (bar "Mar" 6)
            (bar "Apr" 9) (bar "May" 14) (bar "Jun" 16)
            (bar "Jul" 19) (bar "Aug" 18) (bar "Sep" 15)
            (bar "Oct" 11) (bar "Nov" 5) (bar "Dec" 2))
      gray 5 "Temperature [C°]" "Month" (point 10 0)
      (make-bar-chart-config 'size: (size 500 200))
      #f)))
(save-drawing "test.pdf" d (size 520 210))
(open-file "test.pdf")

I hope this helps.

@Pytheas01
Copy link
Author

Pytheas01 commented Dec 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants