Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
tilting box
Author Message
djlenny_3000

Posted: Tue Apr 20, 2004 6:33 pm   Post subject: tilting box

% The "tiltbox" program
% The square box of length size is tilted so that its bottom
% makes an angle theta degrees with x-axis
% The upper left corner of the box is at the center
var angle : real
put "Enter angle of tilt in degrees " ..
get angle
var size : int
put "Enter size of square box in pixels " ..
get size
var col:int
put "Enter colour " ..
get col
% Draw box
const xcenter := maxx div 2
const ycenter := maxy div 2
const c := cosd (angle)
const s := sind (angle)
const x1 := xcenter
const y1 := ycenter
const x2 := x1 + round (size * c)
const y2 := y1 - round (size * s)
const x3 := x2 + round (size * s)
const y3 := y2 + round (size * c)
const x4 := x1 + round (size * s)
const y4 := y1 + round (size * c)
drawline (x1, y1, x2, y2, col)
drawline (x2, y2, x3, y3, col)
drawline (x3, y3, x4, y4, col)
drawline (x4, y4, x1, y1, col)

BTW did i mension that this is my first time using sin and cos

Catalyst

Posted: Tue Apr 20, 2004 6:37 pm   Post subject: (No subject)

sin and cos are gr10
djlenny_3000

Posted: Tue Apr 20, 2004 6:38 pm   Post subject: (No subject)

sorry *said in VERY sarcasmic tone*
in our school i believe we r doing it in grd 11 but if its ten then my fault
Paul

Posted: Tue Apr 20, 2004 6:41 pm   Post subject: (No subject)

Hm... its cool, I don't understand it, and won't unless I look at it really carefully.
Damn grade 10 math is hard when in grade 10 (not really lol)
Check out this wacky effect using ur program, thanx !:
 code: var angle : int var size, col : int loop randint (angle, 1, 180) randint (size, 5, 200) randint (col, 12, 100) % Draw box var xcenter, ycenter: int randint (xcenter, 0, maxx) randint (ycenter, 0, maxy) const c := cosd (angle) const s := sind (angle) const x1 := xcenter const y1 := ycenter const x2 := x1 + round (size * c) const y2 := y1 - round (size * s) const x3 := x2 + round (size * s) const y3 := y2 + round (size * c) const x4 := x1 + round (size * s) const y4 := y1 + round (size * c) drawline (x1, y1, x2, y2, black) drawline (x2, y2, x3, y3, black) drawline (x3, y3, x4, y4, black) drawline (x4, y4, x1, y1, black) drawfill (x1+1, y1+1, col,black) delay (5) end loop
the_short1

Posted: Fri Apr 23, 2004 5:01 pm   Post subject: (No subject)

cool looking paul... i will add that to compilation of visuals,,,

anyways... this is a nice rendition of the question to draw a tilted box...

GOOD JOB!!!!

for mien i just used text...
 code: colorback (black) for a : 1.. 15 locate (1,a) put "                                         " end for

hehehehehhe
i cheated... but o well...
Paul

Posted: Fri Apr 23, 2004 8:58 pm   Post subject: (No subject)

short, the one u posted doesn't do anything.
the_short1

Posted: Sun Apr 25, 2004 6:51 pm   Post subject: (No subject)

oopz....

colorback (black)
for a : 1.. 15
locate (a,a)
put " "..
end for

forgot the .. and forgot to make ROW change too....

now it works..
djlenny_3000

Posted: Tue Apr 27, 2004 6:45 pm   Post subject: (No subject)

hey paul b. that's actually pretty cool i like the visual effect with the randow colors then outlines, did something like that once got 100% (but it was worth like 0.00000000000001% overall.) neways really nice i'd give bits but the weird thing is the fact that I DONT GOT NONE CMON 31 BITS ARRGH

BTW
out of pure boredom
then i saw da loch ness monsta and it says i want treefiftay
What the crap is treefiftay
tree dolla an fify cents