Skip to content

Commit

Permalink
Don't draw primitives if width or height is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Mar 21, 2020
1 parent dce9019 commit 6488983
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions canvas/drawing.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
(stroke-paint nil)
(thickness 1.0)
(rounding 0.0))
(bodge-canvas:draw-rect origin w h
:fill-paint (%paint-handle-of fill-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness
:rounding rounding))
(unless (or (zerop w) (zerop h))
(bodge-canvas:draw-rect origin w h
:fill-paint (%paint-handle-of fill-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness
:rounding rounding)))


(defun draw-image (origin w h image-paint &key (stroke-paint nil)
Expand All @@ -30,15 +31,16 @@
(translate-x 0.0)
(translate-y 0.0)
(rotate 0.0))
(bodge-canvas:draw-image origin w h (%paint-handle-of image-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness
:rounding rounding
:scale-x scale-x
:scale-y scale-y
:translate-x translate-x
:translate-y translate-y
:rotate rotate))
(unless (or (zerop w) (zerop h))
(bodge-canvas:draw-image origin w h (%paint-handle-of image-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness
:rounding rounding
:scale-x scale-x
:scale-y scale-y
:translate-x translate-x
:translate-y translate-y
:rotate rotate)))


(defun draw-circle (center radius &key (fill-paint nil)
Expand All @@ -53,10 +55,11 @@
(defun draw-ellipse (center x-radius y-radius &key (fill-paint nil)
(stroke-paint nil)
(thickness 1.0))
(bodge-canvas:draw-ellipse center x-radius y-radius
:fill-paint (%paint-handle-of fill-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness))
(unless (or (zerop x-radius) (zerop y-radius))
(bodge-canvas:draw-ellipse center x-radius y-radius
:fill-paint (%paint-handle-of fill-paint)
:stroke-paint (%paint-handle-of stroke-paint)
:thickness thickness)))


(defun draw-arc (center radius a0 a1 &key (fill-paint nil)
Expand Down

0 comments on commit 6488983

Please sign in to comment.