added isosceles-triangle
svn: r16677
|
@ -71,6 +71,7 @@ and they all have good sample contracts. (It is amazing what we can do with kids
|
|||
star
|
||||
star-polygon
|
||||
triangle
|
||||
isosceles-triangle
|
||||
text
|
||||
text/font
|
||||
|
||||
|
|
|
@ -658,6 +658,15 @@
|
|||
(make-bb w h (- h d))
|
||||
#f))))
|
||||
|
||||
(define/chk (isosceles-triangle side-length angle mode color)
|
||||
(let ([left-corner (make-polar side-length (+ (* pi 1/2) (/ (degrees->radians angle) 2)))]
|
||||
[right-corner (make-polar side-length (- (* pi 1/2) (/ (degrees->radians angle) 2)))])
|
||||
(make-a-polygon (list (make-point 0 0)
|
||||
(make-point (real-part right-corner) (imag-part right-corner))
|
||||
(make-point (real-part left-corner) (imag-part left-corner)))
|
||||
mode
|
||||
color)))
|
||||
|
||||
(define/chk (triangle side-length mode color)
|
||||
(make-polygon/star side-length 3 mode color values))
|
||||
|
||||
|
@ -681,15 +690,15 @@
|
|||
(make-polygon/star side-length 5 mode color (λ (l) (swizzle l 2))))
|
||||
|
||||
(define (make-polygon/star side-length side-count mode color adjust)
|
||||
(let ([poly (make-polygon
|
||||
(adjust (regular-polygon-points side-length side-count))
|
||||
mode
|
||||
color)])
|
||||
(make-a-polygon (adjust (regular-polygon-points side-length side-count))
|
||||
mode color))
|
||||
|
||||
(define (make-a-polygon points mode color)
|
||||
(let ([poly (make-polygon points mode color)])
|
||||
(let-values ([(l t r b) (simple-bb poly)])
|
||||
(make-image (make-translate (- l) (- t) poly)
|
||||
(make-bb (- r l) (- b t) (- b t))
|
||||
#f))))
|
||||
|
||||
(define (gcd a b)
|
||||
(cond
|
||||
[(zero? b) a]
|
||||
|
@ -798,6 +807,7 @@
|
|||
|
||||
regular-polygon
|
||||
triangle
|
||||
isosceles-triangle
|
||||
star
|
||||
star-polygon
|
||||
|
||||
|
|
|
@ -28,18 +28,18 @@
|
|||
(ellipse 20 30 "solid" "slateblue")
|
||||
(ellipse 20 10 "solid" "navy"))
|
||||
'image
|
||||
"38.png")
|
||||
(list '(frame (ellipse 20 20 "outline" "black")) 'image "37.png")
|
||||
(list '(ellipse 60 60 "solid" "blue") 'image "36.png")
|
||||
(list '(scale/xy 3 2 (ellipse 20 30 "solid" "blue")) 'image "35.png")
|
||||
(list '(ellipse 40 60 "solid" "blue") 'image "34.png")
|
||||
(list '(scale 2 (ellipse 20 30 "solid" "blue")) 'image "33.png")
|
||||
(list '(rotate 5 (rectangle 50 50 "outline" "black")) 'image "32.png")
|
||||
(list '(rotate 45 (ellipse 60 20 "solid" "olivedrab")) 'image "31.png")
|
||||
"41.png")
|
||||
(list '(frame (ellipse 20 20 "outline" "black")) 'image "40.png")
|
||||
(list '(ellipse 60 60 "solid" "blue") 'image "39.png")
|
||||
(list '(scale/xy 3 2 (ellipse 20 30 "solid" "blue")) 'image "38.png")
|
||||
(list '(ellipse 40 60 "solid" "blue") 'image "37.png")
|
||||
(list '(scale 2 (ellipse 20 30 "solid" "blue")) 'image "36.png")
|
||||
(list '(rotate 5 (rectangle 50 50 "outline" "black")) 'image "35.png")
|
||||
(list '(rotate 45 (ellipse 60 20 "solid" "olivedrab")) 'image "34.png")
|
||||
(list
|
||||
'(beside/places "baseline" (text "ijy" 18 "black") (text "ijy" 24 "black"))
|
||||
'image
|
||||
"30.png")
|
||||
"33.png")
|
||||
(list
|
||||
'(beside/places
|
||||
"center"
|
||||
|
@ -48,7 +48,7 @@
|
|||
(ellipse 20 30 "solid" "purple")
|
||||
(ellipse 20 10 "solid" "indigo"))
|
||||
'image
|
||||
"29.png")
|
||||
"32.png")
|
||||
(list
|
||||
'(beside/places
|
||||
"bottom"
|
||||
|
@ -57,7 +57,7 @@
|
|||
(ellipse 20 30 "solid" "slateblue")
|
||||
(ellipse 20 10 "solid" "navy"))
|
||||
'image
|
||||
"28.png")
|
||||
"31.png")
|
||||
(list
|
||||
'(beside
|
||||
(ellipse 20 70 "solid" "gray")
|
||||
|
@ -65,7 +65,7 @@
|
|||
(ellipse 20 30 "solid" "dimgray")
|
||||
(ellipse 20 10 "solid" "black"))
|
||||
'image
|
||||
"27.png")
|
||||
"30.png")
|
||||
(list
|
||||
'(overlay/xy
|
||||
(rectangle 10 10 "solid" "red")
|
||||
|
@ -73,7 +73,7 @@
|
|||
-10
|
||||
(rectangle 10 10 "solid" "black"))
|
||||
'image
|
||||
"26.png")
|
||||
"29.png")
|
||||
(list
|
||||
'(overlay/xy
|
||||
(rectangle 10 10 "solid" "red")
|
||||
|
@ -81,7 +81,7 @@
|
|||
10
|
||||
(rectangle 10 10 "solid" "black"))
|
||||
'image
|
||||
"25.png")
|
||||
"28.png")
|
||||
(list
|
||||
'(overlay/xy
|
||||
(rectangle 10 10 "outline" "red")
|
||||
|
@ -89,7 +89,7 @@
|
|||
0
|
||||
(rectangle 10 10 "outline" "black"))
|
||||
'image
|
||||
"24.png")
|
||||
"27.png")
|
||||
(list
|
||||
'(overlay/xy
|
||||
(ellipse 40 40 "outline" "black")
|
||||
|
@ -97,7 +97,7 @@
|
|||
25
|
||||
(ellipse 10 10 "solid" "forestgreen"))
|
||||
'image
|
||||
"23.png")
|
||||
"26.png")
|
||||
(list
|
||||
'(overlay/places
|
||||
"right"
|
||||
|
@ -107,7 +107,7 @@
|
|||
(rectangle 40 40 "solid" "red")
|
||||
(rectangle 50 50 "solid" "black"))
|
||||
'image
|
||||
"22.png")
|
||||
"25.png")
|
||||
(list
|
||||
'(overlay/places
|
||||
"middle"
|
||||
|
@ -115,7 +115,7 @@
|
|||
(rectangle 30 60 "solid" "orange")
|
||||
(ellipse 60 30 "solid" "purple"))
|
||||
'image
|
||||
"21.png")
|
||||
"24.png")
|
||||
(list
|
||||
'(overlay
|
||||
(ellipse 10 10 "solid" "red")
|
||||
|
@ -125,31 +125,34 @@
|
|||
(ellipse 50 50 "solid" "red")
|
||||
(ellipse 60 60 "solid" "black"))
|
||||
'image
|
||||
"20.png")
|
||||
"23.png")
|
||||
(list
|
||||
'(overlay
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
'image
|
||||
"19.png")
|
||||
"22.png")
|
||||
(list
|
||||
'(text/font "not really a link" 18 "blue" #f 'roman 'normal 'normal #t)
|
||||
'image
|
||||
"18.png")
|
||||
"21.png")
|
||||
(list
|
||||
'(text/font "Goodbye" 18 "indigo" #f 'modern 'italic 'normal #f)
|
||||
'image
|
||||
"17.png")
|
||||
"20.png")
|
||||
(list
|
||||
'(text/font "Hello" 24 "olive" "Gill Sans" 'swiss 'normal 'bold #f)
|
||||
'image
|
||||
"16.png")
|
||||
(list '(text "Goodbye" 36 "indigo") 'image "15.png")
|
||||
(list '(text "Hello" 24 "olive") 'image "14.png")
|
||||
(list '(star-polygon 20 10 3 "solid" "cornflowerblue") 'image "13.png")
|
||||
(list '(star-polygon 40 7 3 "outline" "darkred") 'image "12.png")
|
||||
(list '(star-polygon 40 5 2 "solid" "seagreen") 'image "11.png")
|
||||
(list '(star 40 "solid" "gray") 'image "10.png")
|
||||
"19.png")
|
||||
(list '(text "Goodbye" 36 "indigo") 'image "18.png")
|
||||
(list '(text "Hello" 24 "olive") 'image "17.png")
|
||||
(list '(star-polygon 20 10 3 "solid" "cornflowerblue") 'image "16.png")
|
||||
(list '(star-polygon 40 7 3 "outline" "darkred") 'image "15.png")
|
||||
(list '(star-polygon 40 5 2 "solid" "seagreen") 'image "14.png")
|
||||
(list '(star 40 "solid" "gray") 'image "13.png")
|
||||
(list '(isosceles-triangle 60 330 "solid" "lightseagreen") 'image "12.png")
|
||||
(list '(isosceles-triangle 60 30 "solid" "aquamarine") 'image "11.png")
|
||||
(list '(isosceles-triangle 200 170 "solid" "seagreen") 'image "10.png")
|
||||
(list '(triangle 40 "solid" "tan") 'image "9.png")
|
||||
(list '(regular-polygon 20 6 "solid" "red") 'image "8.png")
|
||||
(list '(regular-polygon 20 4 "outline" "blue") 'image "7.png")
|
||||
|
|
|
@ -73,6 +73,23 @@ Existing images can be rotated, scaled, and overlaid on top of each other.
|
|||
@image-examples[(triangle 40 "solid" "tan")]
|
||||
}
|
||||
|
||||
@defproc[(isosceles-triangle [side-length (and/c positive? real?)]
|
||||
[angle angle?]
|
||||
[mode mode?]
|
||||
[color (or/c symbol? string?)])
|
||||
image?]{
|
||||
|
||||
Creates a triangle with two equal-length sides, of length @scheme[side-length]
|
||||
where the angle between those sides is @scheme[angle]. The third
|
||||
leg is straight, horizontally. If the angle is less than
|
||||
@scheme[180], then the triangle will point up and if the @scheme[angle]
|
||||
is more, then the triangle will point down.
|
||||
|
||||
@image-examples[(isosceles-triangle 200 170 "solid" "seagreen")
|
||||
(isosceles-triangle 60 30 "solid" "aquamarine")
|
||||
(isosceles-triangle 60 330 "solid" "lightseagreen")]
|
||||
}
|
||||
|
||||
@defproc[(star [side-length (and/c real? positive?)]
|
||||
[mode mode?]
|
||||
[color (or/c symbol? string?)])
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 659 B |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 674 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 893 B |
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 121 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1000 B After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 678 B After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 865 B After Width: | Height: | Size: 1007 B |
Before Width: | Height: | Size: 865 B After Width: | Height: | Size: 1000 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.0 KiB |
BIN
collects/teachpack/2htdp/scribblings/img/39.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
collects/teachpack/2htdp/scribblings/img/40.png
Normal file
After Width: | Height: | Size: 420 B |
BIN
collects/teachpack/2htdp/scribblings/img/41.png
Normal file
After Width: | Height: | Size: 2.3 KiB |