From 421181431e17133d062cfbd672811ac5193aebe9 Mon Sep 17 00:00:00 2001 From: gurpreetsinghmatharoo Date: Mon, 9 Dec 2024 10:50:03 +0530 Subject: [PATCH 1/4] docs(general): Mark draw function pages that cannot use nine slice sprites --- .../Sprites_And_Tiles/draw_sprite_general.htm | 270 +++++++++--------- .../Sprites_And_Tiles/draw_sprite_part.htm | 5 +- .../draw_sprite_part_ext.htm | 5 +- .../Sprites_And_Tiles/draw_sprite_pos.htm | 7 +- .../Sprites_And_Tiles/draw_sprite_tiled.htm | 140 ++++----- .../draw_sprite_tiled_ext.htm | 182 ++++++------ ...function_does_not_support_nine_slicing.hts | 14 + 7 files changed, 326 insertions(+), 297 deletions(-) create mode 100644 Manual/contents/assets/snippets/This_function_does_not_support_nine_slicing.hts diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Drawing/Sprites_And_Tiles/draw_sprite_general.htm b/Manual/contents/GameMaker_Language/GML_Reference/Drawing/Sprites_And_Tiles/draw_sprite_general.htm index c76e7f231..74ba8f6db 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Drawing/Sprites_And_Tiles/draw_sprite_general.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Drawing/Sprites_And_Tiles/draw_sprite_general.htm @@ -1,140 +1,144 @@ - + - - - draw_sprite_general - - - - - - - - - - -

draw_sprite_general

-

This function combines the function draw_sprite_ext() with the function draw_sprite_part(), adding in some additional blending options so that each corner of the final sprite part can be blended with an individual colour.

-

Note that applying colours to corners may not look exactly as you expect due to how sprites are drawn. See the following example, where the image on the left is drawn with a different bottom-left colour, and the image on the right is drawn with a different bottom-right colour:

-

In each image the gradients do not seamlessly span the whole rectangle and instead seem to be split into halves. This is due to a rectangle actually being made up of two triangles, where the corner colours supplied into this function are applied to each vertex of the two triangles (hence 6 vertices at 3 per triangle). This causes the colours between the vertices to be interpolated for each triangle separately.

-

Colour blending is only recommended for the HTML5 target when WebGL is enabled, although you can still set the blending colour if it is not enabled and it will blend the sprite as normal. However all blending in this way creates a duplicate sprite which is then stored in the cache and used when required. This is far from optimal and if you use multiple colour changes it will slow down your games performance unless you activate WebGL. If you do not wish to use WebGL, then you can set the sprite cache size to try and limit this should it be necessary using the function sprite_set_cache_size().

-

This function may not work as expected when using skeleton animation sprites, and you may find that the function only draws the first frame of the default pose. You should be using the draw_skeleton_* functions instead.

-

When drawing with this function, the sprite x offset and y offset are ignored and the sprite part will be drawn with the top left corner at the specified x / y position in the room.

-

-

Syntax:

-

draw_sprite_general(sprite, subimg, left, top, width, height, x, y, xscale, yscale, rot, c1, c2, c3, c4, alpha);

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ArgumentTypeDescription
spriteSprite AssetThe sprite to draw.
subimgRealThe subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
leftRealThe x position on the sprite of the top left corner of the area to draw.
topRealThe y position on the sprite of the top left corner of the area to draw.
widthRealThe width of the area to draw.
heightRealThe height of the area to draw.
xRealThe x coordinate of where to draw the sprite.
yRealThe y coordinate of where to draw the sprite.
xscaleRealThe horizontal scaling of the sprite, as a multiplier: 1 = normal scaling, 0.5 is half etc...
yscaleRealThe vertical scaling of the sprite, as a multiplier: 1 = normal scaling, 0.5 is half etc...
rotRealThe rotation of the sprite. 0=normal, 90=turned 90 degrees counter-clockwise etc.
c1ColourThe colour with which to blend the top left area of the sprite.
c2ColourThe colour with which to blend the top right area of the sprite.
c3ColourThe colour with which to blend the bottom right area of the sprite.
c4ColourThe colour with which to blend the bottom left area of the sprite.
alphaRealThe alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).
-

-

Returns:

-

N/A

-

-

Example:

-

draw_sprite_general(sprite_index, image_index, 8, 8, sprite_width-16, sprite_height-16, x, y, 2, 0.5, 180, c_white, c_white, c_black, c_black, 1);

-

This will draw the instances assigned sprite (sprite_index) and its current frame of animation (image_index), however it will shave an 8px margin off all four sides of the sprite. It will be stretched to double its usual width but half its usual height. It will be opaque, and upside down. The top area of the sprite will be blended white and hence normal, but the bottom area will be black, meaning the sprite will go from normal to a silhouette downwards in a smooth gradient.

-

-

-

-