PDA

View Full Version : scheme newbie here


ryu12341
01-12-2005, 03:02 AM
hi guys!!! i just came across this forum looking for some scheme tutorials. This site looks cool and very helpful just by looking at some other threads.

I have a problem with scheme though. I am trying to draw some a picture using scheme's graphic library (graphics.ss). The picture doesnt have to be elaborate at all, could be just a ellipse with some more ellipses as eyes or could be a square or rectangle. I tried doing some coding and all i got was a blank empty box to pop up. I looked through the help desk for some help for drawing some of these shapes and I dont understand it. Maybe some of you scheme guru's can help me out.

this is what i have for code. please dont laugh, as this is my first time using scheme.

(require (lib "graphics.ss" "graphics"))
(open-graphics)
(open-viewport "Bruce" 600 600)
((draw-ellipse viewport) 100 100 100)
(show (draw-ellipse viewport) 100 100 100)
(send a-dc draw-ellipse x y width height)
x: 100
y: 100
width: 200
height: 200

also, could you guys explain the "viewport" as I tried using it as a parameter and it says its an unidentified identifier.

ryu12341
01-13-2005, 12:21 AM
come on guys!!! i still cant get this to work. any help would be appreciated!!!

Strike
01-13-2005, 01:07 AM
It has to have a viewport to use, you're just opening one and abandoning it. Try:


(define viewport (open-viewport "Bruce" 600 600))


instead of just that original (open-viewport ...) line.

ryu12341
01-13-2005, 01:45 AM
thanks!!! i'll give it a try when im done doing some math homework. do you have any other websites for good tutorials on scheme?

Strike
01-13-2005, 04:45 AM
http://www.schemers.org/

ryu12341
01-13-2005, 06:03 PM
ok, i did the

(define (open-viewport "Bruce" 600 600))

when i try to run it, it says

draw-ellipse: expected posn as arg 0, got: 100, all args: 100 100 100 #<struct:color%>

and has this highlighted

((draw-ellipse viewport) 100 100 100)

does it want a 100 in the draw-eclipse?

(i.e draw-ecllipse viewport 100) 100 100)

here is my code. im so confused
:(

(require (lib "graphics.ss" "graphics"))
(open-graphics)
(define viewport(open-viewport "Bruce" 600 600))
((draw-ellipse viewport) 100 100 100)
(show (draw-ellipse viewport) 100 100 100)
(send a-dc draw-ellipse x y width height)
x: 100
y: 100
width: 200
height: 200

ryu12341
01-17-2005, 10:33 PM
sweet!!! i finally finished my ghetto picture :). i have one more question, how do i enter text in with the picture?

so far, here is my code. im not sure where or how to enter text in so it appears with my picture.

;;To start, must use the (require (lib "graphics.ss" "graphics")) to get to the viewport graphics library.
(require (lib "graphics.ss" "graphics"))

;; This opens the library's graphics routines, it is initialized.
(open-graphics)

;; Defines and opens up a viewport that is 600 width x 600 height pixels.
(define w (open-viewport "Bruce" 600 600))

;; Draws a solid ellipse that is red.
((draw-solid-ellipse w) (make-posn 100 150) 400 400 (make-rgb 1 0 0))

;; Draws the black nose in the middle.
((draw-solid-ellipse w) (make-posn 280 330) 50 50)

;; Draws the line across the lips.
((draw-line w) (make-posn 400 500) (make-posn 200 500))

;; Draws the two eyeballs here.
((draw-solid-ellipse w) (make-posn 180 250) 20 20)

((draw-solid-ellipse w) (make-posn 400 250) 20 20)

;; Draws a solid blue rectange for this guys hat.
((draw-solid-rectangle w) (make-posn 155 0) 300 200 (make-rgb 0 0 1))

;; Draws the circular part of the lips.
((draw-ellipse w) (make-posn 200 480) 200 50)

any help would be greatly appreaciated!!!

zachogden
01-18-2005, 07:04 AM
I'm no schemer, but I will tell you that for future reference, enclose your code in [ code] and [/ code] tags, without the spaces of course.

ryu12341
01-18-2005, 06:56 PM
sorry, im new to the language and to the forums. thanks for the tip.

zachogden
01-18-2005, 08:54 PM
No problem. People do it all the time.