aldweb

Fermer I. aldweb

Fermer II. Gratuitiels PC

Fermer III. Gratuitiels Palm

Fermer IV. Partagiciels Palm

Fermer V. iziBasic Palm

Fermer VI. Connaissance Palm

Fermer VII. Ordinateur Poche

Fermer VIII. miniPortail

Spécial !



Version mobile
de l'aldweb Site

m.aldweb.com


Ni Français, ni Anglais ?

Essayez donc l'un de ces drapeaux :
[de] [es] [it] [pt]
Recherche




Météo / Spam / www

Météo Lyon


aldweb contre le SPAM


Newsletter
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
298 Abonnés
Sites web de la famille

Webmaster - Infos
News Amis
Visites

   visiteurs

   visiteurs en ligne

Sondage
Comment trouve-tu le nouvel habillage de l'aldweb Site ?
 
Superbe !
Joli
Moyen
Moche...
Résultats
forum.gifForum - iziBasic - Sujet n°1413

Forum - Forum
iziBasic - iziBasic


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

actif  Sujet n° 1413  Filled-In Triangles

le 21/05/2006 @ 10:14
par Garfield

Anonyme



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.
  Poster une réponse  Haut

[]   

DébutPrécédent [ 1 2 3 4 ] SuivantFin

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

Anonyme

visiteur
You may want to concider putting this into a .rsrc file... That is if you dont intend to draw it programatically
Ecrire à Ktimaster   Poster une réponse  Haut

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

Anonyme

visiteur
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.
  Poster une réponse  Haut

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

Anonyme

visiteur
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?
Ecrire à bh77a   Poster une réponse  Haut

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

Anonyme

visiteur
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)
Ecrire à Ktimaster   Poster une réponse  Haut

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

Anonyme

visiteur
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...
Ecrire à bh77a   Poster une réponse  Haut

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

Anonyme

visiteur
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?
  Poster une réponse  Haut

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

Anonyme

visiteur
Hi Garfield,

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

bh77a
Ecrire à bh77a   Poster une réponse  Haut

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

Anonyme

visiteur
Nicely done bh77a That is exactly what I was thinking
Ecrire à Ktimaster   Poster une réponse  Haut

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

Anonyme

visiteur
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?
  Poster une réponse  Haut

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

Anonyme

visiteur
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.
Ecrire à bh77a   Poster une réponse  Haut
DébutPrécédent [ 1 2 3 4 ] SuivantFin
actif sujet actif   clos sujet clos   Important! Important!   Nouveau Nouveau message   -   Rectifier Rectifier message   Clôturer Clôturer sujet   Remonter Remonter
[]
Catégories de discussion  Forum 



 
^ Haut ^