mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-20 20:49:17 -05:00
Update textures_screen_buffer.c
This commit is contained in:
@ -52,6 +52,7 @@ int main(void)
|
||||
float hue = t*t;
|
||||
float saturation = t;
|
||||
float value = t;
|
||||
|
||||
palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value);
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ int main(void)
|
||||
{
|
||||
int flame = (int)flameRootBuffer[x];
|
||||
flame += GetRandomValue(0, 2);
|
||||
flameRootBuffer[x] = (flameInc > 255)? 255: (unsigned char)flame;
|
||||
flameRootBuffer[x] = (flame > 255)? 255: (unsigned char)flame;
|
||||
}
|
||||
|
||||
// Transfer flameRoot to indexBuffer
|
||||
@ -81,8 +82,7 @@ int main(void)
|
||||
// Clear top row, because it can't move any higher
|
||||
for (int x = 0; x < imageWidth; x++)
|
||||
{
|
||||
if (indexBuffer[x] == 0) continue;
|
||||
indexBuffer[x] = 0;
|
||||
if (indexBuffer[x] != 0) indexBuffer[x] = 0;
|
||||
}
|
||||
|
||||
// Skip top row, it is already cleared
|
||||
@ -92,20 +92,24 @@ int main(void)
|
||||
{
|
||||
unsigned int i = x + y*imageWidth;
|
||||
unsigned char colorIndex = indexBuffer[i];
|
||||
if (colorIndex == 0) continue;
|
||||
|
||||
if (colorIndex != 0)
|
||||
{
|
||||
// Move pixel a row above
|
||||
indexBuffer[i] = 0;
|
||||
int moveX = GetRandomValue(0, 2) - 1;
|
||||
int newX = x + moveX;
|
||||
if (newX < 0 || newX >= imageWidth) continue;
|
||||
|
||||
if ((newX > 0) && (newX < imageWidth))
|
||||
{
|
||||
unsigned int iabove = i - imageWidth + moveX;
|
||||
int decay = GetRandomValue(0, 3);
|
||||
colorIndex -= (decay < colorIndex)? decay : colorIndex;
|
||||
indexBuffer[iabove] = colorIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update screenImage with palette colors
|
||||
for (int y = 1; y < imageHeight; y++)
|
||||
@ -115,6 +119,7 @@ int main(void)
|
||||
unsigned int i = x + y*imageWidth;
|
||||
unsigned char colorIndex = indexBuffer[i];
|
||||
Color col = palette[colorIndex];
|
||||
|
||||
ImageDrawPixel(&screenImage, x, y, col);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user