Skip to content

Commit

Permalink
More line variations
Browse files Browse the repository at this point in the history
  • Loading branch information
dpt committed Feb 22, 2024
1 parent 6bf0649 commit 4882951
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions libraries/framebuf/curve/test/curve-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ static result_t start_sdl(sdlstate_t *state, int width, int height)
}

state->window = SDL_CreateWindow("DPTLib SDL Test",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height,
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
SDL_WINDOW_SHOWN);
if (state->window == NULL)
{
fprintf(stderr, "Error: SDL_CreateWindow: %s\n", SDL_GetError());
Expand Down Expand Up @@ -489,30 +489,42 @@ static void rotate_lines(curveteststate_t *state, int degrees, int palidx)
const float separation = diameter;
const int ntypes = 3 + 1;

float startx, starty;
int x,y;
float r;
float xa, ya, xb, yb;
float sep;
box_t b;
float startx, starty;
int x,y;
float r;
float ox, oy;
float xa, ya, xb, yb;
float sep;
box_t b;

startx = starty = radius;

for (y = 0; y < nvert; y++)
{
for (x = 0; x < nhorz; x++)
{
r = spin;
r += degrees / 8.0f; /* spin with input */
/* spin with increasing speed vertically */
r = spin * y / 2.0f;

/* spin very slowly over time */
spin += 0.0005f;

/* spin with input */
r += degrees / 8.0f;

/* show some rotations over the horizontal */
r += 90.0f * x / (nhorz - 1);
r += 360.0f * y / (nvert - 1); /* show all rotations over the range */

spin += 0.0005f; /* spin very slowly over time */
/* show all rotations over the vertical */
r += 360.0f * y / (nvert - 1);

ox = startx + x * diameter * ntypes;
oy = starty + y * diameter;

xa = startx + x * diameter * ntypes + sinf((r + 0.0f) * deg2rad) * radius;
ya = starty + y * diameter * ntypes + cosf((r + 0.0f) * deg2rad) * radius;
xb = startx + x * diameter * ntypes + sinf((r + 180.0f) * deg2rad) * radius;
yb = starty + y * diameter * ntypes + cosf((r + 180.0f) * deg2rad) * radius;
xa = ox + sinf((r + 0.0f) * deg2rad) * radius;
ya = oy + cosf((r + 0.0f) * deg2rad) * radius;
xb = ox + sinf((r + 180.0f) * deg2rad) * radius;
yb = oy + cosf((r + 180.0f) * deg2rad) * radius;

sep = 0;

Expand Down

0 comments on commit 4882951

Please sign in to comment.