Ceci est une ancienne révision du document !
La famille de fonctions DrawingSurface vous permet de dessiner directement sur les dynamic
sprites et les arrière-plans du jeu. Vous obtenez une surface de dessin en appelant
DynamicSprite.GetDrawingSurface ou
Room.GetDrawingSurfaceForBackground,
et vous pouvez ensuite utiliser les méthodes suivantes pour dessiner sur ces surfaces.
IMPORTANT : Vous DEVEZ appeler la méthode Release
lorsque vous avez fini de dessiner sur une surface. Ceci permet à AGS de mettre à jour
les copies en cache de l'image et de les charger en mémoire vidéo si nécessaire.
(Anciennement RawClearScreen, désormais obsolète)
DrawingSurface.Clear(optional int couleur)
Remplit la surface avec la COULEUR spécifiée (correspond aux numéros dans l'onglet
Colours de l'éditeur). Le contenu en cours de la surface sera effacé.
Si vous n'entrez pas de paramètre COULEUR, ou utilisez COLOR_TRANSPARENT, la surface
deviendra entièrement transparente.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.Clear(14); surface.DrawingColor = 13; surface.DrawCircle(160,100,50); surface.Release();
rend l'arrière-plan de la pièce entièrement jaune, puis dessine un cercle rose en son milieu.
Voir aussi : DrawingSurface.DrawingColor
(Anciennement RawSaveScreen, désormais obsolète)
DrawingSurface* DrawingSurface.CreateCopy()
Crée une copie de la surface actuelle, de façon à pouvoir la récupérer
plus tard pour la restaurer. Ceci peut être utile si vous voulez faire
une copie de sauvegarde de l'arrière-plan avant de dessiner dessus,
ou pour sauvegarder une étape de votre dessin et la restaurer plus tard.
Contrairement à la commande obsolète RawSaveScreen des versions précédentes d'AGS,
les surfaces créées par cette commande ne sont pas perdues lorsque le joueur change
de pièce ou restaure une partie. Toutefois, les surfaces qui contiennent des copies
d'arrière-plans peuvent être très lourdes , occupant une grande place dans la mémoire
et peuvent significativement alourdir le jeu. Ainsi, il est fortement recommandé
d'utiliser Release sur la surface copiée dès que vous en avez fini avec elle.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); DrawingSurface *backup = surface.CreateCopy(); surface.DrawTriangle(0,0,160,100,0,200); Wait(80); surface.DrawSurface(backup); backup.Release(); surface.Release();
fera une copie de sauvegarde de l'arrière-plan de la pièce, dessinera un triangle dessus,
attendra un moment puis restaurera l'arrière-plan original.
Voir aussi : DrawingSurface.DrawSurface
(Anciennement RawDrawCircle, désormais obsolète)
DrawingSurface.DrawCircle(int x, int y, int rayon)
Dessine un cercle plein de rayon RAYON centré à (X,Y) de la couleur de dessin courante.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawCircle(160,100,50); surface.Release();
dessinera un cercle jaune au centre de l'écran, d'un rayon de 50 pixels.
Voir aussi : DrawingSurface.DrawLine,
DrawingSurface.DrawingColor
(Anciennement RawDrawImage, désormais obsolète)
(Anciennement RawDrawImageResized, désormais obsolète)
(Anciennement RawDrawImageTransparent, désormais obsolète)
DrawingSurface.DrawImage(int x, int y, int slot, optional int transparency, optional int width, optional int height)
Draws image SLOT from the sprite manager onto the surface at location (X,Y).
Optionally, you can also specify the transparency of the image. This is a number
from 0-100; using a transparency of 50 will draw the image semi-transparent;
using 0 means it will not be transparent.
You can also resize the image as you draw it. In order to do this, simply specify
a width and height that you wish to resize the image to when it is drawn.
NOTE: This command only works if the image to be drawn is the same colour
depth as the surface that you are drawing onto.
NOTE: Transparency does not work in 256-colour games, or with 256-colour sprites.
NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates.
This means that in a scrolling room you can draw outside the current visible area.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawImage(100, 100, oDoor.Graphic, 40); surface.Release();
will draw the oDoor object's graphic onto the room background at (100, 100), at 40%
transparency.
Voir aussi :
DrawingSurface.DrawLine,
DrawingSurface.DrawString,
DrawingSurface.DrawSurface,
Room.ColorDepth
(Anciennement RawDrawLine, désormais obsolète)
DrawingSurface.DrawLine(int from_x, int from_y, int to_x, int to_y, optional int thickness)
Draws a line from (FROM_X, FROM_Y) to (TO_X, TO_Y) in the surface's current drawing colour.
The thickness parameter allows you to specify how thick the line is, the default being 1 pixel.
NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates.
This means that in a scrolling room you can draw outside the current visible area.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawLine(0, 0, 160, 100); surface.Release();
will draw a line from the left top of the screen (0,0) to the middle of the screen (160,100);
Voir aussi : DrawingSurface.DrawCircle,
DrawingSurface.DrawRectangle,
DrawingSurface.DrawTriangle,
DrawingSurface.DrawingColor
(Anciennement RawPrintMessageWrapped, désormais obsolète)
DrawingSurface.DrawMessageWrapped(int x, int y, int width, FontType font, int message_number)
Draws the room message MESSAGE_NUMBER onto the surface at (x,y), using the
specified FONT.
WIDTH is the width of the virtual textbox enclosing the text, and is the point that
the text will wrap at. This command is designed for writing a long message to the
screen with it wrapping normally like a standard label would do.
The text will be printed using the current drawing colour.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawMessageWrapped(80, 40, 160, Game.NormalFont, 10); surface.Release();
will display message 10 in the centre of the screen, starting from Y = 40.
Voir aussi : DrawingSurface.DrawString,
DrawingSurface.DrawingColor,
DrawingSurface.DrawStringWrapped
DrawingSurface.DrawPixel(int x, int y)Draws a single pixel onto the surface at (X,Y) in the current colour. The pixel thickness respects the UseHighResCoordinates property.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawPixel(50, 50); surface.Release();
draws a yellow pixel in the top left of the room background
Voir aussi : DrawingSurface.DrawingColor,
DrawingSurface.DrawLine,
DrawingSurface.GetPixel,
DrawingSurface.UseHighResCoordinates
(Anciennement RawDrawRectangle, désormais obsolète)
DrawingSurface.DrawRectangle(int x1, int y1, int x2, int y2)
Draws a filled rectangle in the current colour with its top-left corner
at (x1,y1) and its bottom right corner at (x2, y2)
NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates.
This means that in a scrolling room you can draw outside the current visible area.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawRectangle(0, 0, 160, 100); surface.Release();
will draw a rectangle over the top left hand quarter of the screen.
Voir aussi : DrawingSurface.DrawImage,
DrawingSurface.DrawLine
(Anciennement RawPrint, désormais obsolète)
DrawingSurface.DrawString(int x, int y, FontType font, string text, ...)
Draws the text onto the surface at (x, y), using the supplied font number.
The text will be drawn in the current drawing colour.
You can insert the value of variables into the message. For more information,
see the string formatting section.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawString(0, 100, Game.NormalFont, "Text written into the background!"); surface.Release();
will write some text onto the middle-left of the room background
Voir aussi : GetTextWidth,
DrawingSurface.DrawStringWrapped,
DrawingSurface.DrawingColor
DrawingSurface.DrawStringWrapped(int x, int y, int width, FontType font, Alignment, const string text)Draws the text onto the surface at (x,y), using the specified FONT.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawStringWrapped(80, 40, 160, Game.NormalFont, eAlignCentre, "Hello, my name is Bob."); surface.Release();
will display the text in the centre of the screen, starting from Y = 40.
Compatibility: Supported by AGS 3.0.1 and later versions.
Voir aussi : DrawingSurface.DrawString,
DrawingSurface.DrawingColor,
DrawingSurface.DrawMessageWrapped
(Anciennement RawDrawFrameTransparent, désormais obsolète)
(Anciennement RawRestoreScreen, désormais obsolète)
DrawingSurface.DrawSurface(DrawingSurface *source, optional int transparency)
Draws the specified surface on top of this surface, optionally using transparency
percent transparency.
This allows you to perform day-to-night fading and other special effects.
NOTE: You cannot use the transparency parameter with 256-colour surfaces.
NOTE: This command can be a bit on the slow side, so don't call it from repeatedly_execute.
TIP: If you want to gradually fade in a second background, create a copy of
the original surface and then restore it after each iteration, otherwise the backgrounds
will converge too quickly.
Exemple :
DrawingSurface *mainBackground = Room.GetDrawingSurfaceForBackground(0); DrawingSurface *nightBackground = Room.GetDrawingSurfaceForBackground(1); mainBackground.DrawSurface(nightBackground, 50); mainBackground.Release(); nightBackground.Release();
this will draw background frame 1 onto frame 0 at 50% opacity.
Voir aussi : DrawingSurface.DrawImage,
SetAmbientTint
(Anciennement RawDrawTriangle, désormais obsolète)
DrawingSurface.DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
Draws a filled triangle in the current colour with corners at the points
(x1,y1), (x2,y2) and (x3,y3).
Well, don't look at me, you might find it useful for something
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawTriangle(0,0,160,100,0,200); surface.Release();
will draw a triangle with corners at the points (0,0),(160,100),(0,200).
Voir aussi : DrawingSurface.DrawImage,
DrawingSurface.DrawLine,
DrawingSurface.DrawRectangle
DrawingSurface.Release()Tells AGS that you have finished drawing onto this surface, and that AGS can now upload the changed image into video memory.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawLine(0, 0, 50, 50); surface.Release();
draws a yellow diagonal line across the top-left of the current room background,
then releases the image.
Voir aussi : DynamicSprite.GetDrawingSurface,
Room.GetDrawingSurfaceForBackground
(Anciennement RawSetColor, désormais obsolète)
int DrawingSurface.DrawingColor
Gets/sets the current drawing colour on this surface. Set this before using commands
like DrawLine, which use this colour for
their drawing.
You can set this either to an AGS Colour Number (as you'd get from the Colours pane
in the editor) or to the special constant COLOR_TRANSPARENT, which allows you
to draw transparent areas onto the surface.
Exemple :
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawingColor = 14; surface.DrawLine(0, 0, 160, 100); surface.DrawingColor = Game.GetColorFromRGB(255, 255, 255); surface.DrawLine(0, 199, 160, 100); surface.Release();
will draw a yellow line from the left top of the screen (0,0) to the middle of the screen (160,100),
and a white line from the bottom left to the middle.
Voir aussi : DrawingSurface.DrawCircle,
DrawingSurface.DrawLine,
DrawingSurface.DrawRectangle,
Game.GetColorFromRGB
int DrawingSurface.GetPixel(int x, int y)Returns the AGS Colour Number of the pixel at (X,Y) on the surface.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); Display("The colour of the middle pixel is %d.", surface.GetPixel(160, 100)); surface.Release();
displays the pixel colour of the centre pixel on the screen.
Compatibility: Supported by AGS 3.0.1 and later versions.
Voir aussi : DrawingSurface.DrawingColor,
DrawingSurface.DrawPixel,
DrawingSurface.UseHighResCoordinates
readonly int DrawingSurface.HeightGets the height of the surface.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); Display("The background is %d x %d!", surface.Width, surface.Height); surface.Release();
displays the size of the surface to the player
Voir aussi : DrawingSurface.UseHighResCoordinates,
DrawingSurface.Width
bool DrawingSurface.UseHighResCoordinatesGets/sets whether you want to use high-resolution co-ordinates with this surface.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.UseHighResCoordinates = true; surface.DrawingColor = 14; surface.DrawLine(0, 0, 320, 200); surface.Release();
draws a yellow line from the top left of the screen to the middle of the screen. If we
hadn't set UseHighResCoordinates to true, this would draw a line from the top left
to the bottom right of the screen.
Voir aussi : DrawingSurface.DrawCircle, DrawingSurface.DrawLine,
DrawingSurface.DrawRectangle,
DrawingSurface.DrawTriangle
readonly int DrawingSurface.WidthGets the width of the surface.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); Display("The background is %d x %d!", surface.Width, surface.Height); surface.Release();
displays the size of the surface to the player
Voir aussi : DrawingSurface.Height,
DrawingSurface.UseHighResCoordinates