Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /*
  2. * demo demo for libcaca
  3. * Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. #include "config.h"
  14. #include <math.h>
  15. #include <string.h>
  16. #include <stdio.h>
  17. #include "caca.h"
  18. static void display_menu(void);
  19. static void demo_all(void);
  20. static void demo_color(void);
  21. static void demo_dots(void);
  22. static void demo_lines(void);
  23. static void demo_boxes(void);
  24. static void demo_ellipses(void);
  25. static void demo_triangles(void);
  26. static void demo_sprites(void);
  27. static void demo_render(void);
  28. int bounds = 0;
  29. int outline = 0;
  30. int dithering = 0;
  31. cucul_sprite_t *sprite = NULL;
  32. cucul_canvas_t *cv;
  33. caca_display_t *dp;
  34. int main(int argc, char **argv)
  35. {
  36. void (*demo)(void) = NULL;
  37. int quit = 0;
  38. cv = cucul_create_canvas(0, 0);
  39. if(!cv)
  40. return 1;
  41. dp = caca_create_display(cv);
  42. if(!dp)
  43. return 1;
  44. caca_set_delay(dp, 40000);
  45. /* Initialize data */
  46. sprite = cucul_load_sprite(DATADIR "/caca.txt");
  47. if(!sprite)
  48. sprite = cucul_load_sprite("caca.txt");
  49. if(!sprite)
  50. sprite = cucul_load_sprite("examples/caca.txt");
  51. /* Disable cursor */
  52. caca_set_mouse(dp, 0);
  53. /* Main menu */
  54. display_menu();
  55. caca_refresh_display(dp);
  56. /* Go ! */
  57. while(!quit)
  58. {
  59. caca_event_t ev;
  60. int menu = 0, mouse = 0, xmouse = 0, ymouse = 0;
  61. while(caca_get_event(dp, CACA_EVENT_ANY, &ev, 0))
  62. {
  63. if(demo && (ev.type & CACA_EVENT_KEY_PRESS))
  64. {
  65. menu = 1;
  66. demo = NULL;
  67. }
  68. else if(ev.type & CACA_EVENT_KEY_PRESS)
  69. {
  70. switch(ev.data.key.ch)
  71. {
  72. case 'q':
  73. case 'Q':
  74. demo = NULL;
  75. quit = 1;
  76. break;
  77. case 'o':
  78. case 'O':
  79. outline = (outline + 1) % 3;
  80. display_menu();
  81. break;
  82. case 'b':
  83. case 'B':
  84. bounds = (bounds + 1) % 2;
  85. display_menu();
  86. break;
  87. #if 0
  88. case 'd':
  89. case 'D':
  90. dithering = (dithering + 1) % 5;
  91. cucul_set_feature(cv, dithering);
  92. display_menu();
  93. break;
  94. #endif
  95. case 'c':
  96. demo = demo_color;
  97. break;
  98. case 'f':
  99. case 'F':
  100. demo = demo_all;
  101. break;
  102. case '1':
  103. demo = demo_dots;
  104. break;
  105. case '2':
  106. demo = demo_lines;
  107. break;
  108. case '3':
  109. demo = demo_boxes;
  110. break;
  111. case '4':
  112. demo = demo_triangles;
  113. break;
  114. case '5':
  115. demo = demo_ellipses;
  116. break;
  117. case 's':
  118. case 'S':
  119. if(sprite)
  120. demo = demo_sprites;
  121. break;
  122. case 'r':
  123. case 'R':
  124. demo = demo_render;
  125. break;
  126. }
  127. if(demo)
  128. {
  129. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  130. cucul_clear_canvas(cv);
  131. }
  132. }
  133. else if(ev.type & CACA_EVENT_MOUSE_MOTION)
  134. {
  135. mouse = 1;
  136. xmouse = ev.data.mouse.x;
  137. ymouse = ev.data.mouse.y;
  138. }
  139. else if(ev.type & CACA_EVENT_RESIZE)
  140. {
  141. mouse = 1; /* old hack */
  142. }
  143. }
  144. if(menu || (mouse && !demo))
  145. {
  146. display_menu();
  147. if(mouse && !demo)
  148. {
  149. cucul_set_color(cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
  150. cucul_putstr(cv, xmouse, ymouse, ".");
  151. cucul_putstr(cv, xmouse, ymouse + 1, "|\\");
  152. }
  153. caca_refresh_display(dp);
  154. mouse = menu = 0;
  155. }
  156. if(demo)
  157. {
  158. demo();
  159. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  160. cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2,
  161. cucul_get_canvas_height(cv) - 2);
  162. cucul_printf(cv, 4, 1, "[%i.%i fps]----",
  163. 1000000 / caca_get_rendertime(dp),
  164. (10000000 / caca_get_rendertime(dp)) % 10);
  165. caca_refresh_display(dp);
  166. }
  167. }
  168. /* Clean up */
  169. cucul_free_sprite(sprite);
  170. caca_free_display(dp);
  171. cucul_free_canvas(cv);
  172. return 0;
  173. }
  174. static void display_menu(void)
  175. {
  176. int xo = cucul_get_canvas_width(cv) - 2;
  177. int yo = cucul_get_canvas_height(cv) - 2;
  178. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  179. cucul_clear_canvas(cv);
  180. cucul_draw_thin_box(cv, 1, 1, xo, yo);
  181. cucul_putstr(cv, (xo - strlen("libcaca demo")) / 2, 3, "libcaca demo");
  182. cucul_putstr(cv, (xo - strlen("==============")) / 2, 4, "==============");
  183. cucul_putstr(cv, 4, 6, "demos:");
  184. cucul_putstr(cv, 4, 7, "'f': full");
  185. cucul_putstr(cv, 4, 8, "'1': dots");
  186. cucul_putstr(cv, 4, 9, "'2': lines");
  187. cucul_putstr(cv, 4, 10, "'3': boxes");
  188. cucul_putstr(cv, 4, 11, "'4': triangles");
  189. cucul_putstr(cv, 4, 12, "'5': ellipses");
  190. cucul_putstr(cv, 4, 13, "'c': colour");
  191. cucul_putstr(cv, 4, 14, "'r': render");
  192. if(sprite)
  193. cucul_putstr(cv, 4, 15, "'s': sprites");
  194. cucul_putstr(cv, 4, 16, "settings:");
  195. cucul_printf(cv, 4, 17, "'o': outline: %s",
  196. outline == 0 ? "none" : outline == 1 ? "solid" : "thin");
  197. cucul_printf(cv, 4, 18, "'b': drawing boundaries: %s",
  198. bounds == 0 ? "screen" : "infinite");
  199. //cucul_printf(cv, 4, 19, "'d': dithering (%s)",
  200. // cucul_get_feature_name(dithering));
  201. cucul_putstr(cv, 4, yo - 2, "'q': quit");
  202. caca_refresh_display(dp);
  203. }
  204. static void demo_all(void)
  205. {
  206. static int i = 0;
  207. int j, xo, yo, xa, ya, xb, yb, xc, yc;
  208. i++;
  209. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  210. cucul_clear_canvas(cv);
  211. /* Draw the sun */
  212. cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  213. xo = cucul_get_canvas_width(cv) / 4;
  214. yo = cucul_get_canvas_height(cv) / 4 + 5 * sin(0.03*i);
  215. for(j = 0; j < 16; j++)
  216. {
  217. xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8);
  218. ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8);
  219. cucul_draw_thin_line(cv, xo, yo, xa, ya);
  220. }
  221. j = 15 + sin(0.03*i) * 8;
  222. cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
  223. cucul_fill_ellipse(cv, xo, yo, j, j / 2, "#");
  224. cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  225. cucul_draw_ellipse(cv, xo, yo, j, j / 2, "#");
  226. /* Draw the pyramid */
  227. xo = cucul_get_canvas_width(cv) * 5 / 8;
  228. yo = 2;
  229. xa = cucul_get_canvas_width(cv) / 8 + sin(0.03*i) * 5;
  230. ya = cucul_get_canvas_height(cv) / 2 + cos(0.03*i) * 5;
  231. xb = cucul_get_canvas_width(cv) - 10 - cos(0.02*i) * 10;
  232. yb = cucul_get_canvas_height(cv) * 3 / 4 - 5 + sin(0.02*i) * 5;
  233. xc = cucul_get_canvas_width(cv) / 4 - sin(0.02*i) * 5;
  234. yc = cucul_get_canvas_height(cv) * 3 / 4 + cos(0.02*i) * 5;
  235. cucul_set_color(cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
  236. cucul_fill_triangle(cv, xo, yo, xb, yb, xa, ya, "%");
  237. cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  238. cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xa, ya);
  239. cucul_set_color(cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
  240. cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
  241. cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  242. cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
  243. cucul_set_color(cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
  244. cucul_fill_triangle(cv, xo, yo, xb, yb, xc, yc, "%");
  245. cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  246. cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xc, yc);
  247. /* Draw a background triangle */
  248. xa = 2;
  249. ya = 2;
  250. xb = cucul_get_canvas_width(cv) - 3;
  251. yb = cucul_get_canvas_height(cv) / 2;
  252. xc = cucul_get_canvas_width(cv) / 3;
  253. yc = cucul_get_canvas_height(cv) - 3;
  254. cucul_set_color(cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
  255. cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
  256. xo = cucul_get_canvas_width(cv) / 2 + cos(0.027*i) * cucul_get_canvas_width(cv) / 3;
  257. yo = cucul_get_canvas_height(cv) / 2 - sin(0.027*i) * cucul_get_canvas_height(cv) / 2;
  258. cucul_draw_thin_line(cv, xa, ya, xo, yo);
  259. cucul_draw_thin_line(cv, xb, yb, xo, yo);
  260. cucul_draw_thin_line(cv, xc, yc, xo, yo);
  261. /* Draw a sprite on the pyramid */
  262. cucul_draw_sprite(cv, xo, yo, sprite, 0);
  263. /* Draw a trail behind the foreground sprite */
  264. for(j = i - 60; j < i; j++)
  265. {
  266. int delta = cucul_rand(-5, 6);
  267. cucul_set_color(cv, cucul_rand(0, 16), cucul_rand(0, 16));
  268. cucul_putchar(cv, cucul_get_canvas_width(cv) / 2
  269. + cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4),
  270. cucul_get_canvas_height(cv) / 2
  271. + sin(0.02*j) * (delta + cucul_get_canvas_height(cv) / 3),
  272. '#');
  273. }
  274. /* Draw foreground sprite */
  275. cucul_draw_sprite(cv, cucul_get_canvas_width(cv) / 2 + cos(0.02*i) * cucul_get_canvas_width(cv) / 4,
  276. cucul_get_canvas_height(cv) / 2 + sin(0.02*i) * cucul_get_canvas_height(cv) / 3,
  277. sprite, 0);
  278. }
  279. static void demo_dots(void)
  280. {
  281. int xmax = cucul_get_canvas_width(cv);
  282. int ymax = cucul_get_canvas_height(cv);
  283. int i;
  284. static char chars[10] =
  285. {
  286. '+', '-', '*', '#', 'X', '@', '%', '$', 'M', 'W'
  287. };
  288. for(i = 1000; i--;)
  289. {
  290. /* Putpixel */
  291. cucul_set_color(cv, cucul_rand(0, 16), cucul_rand(0, 16));
  292. cucul_putchar(cv, cucul_rand(0, xmax), cucul_rand(0, ymax),
  293. chars[cucul_rand(0, 9)]);
  294. }
  295. }
  296. static void demo_color(void)
  297. {
  298. int i, j;
  299. char buf[BUFSIZ];
  300. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  301. cucul_clear_canvas(cv);
  302. for(i = 0; i < 16; i++)
  303. {
  304. sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i));
  305. cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
  306. cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf);
  307. for(j = 0; j < 16; j++)
  308. {
  309. cucul_set_color(cv, i, j);
  310. cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# ");
  311. }
  312. }
  313. }
  314. static void demo_lines(void)
  315. {
  316. int w = cucul_get_canvas_width(cv);
  317. int h = cucul_get_canvas_height(cv);
  318. int xa, ya, xb, yb;
  319. if(bounds)
  320. {
  321. xa = cucul_rand(- w, 2 * w); ya = cucul_rand(- h, 2 * h);
  322. xb = cucul_rand(- w, 2 * w); yb = cucul_rand(- h, 2 * h);
  323. }
  324. else
  325. {
  326. xa = cucul_rand(0, w); ya = cucul_rand(0, h);
  327. xb = cucul_rand(0, w); yb = cucul_rand(0, h);
  328. }
  329. cucul_set_color(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK);
  330. if(outline > 1)
  331. cucul_draw_thin_line(cv, xa, ya, xb, yb);
  332. else
  333. cucul_draw_line(cv, xa, ya, xb, yb, "#");
  334. }
  335. static void demo_boxes(void)
  336. {
  337. int w = cucul_get_canvas_width(cv);
  338. int h = cucul_get_canvas_height(cv);
  339. int xa, ya, xb, yb;
  340. if(bounds)
  341. {
  342. xa = cucul_rand(- w, 2 * w); ya = cucul_rand(- h, 2 * h);
  343. xb = cucul_rand(- w, 2 * w); yb = cucul_rand(- h, 2 * h);
  344. }
  345. else
  346. {
  347. xa = cucul_rand(0, w); ya = cucul_rand(0, h);
  348. xb = cucul_rand(0, w); yb = cucul_rand(0, h);
  349. }
  350. cucul_set_color(cv, cucul_rand(0, 16), cucul_rand(0, 16));
  351. cucul_fill_box(cv, xa, ya, xb, yb, "#");
  352. cucul_set_color(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK);
  353. if(outline == 2)
  354. cucul_draw_thin_box(cv, xa, ya, xb, yb);
  355. else if(outline == 1)
  356. cucul_draw_box(cv, xa, ya, xb, yb, "#");
  357. }
  358. static void demo_ellipses(void)
  359. {
  360. int w = cucul_get_canvas_width(cv);
  361. int h = cucul_get_canvas_height(cv);
  362. int x, y, a, b;
  363. if(bounds)
  364. {
  365. x = cucul_rand(- w, 2 * w); y = cucul_rand(- h, 2 * h);
  366. a = cucul_rand(0, w); b = cucul_rand(0, h);
  367. }
  368. else
  369. {
  370. do
  371. {
  372. x = cucul_rand(0, w); y = cucul_rand(0, h);
  373. a = cucul_rand(0, w); b = cucul_rand(0, h);
  374. } while(x - a < 0 || x + a >= w || y - b < 0 || y + b >= h);
  375. }
  376. cucul_set_color(cv, cucul_rand(0, 16), cucul_rand(0, 16));
  377. cucul_fill_ellipse(cv, x, y, a, b, "#");
  378. cucul_set_color(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK);
  379. if(outline == 2)
  380. cucul_draw_thin_ellipse(cv, x, y, a, b);
  381. else if(outline == 1)
  382. cucul_draw_ellipse(cv, x, y, a, b, "#");
  383. }
  384. static void demo_triangles(void)
  385. {
  386. int w = cucul_get_canvas_width(cv);
  387. int h = cucul_get_canvas_height(cv);
  388. int xa, ya, xb, yb, xc, yc;
  389. if(bounds)
  390. {
  391. xa = cucul_rand(- w, 2 * w); ya = cucul_rand(- h, 2 * h);
  392. xb = cucul_rand(- w, 2 * w); yb = cucul_rand(- h, 2 * h);
  393. xc = cucul_rand(- w, 2 * w); yc = cucul_rand(- h, 2 * h);
  394. }
  395. else
  396. {
  397. xa = cucul_rand(0, w); ya = cucul_rand(0, h);
  398. xb = cucul_rand(0, w); yb = cucul_rand(0, h);
  399. xc = cucul_rand(0, w); yc = cucul_rand(0, h);
  400. }
  401. cucul_set_color(cv, cucul_rand(0, 16), cucul_rand(0, 16));
  402. cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
  403. cucul_set_color(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK);
  404. if(outline == 2)
  405. cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
  406. else if(outline == 1)
  407. cucul_draw_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
  408. }
  409. static void demo_sprites(void)
  410. {
  411. cucul_draw_sprite(cv, cucul_rand(0, cucul_get_canvas_width(cv)),
  412. cucul_rand(0, cucul_get_canvas_height(cv)), sprite, 0);
  413. }
  414. #if 0
  415. static void demo_render(void)
  416. {
  417. cucul_dither_t *dither;
  418. //short buffer[256*256];
  419. //short *dest = buffer;
  420. int buffer[256*256];
  421. int *dest = buffer;
  422. int x, y, z;
  423. static int i = 0;
  424. i = (i + 1) % 512;
  425. z = i < 256 ? i : 511 - i;
  426. for(x = 0; x < 256; x++)
  427. for(y = 0; y < 256; y++)
  428. {
  429. //*dest++ = ((x >> 3) << 11) | ((y >> 2) << 5) | ((z >> 3));
  430. *dest++ = (x << 16) | (y << 8) | (z);
  431. }
  432. cucul_set_dither_invert(dither, 1);
  433. //dither = cucul_create_dither(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000);
  434. dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
  435. cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv),
  436. dither, buffer);
  437. cucul_free_dither(dither);
  438. }
  439. #endif
  440. static void draw_circle(int *buffer, int xo, int yo, int r, int mask, int val);
  441. static void demo_render(void)
  442. {
  443. cucul_dither_t *dither;
  444. int buffer[256*256];
  445. int *dest;
  446. int x, y, z, xo, yo;
  447. static int i = 0;
  448. i++;
  449. dest = buffer;
  450. for(x = 0; x < 256; x++)
  451. for(y = 0; y < 256; y++)
  452. {
  453. *dest++ = 0xff000000;
  454. }
  455. /* red */
  456. xo = 128 + 48 * sin(0.02 * i);
  457. yo = 128 + 48 * cos(0.03 * i);
  458. for(z = 0; z < 240; z++)
  459. draw_circle(buffer, xo, yo, z, 0x00ff0000, 200 << 16);
  460. /* green */
  461. xo = 128 + 48 * sin(2 + 0.06 * i);
  462. yo = 128 + 48 * cos(2 + 0.05 * i);
  463. for(z = 0; z < 240; z++)
  464. draw_circle(buffer, xo, yo, z, 0x0000ff00, 200 << 8);
  465. /* blue */
  466. xo = 128 + 48 * sin(1 + 0.04 * i);
  467. yo = 128 + 48 * cos(1 + 0.03 * i);
  468. for(z = 0; z < 240; z++)
  469. draw_circle(buffer, xo, yo, z, 0x000000ff, 200);
  470. dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
  471. cucul_set_dither_invert(dither, 1);
  472. cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv), dither, (char *)buffer);
  473. cucul_free_dither(dither);
  474. }
  475. static void draw_circle(int *buffer, int x, int y, int r, int mask, int val)
  476. {
  477. int t, dx, dy;
  478. #define POINT(X,Y) \
  479. buffer[(X) + 256 * (Y)] = 0xff000000 | (buffer[(X) + 256 * (Y)] & ~mask) | val;
  480. for(t = 0, dx = 0, dy = r; dx <= dy; dx++)
  481. {
  482. POINT(x - dx / 3, y - dy / 3);
  483. POINT(x + dx / 3, y - dy / 3);
  484. POINT(x - dx / 3, y + dy / 3);
  485. POINT(x + dx / 3, y + dy / 3);
  486. POINT(x - dy / 3, y - dx / 3);
  487. POINT(x + dy / 3, y - dx / 3);
  488. POINT(x - dy / 3, y + dx / 3);
  489. POINT(x + dy / 3, y + dx / 3);
  490. t += t > 0 ? dx - dy-- : dx;
  491. }
  492. }