Exemple #1
0
void test_circles(Screen* screen) {
	fill_screen(screen, color_make(2, 0, 0));

	Coordinate center = point_make(screen->window->size.width/2, screen->window->size.height/2);
	int radius = screen->window->size.height/2;

	for (int i = 0; i < 26; i++) {
		Circle c = circle_make(center, radius);
		draw_circle(screen, c, color_make(i, 0, 0), 1);

		radius -= 4;
	}
}
Exemple #2
0
static void EXPORT_in_circle(struct crabql *crabql, msgpack_object *o, UT_string *s, int nargs) {
    ERROR_ASSERT(nargs == 3);
    ERROR_ASSERT(o[2].type == MSGPACK_OBJECT_ARRAY);
    ERROR_ASSERT(o[2].via.array.size == 2);
    ERROR_ASSERT(o[2].via.array.ptr[0].type == MSGPACK_OBJECT_POSITIVE_INTEGER);
    ERROR_ASSERT(o[2].via.array.ptr[1].type == MSGPACK_OBJECT_POSITIVE_INTEGER);

    struct circle *circle = circle_make(*(struct point *) &o[2].via.array.ptr[0].via.u64, o[2].via.array.ptr[1].via.u64);
    char *binstr = dump_binstrescape((const char *) circle, sizeof(struct circle));

    uts_printf_concat(s, "cb_point_in_circle((uint64_t) ");
    crabql_generate_code(crabql, &o[1], s);
    uts_printf_concat(s, ", \"");
    utstring_bincpy(s, binstr, strlen(binstr));
    uts_printf_concat(s, "\")");

    slab_free(circle);
    slab_free(binstr);
}