For Programmers: Free Programming Magazines  


Home > Archive > Scheme > April 2005 > need help on chex scheme graphics









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]

 

Author need help on chex scheme graphics
madman

2005-04-12, 3:59 pm

I would appreciate any help on what to put in the following code to
place points, lines, ovals, or polygons on the canvas. I know it is not
that difficult but it eludes me and i do need the imformation badly. I
have looked at the samples in the tutorial but something still doesnt
click. I think it is as below but i need the general code. i do not
want to draw with the mouse what i need to do is place a line, point,
polygon, or oval at a precise point in the canvas using the create
command and have it show me the object in the canvas. (create <line>
canvas x1 y1 x2 y2 more...) where i will compute the coordinates by
function calls.
I realize this is probably very minor to you but it is very important
to me and so i think it is something simple as below where just a few
lines need to be added. (is there a create class: point or pixel?)

(module ()
(import swl:oop)
(import swl:macros)
(import swl:generics)
(import swl:option)
(let* ([top (create <toplevel> with (title: "Canvas Example"))]
what goes here to get what I need

respectfully submitted
madmountain

Abdulaziz Ghuloum

2005-04-12, 9:00 pm

madman wrote:

> I would appreciate any help on what to put in the following code to
> place points, lines, ovals, or polygons on the canvas. I know it is not
> that difficult but it eludes me and i do need the imformation badly. I
> have looked at the samples in the tutorial but something still doesnt
> click. I think it is as below but i need the general code. i do not
> want to draw with the mouse what i need to do is place a line, point,
> polygon, or oval at a precise point in the canvas using the create
> command and have it show me the object in the canvas. (create <line>
> canvas x1 y1 x2 y2 more...) where i will compute the coordinates by
> function calls.
> I realize this is probably very minor to you but it is very important
> to me and so i think it is something simple as below where just a few
> lines need to be added. (is there a create class: point or pixel?)


Is this enough to get you started?

(module ()
(import swl:oop)
(import swl:macros)
(import swl:generics)
(import swl:option)
(define (random-color)
(make <rgb> (random 255) (random 255) (random 255)))
(let* ([top (create <toplevel> with (title: "Canvas Example"))]
[canvas
(create <canvas> top
with
(background-color: (make <rgb> 215 215 255)))]
[shapes
(list (create <rectangle> canvas 10 10 100 100)
(create <oval> canvas 100 20 300 200)
(create <polygon> canvas
10 10
30 40
70 20))])
(for-each (lambda (shape)
(set-outline-color! shape (random-color))
(show shape))
shapes)
(show canvas)
top))
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com