Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ac2e88e

Browse files
committed
Add smiley demo
Implementation details: - Yellow circular face (70px radius) with black outline - Two black circular eyes (10px radius each) - Smile arc using twin_path_arc (50px radius, 0-180 degrees) - 200x200 window size for clean rendering The smiley demo showcases: - Circle and arc path primitives - Fill and stroke operations - Fixed-point coordinate system - Color composition with alpha channel
1 parent 56151cf commit ac2e88e

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

‎apps/multi.c‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,57 @@ static void apps_circletext_start(twin_screen_t *screen,
216216
twin_window_show(window);
217217
}
218218

219+
static void apps_smiley_start(twin_screen_t *screen, int x, int y, int w, int h)
220+
{
221+
twin_window_t *window = twin_window_create(
222+
screen, TWIN_ARGB32, TwinWindowApplication, x, y, w, h);
223+
twin_pixmap_t *pixmap = window->pixmap;
224+
225+
twin_window_set_name(window, "Smiley");
226+
227+
/* Clear background to white */
228+
twin_fill(pixmap, 0xffffffff, TWIN_SOURCE, 0, 0, w, h);
229+
230+
/* Calculate center and dimensions */
231+
twin_fixed_t center_x = twin_int_to_fixed(w / 2);
232+
twin_fixed_t center_y = twin_int_to_fixed(h / 2);
233+
twin_fixed_t face_radius = D(70);
234+
twin_fixed_t mouth_radius = D(50);
235+
twin_fixed_t eye_radius = D(10);
236+
twin_fixed_t eye_offset_x = D(25);
237+
twin_fixed_t eye_offset_y = D(20);
238+
239+
/* Draw face - yellow circle with black outline */
240+
twin_path_t *face = twin_path_create();
241+
twin_path_circle(face, center_x, center_y, face_radius);
242+
twin_paint_path(pixmap, 0xffffff00, face); /* Yellow fill */
243+
twin_paint_stroke(pixmap, 0xff000000, face, D(5)); /* Black outline */
244+
twin_path_destroy(face);
245+
246+
/* Draw left eye */
247+
twin_path_t *left_eye = twin_path_create();
248+
twin_path_circle(left_eye, center_x - eye_offset_x, center_y - eye_offset_y,
249+
eye_radius);
250+
twin_paint_path(pixmap, 0xff000000, left_eye); /* Black */
251+
twin_path_destroy(left_eye);
252+
253+
/* Draw right eye */
254+
twin_path_t *right_eye = twin_path_create();
255+
twin_path_circle(right_eye, center_x + eye_offset_x,
256+
center_y - eye_offset_y, eye_radius);
257+
twin_paint_path(pixmap, 0xff000000, right_eye); /* Black */
258+
twin_path_destroy(right_eye);
259+
260+
/* Draw smile - bottom half arc */
261+
twin_path_t *smile = twin_path_create();
262+
twin_path_arc(smile, center_x, center_y, mouth_radius, mouth_radius,
263+
TWIN_ANGLE_0, TWIN_ANGLE_180);
264+
twin_paint_stroke(pixmap, 0xff000000, smile, D(5)); /* Black line */
265+
twin_path_destroy(smile);
266+
267+
twin_window_show(window);
268+
}
269+
219270
static void apps_ascii_start(twin_screen_t *screen, int x, int y, int w, int h)
220271
{
221272
twin_window_t *window = twin_window_create(
@@ -374,6 +425,7 @@ void apps_multi_start(twin_screen_t *screen,
374425
(void) name;
375426
apps_circletext_start(screen, x, y, w, h);
376427
apps_multiline_start(screen, x += 20, y += 20, w * 2 / 3, h * 2 / 3);
428+
apps_smiley_start(screen, x += 20, y += 20, 200, 200);
377429
apps_ascii_start(screen, x += 20, y += 20, w, h);
378430
apps_flower_start(screen, x += 20, y += 20, w, h);
379431
apps_blur(screen, x += 20, y += 20, w / 2, h / 2);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /