commit ef8862aa5d5a5a64cb174e74109885f6e961e912
parent 5a6c93269636558e5ac824a2b9897df3158a9d26
Author: glenda <glenda@kobeni>
Date: Mon, 8 Jan 2024 20:32:46 +0000
src/noise: add circle scene
Diffstat:
3 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/src/noise/circle.c b/src/noise/circle.c
@@ -0,0 +1,51 @@
+/* a scene with circle drawn by fillellipse(2) func */
+
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+#include "noise.h"
+
+#include "circle.h"
+
+struct Circle_State {
+ Point c;
+ int r, dr;
+ Image *bg, *fill;
+ long t, nt;
+} css;
+
+void cs_init(void *)
+{
+ css.dr = 50;
+ css.r = 50;
+ css.bg = display->black;
+ css.fill = display->white;
+ css.t = 0;
+}
+
+void cs_draw(void *)
+{
+ css.c = addpt(Pt(css.r, css.r), screen->r.min);
+ draw(screen, screen->r, css.bg, nil, ZP);
+ fillellipse(screen, css.c, css.r, css.r, css.fill, ZP);
+ css.nt = time(nil);
+
+ if (css.nt - css.t > 2) {
+ css.t = css.nt;
+ css.r += css.dr;
+ if (css.r > 500) css.r = 50;
+ }
+}
+
+void cs_stop(void *)
+{
+
+}
+
+Scene CircleScene = {
+ "a circle",
+ cs_init,
+ cs_draw,
+ cs_stop,
+ nil};
diff --git a/src/noise/config.h b/src/noise/config.h
@@ -1,8 +1,10 @@
#include "dnoise.h"
#include "blank.h"
+#include "circle.h"
Scene *plist[] = {
- &BlankScene,
&DNoiseScene,
+ &CircleScene,
+ &BlankScene,
nil,
};
diff --git a/src/noise/main.c b/src/noise/main.c
@@ -9,10 +9,6 @@
#include "config.h"
-enum {
- PlSize = sizeof(plist) / sizeof(Scene *),
-};
-
Scene *cs;
struct FPSWidget {