Je suis avec VB 6 pro et je cherche à tracer des polygones et à les remplir
d'une "certaine" couleur.
Pour un carré ou rectangle c'est line (x,y)-(x,y),couleur, BF
Pour un cercle idem facile.
Mais pour un losange ou autre parallélépipède comment fait-on, je sais le
tracer avec line, mais après pour le remplir d'une certaine couleur ?
Je suis avec VB 6 pro et je cherche à tracer des polygones et à les
remplir
d'une "certaine" couleur. Pour un carré ou rectangle c'est line (x,y)-(x,y),couleur, BF Pour un cercle idem facile.
Mais pour un losange ou autre parallélépipède comment fait-on, je sais le tracer avec line, mais après pour le remplir d'une certaine couleur ?
Merci de votre aide.
Jark
Le code qui suit est en Basic, mais sa logique est indépendante du langage. Antoni Gual est un des maîtres de Quick-Basic, son module est un des plus performants en langage clair (sans ASM donc).
Pour en voir une application dans un programme complet, vous pouvez charger TC-Draw, programme complet type MS- Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%) ' This flood-fill algorithm was adapted from a program by Antoni Gual ' who adapted it from Paul Heckbert's C code in Graphics Gems
' Retrieve the data from a previous filled line and jump to the bottom line dy% = Stack%(Sp2%, 4) y% = Stack%(Sp2%, 3) + dy% x1% = Stack%(Sp2%, 1) x2 = Stack%(Sp2%, 2) Sp2% = Sp2% + 1 IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a point of it ' must be filled. Try points left of the left side of the previous line: ' Get a left side x% = x1% WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% - 1: WEND IF x% >= x1% THEN GOTO Skip L% = x% + 1
' Store this part as filled IF L% < x1% THEN Stack%(Sp%, 3) = y% Stack%(Sp%, 1) = L% Stack%(Sp%, 2) = x1% - 1 Stack%(Sp%, 4) = -dy% Sp% = Sp% + 1 IF Sp% > StackSize% THEN Sp% = 0 END IF
x% = x1% + 1 DO WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue% FOR i% = L% TO x% - 1 Pset24 i%, y% NEXT i%
Le code qui suit est en Basic, mais sa logique est
indépendante du langage. Antoni Gual est un des maîtres de
Quick-Basic, son module est un des plus performants en
langage clair (sans ASM donc).
Pour en voir une application dans un programme complet,
vous pouvez charger TC-Draw, programme complet type MS-
Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%)
' This flood-fill algorithm was adapted from a program by
Antoni Gual
' who adapted it from Paul Heckbert's C code in Graphics
Gems
' Retrieve the data from a previous filled line and jump
to the bottom line
dy% = Stack%(Sp2%, 4)
y% = Stack%(Sp2%, 3) + dy%
x1% = Stack%(Sp2%, 1)
x2 = Stack%(Sp2%, 2)
Sp2% = Sp2% + 1
IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a
point of it
' must be filled. Try points left of the left side of the
previous line:
' Get a left side
x% = x1%
WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%)
= 1: x% = x% - 1: WEND
IF x% >= x1% THEN GOTO Skip
L% = x% + 1
' Store this part as filled
IF L% < x1% THEN
Stack%(Sp%, 3) = y%
Stack%(Sp%, 1) = L%
Stack%(Sp%, 2) = x1% - 1
Stack%(Sp%, 4) = -dy%
Sp% = Sp% + 1
IF Sp% > StackSize% THEN Sp% = 0
END IF
x% = x1% + 1
DO
WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%,
BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue%
FOR i% = L% TO x% - 1
Pset24 i%, y%
NEXT i%
Le code qui suit est en Basic, mais sa logique est indépendante du langage. Antoni Gual est un des maîtres de Quick-Basic, son module est un des plus performants en langage clair (sans ASM donc).
Pour en voir une application dans un programme complet, vous pouvez charger TC-Draw, programme complet type MS- Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%) ' This flood-fill algorithm was adapted from a program by Antoni Gual ' who adapted it from Paul Heckbert's C code in Graphics Gems
' Retrieve the data from a previous filled line and jump to the bottom line dy% = Stack%(Sp2%, 4) y% = Stack%(Sp2%, 3) + dy% x1% = Stack%(Sp2%, 1) x2 = Stack%(Sp2%, 2) Sp2% = Sp2% + 1 IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a point of it ' must be filled. Try points left of the left side of the previous line: ' Get a left side x% = x1% WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% - 1: WEND IF x% >= x1% THEN GOTO Skip L% = x% + 1
' Store this part as filled IF L% < x1% THEN Stack%(Sp%, 3) = y% Stack%(Sp%, 1) = L% Stack%(Sp%, 2) = x1% - 1 Stack%(Sp%, 4) = -dy% Sp% = Sp% + 1 IF Sp% > StackSize% THEN Sp% = 0 END IF
x% = x1% + 1 DO WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue% FOR i% = L% TO x% - 1 Pset24 i%, y% NEXT i%
Pour ceux que ça interresse et qui voudraient des explications complementaire, il existe un exellent livre de Rémy Malgouyres au éditions DUNOD "Algorithmes pour la synthese d'images et l'animation 3D" Les premiers chapitres traitant de la 2D, notamment le remplissage des polygones.
Christophe Vergon
"Jark" a écrit dans le message de news: 03c701c3d83f$8802a5c0$ Le code qui suit est en Basic, mais sa logique est indépendante du langage. Antoni Gual est un des maîtres de Quick-Basic, son module est un des plus performants en langage clair (sans ASM donc).
Pour en voir une application dans un programme complet, vous pouvez charger TC-Draw, programme complet type MS- Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%) ' This flood-fill algorithm was adapted from a program by Antoni Gual ' who adapted it from Paul Heckbert's C code in Graphics Gems
' Retrieve the data from a previous filled line and jump to the bottom line dy% = Stack%(Sp2%, 4) y% = Stack%(Sp2%, 3) + dy% x1% = Stack%(Sp2%, 1) x2 = Stack%(Sp2%, 2) Sp2% = Sp2% + 1 IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a point of it ' must be filled. Try points left of the left side of the previous line: ' Get a left side x% = x1% WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% - 1: WEND IF x% >= x1% THEN GOTO Skip L% = x% + 1
' Store this part as filled IF L% < x1% THEN Stack%(Sp%, 3) = y% Stack%(Sp%, 1) = L% Stack%(Sp%, 2) = x1% - 1 Stack%(Sp%, 4) = -dy% Sp% = Sp% + 1 IF Sp% > StackSize% THEN Sp% = 0 END IF
x% = x1% + 1 DO WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue% FOR i% = L% TO x% - 1 Pset24 i%, y% NEXT i%
Pour ceux que ça interresse et qui voudraient des explications
complementaire, il existe un exellent livre de Rémy Malgouyres au éditions
DUNOD "Algorithmes pour la synthese d'images et l'animation 3D"
Les premiers chapitres traitant de la 2D, notamment le remplissage des
polygones.
Christophe Vergon
"Jark" <mandelbrot.dazibao@free.fr> a écrit dans le message de news:
03c701c3d83f$8802a5c0$a501280a@phx.gbl...
Le code qui suit est en Basic, mais sa logique est
indépendante du langage. Antoni Gual est un des maîtres de
Quick-Basic, son module est un des plus performants en
langage clair (sans ASM donc).
Pour en voir une application dans un programme complet,
vous pouvez charger TC-Draw, programme complet type MS-
Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%)
' This flood-fill algorithm was adapted from a program by
Antoni Gual
' who adapted it from Paul Heckbert's C code in Graphics
Gems
' Retrieve the data from a previous filled line and jump
to the bottom line
dy% = Stack%(Sp2%, 4)
y% = Stack%(Sp2%, 3) + dy%
x1% = Stack%(Sp2%, 1)
x2 = Stack%(Sp2%, 2)
Sp2% = Sp2% + 1
IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a
point of it
' must be filled. Try points left of the left side of the
previous line:
' Get a left side
x% = x1%
WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%)
= 1: x% = x% - 1: WEND
IF x% >= x1% THEN GOTO Skip
L% = x% + 1
' Store this part as filled
IF L% < x1% THEN
Stack%(Sp%, 3) = y%
Stack%(Sp%, 1) = L%
Stack%(Sp%, 2) = x1% - 1
Stack%(Sp%, 4) = -dy%
Sp% = Sp% + 1
IF Sp% > StackSize% THEN Sp% = 0
END IF
x% = x1% + 1
DO
WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%,
BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue%
FOR i% = L% TO x% - 1
Pset24 i%, y%
NEXT i%
Pour ceux que ça interresse et qui voudraient des explications complementaire, il existe un exellent livre de Rémy Malgouyres au éditions DUNOD "Algorithmes pour la synthese d'images et l'animation 3D" Les premiers chapitres traitant de la 2D, notamment le remplissage des polygones.
Christophe Vergon
"Jark" a écrit dans le message de news: 03c701c3d83f$8802a5c0$ Le code qui suit est en Basic, mais sa logique est indépendante du langage. Antoni Gual est un des maîtres de Quick-Basic, son module est un des plus performants en langage clair (sans ASM donc).
Pour en voir une application dans un programme complet, vous pouvez charger TC-Draw, programme complet type MS- Paint en SVGA sous QB :
http://www.zarbi27.com/apophis/
SUB Fill24 (x0%, y0%) ' This flood-fill algorithm was adapted from a program by Antoni Gual ' who adapted it from Paul Heckbert's C code in Graphics Gems
' Retrieve the data from a previous filled line and jump to the bottom line dy% = Stack%(Sp2%, 4) y% = Stack%(Sp2%, 3) + dy% x1% = Stack%(Sp2%, 1) x2 = Stack%(Sp2%, 2) Sp2% = Sp2% + 1 IF Sp2% > StackSize% THEN Sp2% = 0
' Any point in the bottom line in contact with at least a point of it ' must be filled. Try points left of the left side of the previous line: ' Get a left side x% = x1% WHILE x% > -1 AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% - 1: WEND IF x% >= x1% THEN GOTO Skip L% = x% + 1
' Store this part as filled IF L% < x1% THEN Stack%(Sp%, 3) = y% Stack%(Sp%, 1) = L% Stack%(Sp%, 2) = x1% - 1 Stack%(Sp%, 4) = -dy% Sp% = Sp% + 1 IF Sp% > StackSize% THEN Sp% = 0 END IF
x% = x1% + 1 DO WHILE x% <= MaxX% AND CompCol%(x%, y%, BRed%, BGreen%, BBlue%) = 1: x% = x% + 1: WEND
RGB DrawRed%, DrawGreen%, DrawBlue% FOR i% = L% TO x% - 1 Pset24 i%, y% NEXT i%