4 Commits

3 changed files with 57 additions and 10 deletions

View File

@ -16,7 +16,6 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
[![GitHub Stars](https://img.shields.io/github/stars/raysan5/raylib?style=flat&label=stars)](https://github.com/raysan5/raylib/stargazers)
[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/6.0)](https://github.com/raysan5/raylib/commits/master)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/raysan5?label=sponsors)](https://github.com/sponsors/raysan5)
[![Packaging Status](https://repology.org/badge/tiny-repos/raylib.svg)](https://repology.org/project/raylib/versions)
[![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE)
[![Discord Members](https://img.shields.io/discord/426912293134270465.svg?label=Discord&logo=discord)](https://discord.gg/raylib)

View File

@ -1358,6 +1358,9 @@ void PollInputEvents(void)
// Reset key repeats
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
// Register previous mouse states
for (int i = 0; i < MAX_MOUSE_BUTTONS; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
// Reset last gamepad button/axis registered state
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
//CORE.Input.Gamepad.axisCount = 0;

View File

@ -3965,7 +3965,8 @@ void ImageDrawRectangleLinesEx(Image *dst, Rectangle rec, int thick, Color color
// Draw rectangle with gradient colors within an image, counter-clockwise color order
void ImageDrawRectangleGradientEx(Image *dst, Rectangle rec, Color col1, Color col2, Color col3, Color col4)
{
if ((dst == NULL) || (rec.width <= 0) || (rec.height <= 0)) return;
// Security checks to avoid program crash
if ((dst == NULL) || (dst->data == NULL) || (rec.width <= 0) || (rec.height <= 0)) return;
int x0 = (int)floorf(rec.x);
int y0 = (int)floorf(rec.y);
@ -4079,7 +4080,51 @@ void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color)
// Draw a gradient-filled circle within an image
void ImageDrawCircleGradient(Image *dst, Vector2 center, float radius, Color inner, Color outer)
{
// TODO: NEW: Implement ImageDrawCircleGradient()
// Security checks to avoid program crash
if ((dst == NULL) || (dst->data == NULL) || (radius <= 0.0f)) return;
int x0 = (int)floorf(center.x - radius);
int y0 = (int)floorf(center.y - radius);
int x1 = (int)ceilf(center.x + radius);
int y1 = (int)ceilf(center.y + radius);
// Limit drawing to image bounds
if (x0 < 0) x0 = 0;
if (y0 < 0) y0 = 0;
if (x1 > dst->width) x1 = dst->width;
if (y1 > dst->height) y1 = dst->height;
if ((x0 >= x1) || (y0 >= y1)) return;
float radiusSq = radius*radius;
for (int y = y0; y < y1; y++)
{
for (int x = x0; x < x1; x++)
{
// Center relative to circle center
float dx = (x + 0.5f) - center.x;
float dy = (y + 0.5f) - center.y;
float distSq = dx*dx + dy*dy;
// Skip pixels outside the circle
if (distSq > radiusSq) continue;
// Linear interpolation from inner to outer color
// TODO: Consider other types of interpolation for better results?
float t = sqrtf(distSq)/radius;
Color color = {
(unsigned char)(inner.r + (outer.r - inner.r)*t),
(unsigned char)(inner.g + (outer.g - inner.g)*t),
(unsigned char)(inner.b + (outer.b - inner.b)*t),
(unsigned char)(inner.a + (outer.a - inner.a)*t)
};
// NOTE: Pixel format conversion managed by ImageDrawPixel()
ImageDrawPixel(dst, x, y, color);
}
}
}
// Draw an image within an image
@ -4107,8 +4152,8 @@ void ImageDrawImageRec(Image *dst, Image src, Rectangle srcRec, Vector2 position
// TODO: REVIEW: ImageDrawImagePro(), implement origin and rotation for image drawing
void ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Vector2 origin, float rotation, Color tint)
{
// Security check to avoid program crash
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0) ||
// Security checks to avoid program crash
if ((dst == NULL) || (dst->data == NULL) || (dst->width == 0) || (dst->height == 0) ||
(src.data == NULL) || (src.width == 0) || (src.height == 0)) return;
if (dst->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image drawing not supported for compressed formats");
@ -4170,7 +4215,7 @@ void ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec
Color colSrc = { 0 };
Color colDst = { 0 };
Color blend = { 0 };
Color colBlend = { 0 };
bool blendRequired = true;
// Fast path: Avoid blend if source has no alpha to blend
@ -4208,10 +4253,10 @@ void ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec
colDst = GetPixelColor(pDst, dst->format);
// Fast path: Avoid blend if source has no alpha to blend
if (blendRequired) blend = ColorAlphaBlend(colDst, colSrc, tint);
else blend = colSrc;
if (blendRequired) colBlend = ColorAlphaBlend(colDst, colSrc, tint);
else colBlend = colSrc;
SetPixelColor(pDst, blend, dst->format);
SetPixelColor(pDst, colBlend, dst->format);
pDst += bytesPerPixelDst;
pSrc += bytesPerPixelSrc;
@ -4674,7 +4719,7 @@ void DrawTexture(Texture2D texture, int posX, int posY, Color tint)
// Draw a texture with position defined as Vector2
void DrawTextureV(Texture2D texture, Vector2 position, Color tint)
{
DrawTextureEx(texture, position, 0, 1.0f, tint);
DrawTextureEx(texture, position, 0.0f, 1.0f, tint);
}
// Draw a texture with rotation and scale