mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
Randomize flower offset again.
This commit is contained in:
parent
aa68fe346a
commit
3b94998f6a
1 changed files with 4 additions and 4 deletions
8
flower.c
8
flower.c
|
|
@ -106,8 +106,8 @@ draw_stuff(int width, int height)
|
||||||
struct flower {
|
struct flower {
|
||||||
struct wl_compositor *compositor;
|
struct wl_compositor *compositor;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
int i;
|
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
int offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -125,8 +125,8 @@ handle_frame(void *data,
|
||||||
struct flower *flower = data;
|
struct flower *flower = data;
|
||||||
|
|
||||||
wl_surface_map(flower->surface,
|
wl_surface_map(flower->surface,
|
||||||
flower->x + cos(timestamp / 400.0) * 400 - flower->width / 2,
|
flower->x + cos((flower->offset + timestamp) / 400.0) * 400 - flower->width / 2,
|
||||||
flower->y + sin(timestamp / 320.0) * 300 - flower->height / 2,
|
flower->y + sin((flower->offset + timestamp) / 320.0) * 300 - flower->height / 2,
|
||||||
flower->width, flower->height);
|
flower->width, flower->height);
|
||||||
wl_compositor_commit(flower->compositor, 0);
|
wl_compositor_commit(flower->compositor, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
srandom(ts.tv_nsec);
|
srandom(ts.tv_nsec);
|
||||||
flower.i = ts.tv_nsec;
|
flower.offset = random();
|
||||||
|
|
||||||
s = draw_stuff(flower.width, flower.height);
|
s = draw_stuff(flower.width, flower.height);
|
||||||
buffer = buffer_create_from_cairo_surface(fd, s);
|
buffer = buffer_create_from_cairo_surface(fd, s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue