aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1413

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1413  Filled-In Triangles

21/05/2006 @ 10:14
by Garfield

Anonymous



Hi

I want to draw filled-in triangles and I can't work out how to do it.

I can obviously draw outlined triangles using three LINETO statements, but how do you get a filled-in triangle?

I'm sure once you tell me I'll kick myself, but right now I'm at a loss.

Thanks.
  Post an answer  Top

[]   

StartPrevious [ 1 2 3 4 ] NextEnd

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1
--------
21/05/2006 @ 16:56
by Ktimaster

Anonymous

visitor
You may want to concider putting this into a .rsrc file... That is if you dont intend to draw it programatically
Write to Ktimaster   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2
--------
21/05/2006 @ 17:04
by Garfield

Anonymous

visitor
I do actually want to draw them programmatically.

In fact, triangles are the building blocks of just about any shape. If you can draw triangles you can draw anything - squares, pentagons, stars, even circles!

BBC Basic (this goes back some time now) used to have a command for drawing triangles for this very reason. It didn't have a command for drawing squares as you would simply draw two triangles, and there was nothing that couldn't be drawn.

Does anyone have a routine that draws a filled-in triangle? Perhaps it's something worth including in a future version of iziBasic?

Thanks.
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 3
--------
21/05/2006 @ 17:13
by bh77a

Anonymous

visitor
I have thought about this in the past but haven't tried anything yet.

If you are needing them to draw circles, you can find some sample routines for the midpoint circle algorithm and ellipses a few posts down the forum.

Have you considered looking at the Palm API to see if there might be something that could be rolled into a PP applet?
Write to bh77a   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 4
--------
21/05/2006 @ 17:18
by Ktimaster

Anonymous

visitor
Well I do have a Theory and it should work,

Rather then using 3 Line Statements you could use Just 1!!!

Line statements can be Stacked on top of each other
I am putting this in RAW form and you can design a loop to build this as a function in your Programs.(With Just 1 Line Statement)
Upside Down Triangle
LINE 50,50 to 100,50
LINE 51,51 to 99,51
LINE 52,52 to 98,52
LINE 53,53 to 97,53

etc...
Normal Triangle
LINE 50,50 to 100,50
Line 49,49 to 99,49
(I would type the code but I am away from home)
Write to Ktimaster   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 5
--------
21/05/2006 @ 17:35
by bh77a

Anonymous

visitor
Alternatively, you could try...
...

X=50:Y=20:A=20:B=70:C=70:D=70

LINE X,Y TO A,B
LINE A,B TO C,D
LINE C,D TO X,Y

WHILE A <= C
LINE X,Y TO A,B
A=A+1
WEND

...

This seems to draw a small triangle quicly. If you wanted to speed it up for a larger triangle, you could try reversing the fill process to meet it in the middle...

...
WHILE C >= A
LINE X,Y TO C,D
C=C-1
WEND
...

Hope this helps...
Write to bh77a   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 6
--------
21/05/2006 @ 17:37
by Garfield

Anonymous

visitor
OK, I see how you can use single lines to build a triangle. This is good if, again, you know what triangle you want to draw.

The only problem is, what if you're simply given three random coordinates? How do you calculate the horizontal (or vertical) lines that need to be drawn to create that triangle?
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 7
--------
21/05/2006 @ 17:46
by bh77a

Anonymous

visitor
Hi Garfield,

Check out answer #5 right before your last post. It should work with any coordinates you throw at it. :)

bh77a
Write to bh77a   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 8
--------
21/05/2006 @ 18:12
by Ktimaster

Anonymous

visitor
Nicely done bh77a That is exactly what I was thinking
Write to Ktimaster   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 9
--------
21/05/2006 @ 21:32
by Garfield

Anonymous

visitor
I may have got it wrong, but from what I can see the code in answer #5 only works if B=D.

Take the following:

X=20 : Y=20 : A=40 : B=70 : C=70 : D=40

Your code won't work with these figures.

Will it?
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 10
--------
21/05/2006 @ 21:59
by bh77a

Anonymous

visitor
You are correct, my example will only work with one side being either horizontal or vertical. I see the need for a flood fill function here...

Anyways, I will look into it a bit more and see what I can come up with. Be sure to share with us if you find the solution.
Write to bh77a   Post an answer  Top
StartPrevious [ 1 2 3 4 ] NextEnd
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^