-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
64 lines (46 loc) · 984 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include "SDL.h"
#include "pixels/canvas.h"
#include "pixels/screen.h"
#include "pixels/draw.h"
int main(int argc, char *argv[])
{
int width = 64;
int height = 64;
canvas_create(width, height);
screen_setup(width, height);
/* ----- Write your program below ----- */
int frame = 0;
bool ascending = true;
bool exit = false;
while (exit == false)
{
if (screen_closebuttonpressed())
break;
int x, y;
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
Uint8 r = 255 - ((255.0 / height) * y);
Uint8 g = (255.0 / width) * x;
Uint8 b = frame % 255;
draw_pixel(x, y, r, g, b);
}
if (frame >= 254)
ascending = false;
else if (frame <= 0)
ascending = true;
if (ascending == true)
frame++;
else
frame--;
screen_update();
usleep(16700);
}
/* ------------------------------------ */
screen_cleanup();
return 0;
}