Update ImageDraw*() functions to match arguments of Draw*() (#1156)
* Update ImageDraw*() functions to match arguments of Draw*() Updated draw functions: ImageDrawPixel() ImageDrawPixelV() ImageDrawCircle() ImageDrawCircleV() ImageDrawLine() ImageDrawLineV() ImageDrawRectangle() ImageDrawRectangleV() ImageDrawRectangleRec() * [nodepadpp] Update Notepad++ ImageDraw defintions This updates the Notepad++ definitions with the updated ImageDraw methods. * [examples] Add ImageDraw calls to textures_image_drawing * Update ImageDraw*() methods
This commit is contained in:
parent
3c3dfde3f9
commit
a025636fa1
@ -35,6 +35,11 @@ int main(void)
|
||||
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE);
|
||||
ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
|
||||
|
||||
// Draw on the image with a few image draw methods
|
||||
ImageDrawPixel(&parrots, 10, 10, RAYWHITE);
|
||||
ImageDrawCircle(&parrots, 10, 10, 5, RAYWHITE);
|
||||
ImageDrawRectangle(&parrots, 5, 20, 10, 10, RAYWHITE);
|
||||
|
||||
UnloadImage(cat); // Unload image from RAM
|
||||
|
||||
// Load custom font for frawing on image
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 410 KiB After Width: | Height: | Size: 234 KiB |
@ -982,12 +982,93 @@
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawRectangle" func="yes">
|
||||
<Overload retVal="void" descr="Draw rectangle within an image">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="int posX" />
|
||||
<Param name="int posY" />
|
||||
<Param name="int width" />
|
||||
<Param name="int height" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawRectangleV" func="yes">
|
||||
<Overload retVal="void" descr="Draw rectangle within an image (Vector version)">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Vector2 position" />
|
||||
<Param name="Vector2 size" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawRectangleRec" func="yes">
|
||||
<Overload retVal="void" descr="Draw rectangle within an image">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Rectangle rec" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawRectangleLines" func="yes">
|
||||
<Overload retVal="void" descr="Draw rectangle lines within an image">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Rectangle rec" />
|
||||
<Param name="int thick" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageClearBackground" func="yes">
|
||||
<Overload retVal="void" descr="Clear image background with given color">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawPixel" func="yes">
|
||||
<Overload retVal="void" descr="Clear image background with given color">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="int posX" />
|
||||
<Param name="int posY" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawPixelV" func="yes">
|
||||
<Overload retVal="void" descr="Clear image background with given color (Vector version)">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Vector2 position" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawCircle" func="yes">
|
||||
<Overload retVal="void" descr="Draw circle within an image">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="int centerX" />
|
||||
<Param name="int centerY" />
|
||||
<Param name="int radius" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawCircleV" func="yes">
|
||||
<Overload retVal="void" descr="Draw circle within an image (Vector version)">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Vector2 center" />
|
||||
<Param name="int radius" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawLine" func="yes">
|
||||
<Overload retVal="void" descr="Draw line within an image">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="int startPosX" />
|
||||
<Param name="int startPosY" />
|
||||
<Param name="int endPosX" />
|
||||
<Param name="int endPosY" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawLineV" func="yes">
|
||||
<Overload retVal="void" descr="Draw line within an image (Vector2 version)">
|
||||
<Param name="Image *dst" />
|
||||
<Param name="Vector2 start" />
|
||||
<Param name="Vector2 end" />
|
||||
<Param name="Color color" />
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
<KeyWord name="ImageDrawText" func="yes">
|
||||
<Overload retVal="void" descr="Draw text (default font) within an image (destination)">
|
||||
<Param name="Image *dst" />
|
||||
@ -2114,4 +2195,4 @@
|
||||
</Overload>
|
||||
</KeyWord>
|
||||
</AutoComplete>
|
||||
</NotepadPlus>
|
||||
</NotepadPlus>
|
||||
|
13
src/raylib.h
13
src/raylib.h
@ -1141,12 +1141,17 @@ RLAPI Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCo
|
||||
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
|
||||
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
|
||||
RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source)
|
||||
RLAPI void ImageDrawRectangle(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image
|
||||
RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image
|
||||
RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version)
|
||||
RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image
|
||||
RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image
|
||||
RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color
|
||||
RLAPI void ImageDrawPixel(Image *dst, Vector2 position, Color color); // Draw pixel within an image
|
||||
RLAPI void ImageDrawCircle(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image
|
||||
RLAPI void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image
|
||||
RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image
|
||||
RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)
|
||||
RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle within an image
|
||||
RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image (Vector version)
|
||||
RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image
|
||||
RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version)
|
||||
RLAPI void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination)
|
||||
RLAPI void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color); // Draw text (custom sprite font) within an image (destination)
|
||||
RLAPI void ImageFlipVertical(Image *image); // Flip image vertically
|
||||
|
@ -1987,7 +1987,19 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
|
||||
}
|
||||
|
||||
// Draw rectangle within an image
|
||||
void ImageDrawRectangle(Image *dst, Rectangle rec, Color color)
|
||||
void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color)
|
||||
{
|
||||
ImageDrawRectangleRec(dst, (Rectangle){ posX, posY, width, height }, color);
|
||||
}
|
||||
|
||||
// Draw rectangle within an image (Vector version)
|
||||
void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color)
|
||||
{
|
||||
ImageDrawRectangle(dst, position.x, position.y, size.x, size.y, color);
|
||||
}
|
||||
|
||||
// Draw rectangle within an image
|
||||
void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
|
||||
{
|
||||
// Security check to avoid program crash
|
||||
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return;
|
||||
@ -2000,40 +2012,46 @@ void ImageDrawRectangle(Image *dst, Rectangle rec, Color color)
|
||||
// Draw rectangle lines within an image
|
||||
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color)
|
||||
{
|
||||
ImageDrawRectangle(dst, (Rectangle){ rec.x, rec.y, rec.width, thick }, color);
|
||||
ImageDrawRectangle(dst, (Rectangle){ rec.x, rec.y + thick, thick, rec.height - thick*2 }, color);
|
||||
ImageDrawRectangle(dst, (Rectangle){ rec.x + rec.width - thick, rec.y + thick, thick, rec.height - thick*2 }, color);
|
||||
ImageDrawRectangle(dst, (Rectangle){ rec.x, rec.y + rec.height - thick, rec.width, thick }, color);
|
||||
ImageDrawRectangle(dst, rec.x, rec.y, rec.width, thick, color);
|
||||
ImageDrawRectangle(dst, rec.x, rec.y + thick, thick, rec.height - thick*2, color);
|
||||
ImageDrawRectangle(dst, rec.x + rec.width - thick, rec.y + thick, thick, rec.height - thick*2, color);
|
||||
ImageDrawRectangle(dst, rec.x, rec.y + rec.height - thick, rec.width, thick, color);
|
||||
}
|
||||
|
||||
// Clear image background with given color
|
||||
void ImageClearBackground(Image *dst, Color color)
|
||||
{
|
||||
ImageDrawRectangle(dst, (Rectangle){ 0.0f, 0.0f, dst->width, dst->height }, color);
|
||||
ImageDrawRectangle(dst, 0, 0, dst->width, dst->height, color);
|
||||
}
|
||||
|
||||
// Draw pixel within an image
|
||||
void ImageDrawPixel(Image *dst, Vector2 position, Color color)
|
||||
void ImageDrawPixel(Image *dst, int x, int y, Color color)
|
||||
{
|
||||
ImageDrawRectangle(dst, (Rectangle){ position.x, position.y, 1.0f, 1.0f }, color);
|
||||
ImageDrawRectangle(dst, x, y, 1, 1, color);
|
||||
}
|
||||
|
||||
// Draw pixel within an image (Vector version)
|
||||
void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
|
||||
{
|
||||
ImageDrawRectangle(dst, (int)position.x, (int)position.y, 1, 1, color);
|
||||
}
|
||||
|
||||
// Draw circle within an image
|
||||
void ImageDrawCircle(Image *dst, Vector2 center, int radius, Color color)
|
||||
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
|
||||
{
|
||||
int x = 0, y = radius, xc = (int)center.x, yc = (int)center.y;
|
||||
int x = 0, y = radius;
|
||||
int decesionParameter = 3 - 2*radius;
|
||||
|
||||
while (y >= x)
|
||||
{
|
||||
ImageDrawPixel(dst, (Vector2){ xc + x, yc + y }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc - x, yc + y }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc + x, yc - y }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc - x, yc - y }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc + y, yc + x }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc - y, yc + x }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc + y, yc - x }, color);
|
||||
ImageDrawPixel(dst, (Vector2){ xc - y, yc - x }, color);
|
||||
ImageDrawPixel(dst, centerX + x, centerY + y, color);
|
||||
ImageDrawPixel(dst, centerX - x, centerY + y, color);
|
||||
ImageDrawPixel(dst, centerX + x, centerY - y, color);
|
||||
ImageDrawPixel(dst, centerX - x, centerY - y, color);
|
||||
ImageDrawPixel(dst, centerX + y, centerY + x, color);
|
||||
ImageDrawPixel(dst, centerX - y, centerY + x, color);
|
||||
ImageDrawPixel(dst, centerX + y, centerY - x, color);
|
||||
ImageDrawPixel(dst, centerX - y, centerY - x, color);
|
||||
x++;
|
||||
|
||||
if (decesionParameter > 0)
|
||||
@ -2045,26 +2063,37 @@ void ImageDrawCircle(Image *dst, Vector2 center, int radius, Color color)
|
||||
}
|
||||
}
|
||||
|
||||
// Draw line within an image
|
||||
void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, Color color)
|
||||
// Draw circle within an image (Vector version)
|
||||
void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color)
|
||||
{
|
||||
int x1 = (int)start.x, y1 = (int)start.y, x2 = (int)end.x, y2 = (int)end.y;
|
||||
int m = 2*(y2 - y1);
|
||||
int slopeError = m - (x2 - x1);
|
||||
ImageDrawCircle(dst, (int)center.x, (int)center.y, radius, color);
|
||||
}
|
||||
|
||||
for (int x = x1, y = y1; x <= x2; x++)
|
||||
// Draw line within an image
|
||||
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
|
||||
{
|
||||
int m = 2*(endPosY - startPosY);
|
||||
int slopeError = m - (startPosY - startPosX);
|
||||
|
||||
for (int x = startPosX, y = startPosY; x <= startPosY; x++)
|
||||
{
|
||||
ImageDrawPixel(dst, (Vector2){ x, y }, color);
|
||||
ImageDrawPixel(dst, x, y, color);
|
||||
slopeError += m;
|
||||
|
||||
if (slopeError >= 0)
|
||||
{
|
||||
y++;
|
||||
slopeError -= 2*(x2 - x1);
|
||||
slopeError -= 2*(startPosY - startPosX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw line within an image (Vector version)
|
||||
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
|
||||
{
|
||||
ImageDrawLine(dst, (int)start.x, (int)start.y, (int)end.x, (int)end.y, color);
|
||||
}
|
||||
|
||||
// Draw text (default font) within an image (destination)
|
||||
void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user