Merge branch 'raysan5:master' into master
This commit is contained in:
commit
b572b1e816
3 changed files with 4184 additions and 1756 deletions
|
|
@ -20,6 +20,9 @@
|
|||
#define MARGIN_SIZE 8 // Size for the margins
|
||||
#define COLOR_SIZE 16 // Size of the color select buttons
|
||||
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
|
||||
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
@ -168,3 +171,86 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
|
||||
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
|
||||
{
|
||||
if ((texture.id <= 0) || (scale <= 0.0f)) return; // Wanna see a infinite loop?!...just delete this line!
|
||||
if ((source.width == 0) || (source.height == 0)) return;
|
||||
|
||||
int tileWidth = (int)(source.width*scale), tileHeight = (int)(source.height*scale);
|
||||
if ((dest.width < tileWidth) && (dest.height < tileHeight))
|
||||
{
|
||||
// Can fit only one tile
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
|
||||
(Rectangle){dest.x, dest.y, dest.width, dest.height}, origin, rotation, tint);
|
||||
}
|
||||
else if (dest.width <= tileWidth)
|
||||
{
|
||||
// Tiled vertically (one column)
|
||||
int dy = 0;
|
||||
for (;dy+tileHeight < dest.height; dy += tileHeight)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, source.height}, (Rectangle){dest.x, dest.y + dy, dest.width, (float)tileHeight}, origin, rotation, tint);
|
||||
}
|
||||
|
||||
// Fit last tile
|
||||
if (dy < dest.height)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
|
||||
(Rectangle){dest.x, dest.y + dy, dest.width, dest.height - dy}, origin, rotation, tint);
|
||||
}
|
||||
}
|
||||
else if (dest.height <= tileHeight)
|
||||
{
|
||||
// Tiled horizontally (one row)
|
||||
int dx = 0;
|
||||
for (;dx+tileWidth < dest.width; dx += tileWidth)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)dest.height/tileHeight)*source.height}, (Rectangle){dest.x + dx, dest.y, (float)tileWidth, dest.height}, origin, rotation, tint);
|
||||
}
|
||||
|
||||
// Fit last tile
|
||||
if (dx < dest.width)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
|
||||
(Rectangle){dest.x + dx, dest.y, dest.width - dx, dest.height}, origin, rotation, tint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tiled both horizontally and vertically (rows and columns)
|
||||
int dx = 0;
|
||||
for (;dx+tileWidth < dest.width; dx += tileWidth)
|
||||
{
|
||||
int dy = 0;
|
||||
for (;dy+tileHeight < dest.height; dy += tileHeight)
|
||||
{
|
||||
DrawTexturePro(texture, source, (Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, (float)tileHeight}, origin, rotation, tint);
|
||||
}
|
||||
|
||||
if (dy < dest.height)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
|
||||
(Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, dest.height - dy}, origin, rotation, tint);
|
||||
}
|
||||
}
|
||||
|
||||
// Fit last column of tiles
|
||||
if (dx < dest.width)
|
||||
{
|
||||
int dy = 0;
|
||||
for (;dy+tileHeight < dest.height; dy += tileHeight)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, source.height},
|
||||
(Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, (float)tileHeight}, origin, rotation, tint);
|
||||
}
|
||||
|
||||
// Draw final tile in the bottom right corner
|
||||
if (dy < dest.height)
|
||||
{
|
||||
DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
|
||||
(Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, dest.height - dy}, origin, rotation, tint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <stdlib.h> // Required for: free()
|
||||
|
||||
#define NUM_PROCESSES 8
|
||||
#define NUM_PROCESSES 9
|
||||
|
||||
typedef enum {
|
||||
NONE = 0,
|
||||
|
|
@ -26,6 +26,7 @@ typedef enum {
|
|||
COLOR_INVERT,
|
||||
COLOR_CONTRAST,
|
||||
COLOR_BRIGHTNESS,
|
||||
GAUSSIAN_BLUR,
|
||||
FLIP_VERTICAL,
|
||||
FLIP_HORIZONTAL
|
||||
} ImageProcess;
|
||||
|
|
@ -37,6 +38,7 @@ static const char *processText[] = {
|
|||
"COLOR INVERT",
|
||||
"COLOR CONTRAST",
|
||||
"COLOR BRIGHTNESS",
|
||||
"GAUSSIAN BLUR",
|
||||
"FLIP VERTICAL",
|
||||
"FLIP HORIZONTAL"
|
||||
};
|
||||
|
|
@ -125,6 +127,7 @@ int main(void)
|
|||
case COLOR_INVERT: ImageColorInvert(&imCopy); break;
|
||||
case COLOR_CONTRAST: ImageColorContrast(&imCopy, -40); break;
|
||||
case COLOR_BRIGHTNESS: ImageColorBrightness(&imCopy, -80); break;
|
||||
case GAUSSIAN_BLUR: ImageBlurGaussian(&imCopy, 10); break;
|
||||
case FLIP_VERTICAL: ImageFlipVertical(&imCopy); break;
|
||||
case FLIP_HORIZONTAL: ImageFlipHorizontal(&imCopy); break;
|
||||
default: break;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,15 @@
|
|||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "rlgl.h" // Required for: Vertex definition
|
||||
#include "raymath.h"
|
||||
|
||||
#define MAX_POINTS 11 // 10 points and back to the start
|
||||
|
||||
// Draw textured polygon, defined by vertex and texture coordinates
|
||||
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
@ -102,3 +107,34 @@ int main(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Draw textured polygon, defined by vertex and texture coordinates
|
||||
// NOTE: Polygon center must have straight line path to all points
|
||||
// without crossing perimeter, points must be in anticlockwise order
|
||||
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
|
||||
{
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
// Texturing is only supported on RL_QUADS
|
||||
rlBegin(RL_QUADS);
|
||||
|
||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
||||
|
||||
for (int i = 0; i < pointCount - 1; i++)
|
||||
{
|
||||
rlTexCoord2f(0.5f, 0.5f);
|
||||
rlVertex2f(center.x, center.y);
|
||||
|
||||
rlTexCoord2f(texcoords[i].x, texcoords[i].y);
|
||||
rlVertex2f(points[i].x + center.x, points[i].y + center.y);
|
||||
|
||||
rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
|
||||
rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
|
||||
|
||||
rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
|
||||
rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
|
||||
}
|
||||
rlEnd();
|
||||
|
||||
rlSetTexture(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue