------------------------------------------------------------------------------------------------ -- Nom : Power_Draw / fait partie du programme Power Fractal -- -- -- -- Auteurs : Gregory Burri & Adrien Crivelli -- ------------------------------------------------------------------------------------------------ -- But : Outils de bas niveau pour le dessin a l'ecran. -- -- Comme dessiner un carre, une partie du tampon etc.. -- ------------------------------------------------------------------------------------------------ with Spider; use Spider; with Spider.Draw; use Spider.Draw; --Enfant de spider Pour gerer la couleur et le dessin with Power_Types; use Power_Types; with Power_Colors; package body Power_Draw is ------------------------------------------------------------------------------------------------ -- Nom : Dessin_Point_Fractal -- -- But : Dessiner un point de la fractal a l'ecran depuis la Matrice Tampon -- -- Parametres ---------------------------------------------------------------------------------- -- In : * les coordonnees x et y du point -- ------------------------------------------------------------------------------------------------ procedure Dessin_Point_Fractal(X, Y : Natural) is Color_Back : Spider.Draw.Tcolor; --La couleur au format spider begin -- Dessin_Point_Fractal --Copie les composantes RGB du point dans la variable au format spider Color_Back.R := Integer(Matrice_Tampon_Ecran(X, Y).R); Color_Back.G := Integer(Matrice_Tampon_Ecran(X, Y).G); Color_Back.B := Integer(Matrice_Tampon_Ecran(X, Y).b); -- Set_Color_Pen(Color_Back); --Defini la couleur du pinceau Move_To(X,Y); --Se deplace au coordonnees du point Put_Pixel; --Affiche une pixel end Dessin_Point_Fractal; ------------------------------------------------------------------------------------------------ -- Nom : Boite -- -- But : dessiner un rectangle vide a l'ecran -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : * les coordonnees du point superieur gauche : X1, Y1 -- -- * les coordonnees du point inferieur droit : X2, Y2 -- -- -- ------------------------------------------------------------------------------------------------ procedure Boite (X1, Y1, X2, Y2 : Natural; Couleur : Spider.Draw.Tcolor) is begin --Boite Spider.Draw.Set_Color_Pen(Couleur); --Dessine quatre traits pour former le rectangle Line_To(X1, Y1, X2, Y1); Line_To(X1, Y2, X2, Y2); Line_To(X1, Y1, X1, Y2); Line_To(X2, Y1, X2, Y2); -- end Boite; ------------------------------------------------------------------------------------------------ -- Nom : Ligne_Matrice_Hori -- -- But : rafraichire une ligne horizontale de l'ecran depuis le tampon -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : * La coordonnee de depart : X1 -- -- * La coordonnee de la fin : X2 -- -- * La coordonnee de positionement en Y : Y -- -- -- ------------------------------------------------------------------------------------------------ procedure Ligne_Matrice_Hori (X1, X2, Y : Natural) is --Variable temporaire X1_Tmp : Natural := X1; X2_Tmp : Natural := X2; -- Tmp : Natural; --Pour le swap de valeurs begin --Ligne_Matrice_hori --Si X1 est plus grand que X2 alors permute leur valeur if X1_Tmp > X2_Tmp then Tmp := X1_Tmp; X1_Tmp := X2_Tmp; X2_Tmp := Tmp; end if; --Boucle pour chaque point a dessiner for I in X1_Tmp..X2_Tmp loop Dessin_Point_Fractal(I, Y); --Affiche le point end loop; end Ligne_Matrice_Hori; ------------------------------------------------------------------------------------------------ -- Nom : Ligne_Matrice_Vert -- -- But : rafraichire une ligne verticale de l'ecran depuis le tampon -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : * La coordonnee de depart : Y1 -- -- * La coordonnee de la fin : Y2 -- -- * La coordonnee de positionement en X : X -- -- -- ------------------------------------------------------------------------------------------------ procedure Ligne_Matrice_Vert (Y1, Y2, X : Natural) is --Variable temporaire Y1_Tmp : Natural := Y1; Y2_Tmp : Natural := Y2; Tmp : Natural; --Pour le swap de valeurs -- begin --Ligne_Matrice_hori --Si Y1 est plus grand que Y2 alors permute leur valeur if Y1_Tmp > Y2_Tmp then Tmp := Y1_Tmp; Y1_Tmp := Y2_Tmp; Y2_Tmp := Tmp; end if; --Boucle pour chaque point a dessiner for I in Y1_Tmp..Y2_Tmp loop Dessin_Point_Fractal(X, I); end loop; end Ligne_Matrice_Vert; ------------------------------------------------------------------------------------------------ -- Nom : Dessin_Croix -- -- But : dessiner une petite croix sur l'ecran -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : Les coordonnees de la croix : X et Y -- -- -- ------------------------------------------------------------------------------------------------ procedure Dessin_Croix (X, Y : Natural) is Color_Back : Spider.Draw.Tcolor; --La couleur au format spider begin --Dessin_croix --Si la croix peut-etre dessine (il faut tenir compte de son rayon : Rayon_Ext_Croix) if X in 0 + Rayon_Ext_Croix..Largeur_Ecran - Rayon_Ext_Croix and Y in 0 + Rayon_Ext_Croix ..Hauteur_Ecran - Rayon_Ext_Croix then --Copie les composantes RGB du point dans la variable au format spider Color_Back.R := Integer(Matrice_Tampon_Ecran(X, Y).R); Color_Back.G := Integer(Matrice_Tampon_Ecran(X, Y).G); Color_Back.B := Integer(Matrice_Tampon_Ecran(X, Y).B); -- Power_Colors.Inverse_Couleur(Color_Back); --Inverse la couleur Set_Color_Pen(Color_Back); --Defini la couleur du pinceau --Trace la croix en fonction de la constante du rayon interne : Rayon_Int_Croix --et de la constante du rayon interne : Rayon_Int_Croix Line_To(X - Rayon_Ext_Croix ,Y , X - Rayon_Int_Croix , Y); Line_To(X + Rayon_Ext_Croix ,Y , X + Rayon_Int_Croix , Y); Line_To(X ,Y - Rayon_Ext_Croix , X , Y - Rayon_Int_Croix); Line_To(X ,Y + Rayon_Ext_Croix , X , Y + Rayon_Int_Croix); -- end if; end Dessin_Croix; ------------------------------------------------------------------------------------------------ -- Nom : Efface_Croix -- -- But : Effacer la croix qui a au paravant ete dessine en X, Y -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : * Les coordonnees de la croix a effacer : X, Y -- -- -- ------------------------------------------------------------------------------------------------ procedure Efface_Croix (X, Y : Natural) is begin -- Efface_Croix --Si le point xy est un point ou une croix a put etre dessine if X in 0 + Rayon_Ext_Croix..Largeur_Ecran - Rayon_Ext_Croix and Y in 0 + Rayon_Ext_Croix ..Hauteur_Ecran - Rayon_Ext_Croix then --Efface la croix, en dessinant par dessus une nouvelle croix mais par rapport au tampon Ligne_Matrice_Hori(X - Rayon_Ext_Croix, X - Rayon_Int_Croix, Y); Ligne_Matrice_Hori(X + Rayon_Ext_Croix, X + Rayon_Int_Croix, Y); Ligne_Matrice_Vert(Y - Rayon_Ext_Croix, Y - Rayon_Int_Croix, X); Ligne_Matrice_Vert(Y + Rayon_Ext_Croix, Y + Rayon_Int_Croix, X); -- end if; end Efface_Croix; end Power_Draw;