Hello.
i'm tring to code a basic paint program.
i put a sprite as background. On the sprite image : a big white zone to draw, on the right side some 'buttons' (to choose the point size and the colour).
Next i use the function DrawEllipse ... but ... my coloured point disapear immediatly !
1) How to keep the 'render display and drawing on it !
2) How to capture only the draw zone and save the image as a png file.
Many thanks.
Global Sprite_fond_jeu_dessin as Integer
Global Couleur_dessin as Integer
Global Taille_point_dessin as Integer
Type ZoneType
Id as Integer
x as Integer
y as Integer
Largeur as Integer
Hauteur as Integer
EndType
Global Dessin_tableau_zones as ZoneType[]
Global Etat_jeu_dessin as Integer
Function Ajouter_zone (Id as Integer, Texte as String, x as Integer, y as Integer, Largeur as Integer, Hauteur as Integer)
Local z as ZoneType
z.Id = Id
z.x = x
z.y = y
z.Largeur = Largeur
z.Hauteur = Hauteur
Dessin_tableau_zones.Insert (z)
Endfunction
Function Charger_jeu_dessin()
Local Image as Integer
Image = loadimage ("jeu_dessiner.png")
Sprite_fond_jeu_dessin = CreateSprite (Image)
SetSpritePosition (Sprite_fond_jeu_dessin, 0,0)
Ajouter_zone (1,"Point1", 1402,95,81,50)
Ajouter_zone (2,"Point2", 1402,155,81,50)
Ajouter_zone (3,"Point3", 1402,225,81,50)
Ajouter_zone (4,"Point4", 1502,95,81,50)
Ajouter_zone (5,"Point5", 1502,155,81,50)
Ajouter_zone (6,"Point6", 1502,225,81,50)
Ajouter_zone (7, "Rouge", 1402,362,80,55)
Ajouter_zone (8, "Bleu", 1402,430,80,55)
Ajouter_zone (9, "Magenta", 1402,492,80,55)
Ajouter_zone (10, "Noir", 1402,562,80,55)
Ajouter_zone (11, "Vert", 1492,362,80,55)
Ajouter_zone (12, "Jaune", 1492,430,80,55)
Ajouter_zone (13, "Cyan", 1492,492,80,55)
Ajouter_zone (14, "Blanc", 1492,562,80,55)
Ajouter_zone (15, "Effacer", 1402,643,280,66)
Ajouter_zone (16, "Enregistrer", 1402,733,280,66)
Ajouter_zone (17, "Quitter", 1402,817,280,66)
Taille_point_dessin = 4
Couleur_dessin = MakeColor (0,0,0)
EndFunction
Function Tester_zone(x as Integer, y as Integer)
Local i as Integer
Local Id as Integer
Id = -1
For i=0 to Dessin_tableau_zones.Length
if x > Dessin_tableau_zones[i].x and x < Dessin_tableau_zones[i].x + Dessin_tableau_zones[i].Largeur
if y > Dessin_tableau_zones[i].y and y < Dessin_tableau_zones[i].y + Dessin_tableau_zones[i].Hauteur
Id = Dessin_tableau_zones[i].Id
ExitFunction Id
endif
endif
Next
EndFunction Id
Function Jouer_jeu_dessin()
Local x as Integer
Local y as Integer
Local Id as Integer
x = GetPointerX()
y = GetPointerY()
if x > 1400
if GetPointerPressed()
Id = Tester_zone(x,y)
log ("Id=" + str(Id))
if Id <> -1
select Id
case 1
Taille_point_dessin = 4
endcase
case 2
Taille_point_dessin = 8
endcase
case 3
Taille_point_dessin = 12
endcase
case 4
Taille_point_dessin = 16
endcase
case 5
Taille_point_dessin = 24
endcase
case 6
Taille_point_dessin = 34
endcase
case 7
Couleur_dessin = MakeColor (255,0,0)
endcase
case 8
Couleur_dessin = MakeColor (0,0,255)
endcase
case 9
Couleur_dessin = MakeColor (255,0,255)
endcase
case 10
Couleur_dessin = MakeColor (0,0,0)
endcase
case 11
Couleur_dessin = MakeColor (0,255,0)
endcase
case 12
Couleur_dessin = MakeColor (255,255,0)
endcase
case 13
Couleur_dessin = MakeColor (0,255,255)
endcase
case 14
Couleur_dessin = MakeColor (255,255,255)
endcase
case 17
Etat_jeu_dessin = JEU_QUITTER
endcase
endselect
else
endif
endif
else
if GetPointerPressed()
DrawEllipse (x,y, Taille_point_dessin, Taille_point_dessin, Couleur_dessin, Couleur_dessin, TRUE)
endif
endif
EndFunction
Function Liberer_jeu_dessin()
DeleteSprite (Sprite_fond_jeu_dessin)
EndFunction
Function Jouer_jeu_deux()
log ("JEU DEUX")
Charger_jeu_dessin()
Etat_jeu_dessin = JEU_DEBUT_NIVEAU
log ("Jeu quitter=" + str(JEU_QUITTER))
repeat
Jouer_jeu_dessin()
Print( ScreenFPS() )
Sync()
until Etat_jeu_dessin = JEU_QUITTER
Liberer_jeu_dessin()
endfunction