From 7cdaaff197ac5f30d49b824062f8ce84932dcfcd Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 8 Oct 2009 14:20:04 +0000 Subject: [PATCH] an attempt to fix up the bounding boxes on ellipses svn: r16281 original commit: e87712fddacacc937f88abd26c42d054de9bfc29 --- collects/2htdp/private/image-core.ss | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/collects/2htdp/private/image-core.ss b/collects/2htdp/private/image-core.ss index f6777632..5fc6ef65 100644 --- a/collects/2htdp/private/image-core.ss +++ b/collects/2htdp/private/image-core.ss @@ -424,10 +424,19 @@ and they all have good sample contracts. (It is amazing what we can do with kids [atomic-shape (translate-shape simple-shape)]) (cond [(ellipse? atomic-shape) - (let ([path (new dc-path%)] - [θ (degrees->radians (ellipse-angle atomic-shape))]) - (send path ellipse 0 0 (ellipse-width atomic-shape) (ellipse-height atomic-shape)) + (let* ([path (new dc-path%)] + [w (ellipse-width atomic-shape)] + [h (ellipse-height atomic-shape)] + [θ (degrees->radians (ellipse-angle atomic-shape))] + [cos2 (sqr (cos θ))] + [sin2 (sqr (sin θ))] + [rotated-width (+ (* w cos2) (* h sin2))] + [rotated-height (+ (* w sin2) (* h cos2))]) + + (send path ellipse 0 0 w h) + (send path translate (- (/ w 2)) (- (/ h 2))) (send path rotate θ) + (send path translate (/ rotated-width 2) (/ rotated-height 2)) (send dc set-pen (mode-color->pen (ellipse-mode atomic-shape) (ellipse-color atomic-shape))) (send dc set-brush (mode-color->brush (ellipse-mode atomic-shape) (ellipse-color atomic-shape))) (send dc draw-path path dx dy))]