Home > Archive > Scheme > March 2004 > graphic
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| can some one help me?
I want to construct a cercl with 2 points , change the color of the
cercle , clear it , and name the center?????
thank you
| |
| Tim Haynes 2004-03-27, 12:25 am |
| zbidii@yahoo.fr (maya) writes:
> can some one help me?
> I want to construct a cercl with 2 points , change the color of the
> cercle , clear it , and name the center?????
If your platform is paper, install a pair of compasses and set of colouring
pens.
I think that's about as helpful as we can be given the above.
~Tim
--
16:24:31 up 107 days, 19:40, 0 users, load average: 1.72, 1.22, 0.74
piglet@stirfried.vegetable.org.uk |You should never underestimate
http://spodzone.org.uk/cesspit/ |the predictability of stupidity.
| |
| Matthias Felleisen 2004-03-27, 12:25 am |
| maya wrote:
> can some one help me?
> I want to construct a cercl with 2 points , change the color of the
> cercle , clear it , and name the center?????
> thank you
Enjoy. -- Matthias
;; Language: Beginner
;; Teachpack: draw.ss
(define-struct circle (center radius))
;; Circle = (make-circle Posn Number)
;; Posn Posn -> Circle
;; given center and point on perimeter, create a circle structure
(define (circle-create-from-two-points center peri)
(make-circle center (posn-distance center peri)))
;; Circle ColorSymbol -> true
;; to draw a circle with given color
(define (circle-draw a-circle a-color)
(draw-circle (circle-center a-circle) (circle-radius a-circle) a-color))
;; Circle -> true
;; to clear a circle with given color
(define (circle-clear a-circle)
(clear-circle (circle-center a-circle) (circle-radius a-circle)))
;; Posn Posn -> Number
;; find the distance between two Posn's
(define (posn-distance p q)
(floor
(sqrt
(+ (sqr (- (posn-x p) (posn-x q))) (sqr (- (posn-y p) (posn-y q)))))))
;; Examples/Tests:
(= 5 (posn-distance (make-posn 0 0) (make-posn 3 4)))
(= 13 (posn-distance (make-posn 0 0) (make-posn 5 12)))
(equal? (circle-create-from-two-points (make-posn 0 0) (make-posn 3 4))
(make-circle (make-posn 0 0) 5))
(equal? (circle-create-from-two-points (make-posn 100 100) (make-posn 112 105))
(make-circle (make-posn 100 100) 13))
;; Run, program, run:
(start 200 200)
(circle-draw
(circle-create-from-two-points (make-posn 100 0) (make-posn 112 105)) 'red)
(sleep-for-a-while 1)
(circle-clear
(circle-create-from-two-points (make-posn 100 0) (make-posn 112 105)))
(sleep-for-a-while 1)
(circle-draw
(circle-create-from-two-points (make-posn 100 0) (make-posn 112 105)) 'blue)
(sleep-for-a-while 1)
(stop)
|
|
|
|
|