void _tm_node_scan (tm_node *n) { if ( (n - nodes) % 2 == 0 ) { int i = rand() % nodes_parceled; tm_node *r = &nodes[i]; if ( tm_node_color(r) == ECRU ) { // fprintf(stderr, " %p => %p\n", (void*) n, (void*) r); tm_tread_mark(t, r); render_dot(t, r, "mark @ "); } render_dot(t, n, "scanned @ "); } }
int main(int argc, char **argv) { int i; tm_node *n = 0; if ( argc > 1 ) { seed = *argv[1] ? atoi(argv[1]) : 0; } if ( ! seed ) { time_t t; time(&t); seed = (t ^ getpid()); } srand(seed); tm_msg_init(); tm_colors_init(&tm.colors); tm_tread_init(t); render_dot(t, 0, "initialized"); for ( i = 0; i < 2; ++ i ) { tm_tread_more_white(t); render_dot(t, 0, "more white"); } for ( i = 0; i < N * 4; ++ i ) { n = tm_tread_allocate(t); render_dot(t, n, "allocate => "); if ( n == 0 ) break; if ( rand() % 2 == 0 ) { int i = rand() % nodes_parceled; tm_node *r = &nodes[i]; if ( tm_node_color(r) != WHITE ) { tm_tread_mutation(t, r); render_dot(t, r, "mutation @ "); } } } render_dot(t, n, n ? "FINISHED" : "out of memory"); return 0; }
void tm_tread_mark_roots(tm_tread *t) { int j; render_dot(t, 0, "flipped"); fprintf(stderr, " tm_tread_mark_roots(%p)\n", (void*) t); for ( j = 0; j < 4; ++ j ) { int i = rand() % nodes_parceled; tm_node *n = &nodes[i]; if ( tm_node_color(n) == ECRU ) { fprintf(stderr, " %p\n", (void*) n); tm_tread_mark(t, n); render_dot(t, n, "mark root @ "); } } render_dot(t, 0, "roots marked"); }
void gtk_css_image_builtin_draw_handle (GtkCssImage *image, cairo_t *cr, double width, double height) { GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image); GdkRGBA lighter, darker; gint xx, yy; cairo_set_line_width (cr, 1.0); color_shade (&builtin->bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 1.3, &lighter); for (yy = 0; yy < height; yy += 3) for (xx = 0; xx < width; xx += 6) { render_dot (cr, &lighter, &darker, xx, yy, 2); render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2); } }
void gtk_css_image_builtin_draw_pane_separator (GtkCssImage *image, cairo_t *cr, double width, double height) { GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image); GdkRGBA lighter, darker; gint xx, yy; cairo_set_line_width (cr, 1.0); color_shade (&builtin->bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 1.3, &lighter); if (width > height) for (xx = width / 2 - 15; xx <= width / 2 + 15; xx += 5) render_dot (cr, &lighter, &darker, xx, height / 2 - 1, 3); else for (yy = height / 2 - 15; yy <= height / 2 + 15; yy += 5) render_dot (cr, &lighter, &darker, width / 2 - 1, yy, 3); }
void RunningRenderer::render(Game* game, Display* display) { display->clear(); render_dot(game, display); render_snake(game, display); }
static void drawfloaters(int beat) { static int prevfloaters; static struct {int x, y, age; char color;} floater[10]; static int oddeven; int nfloaters; int i, j, delta, dx, dy; /* choose the number of floaters */ switch (*config.floaters) { case 'N': /* No floaters */ nfloaters = 0; break; case 'D': /* Dots */ nfloaters = 1; break; case 'S': /* Slow */ oddeven++; /* fall through... */ default: /* Slow/Fast/Retro floaters */ nfloaters = 1 + img_width * img_height / 20000; if (nfloaters > 10) nfloaters = 10; } /* for each floater... */ for (i = 0; i < nfloaters; i++) { /* if Dots, new, old, beat, or off-screen... */ if (*config.floaters == 'D' || i >= prevfloaters || floater[i].age++ > 80 + i * 13 || beat || floater[i].x < 0 || floater[i].x >= img_width || floater[i].y < 0 || floater[i].y >= img_height) { /* Pretend motion is 0. This will cause blursk to * choose a new position, later in this function. */ delta = 0; } else { /* find the real motion */ j = floater[i].y * img_bpl + floater[i].x; delta = &img_buf[j] - img_source[j]; } /* if motion isn't 0, then move the floater */ if (delta != 0) { /* decompose the delta into dx & dy. Watch signs! */ dx = (j + delta) % img_bpl - floater[i].x; dy = (j + delta) / img_bpl - floater[i].y; /* move the floater */ switch (*config.floaters) { case 'S': /* Slow floaters */ if ((oddeven ^ i) & 0x1) dx = dy = 0; break; case 'F': /* Fast floaters */ dx *= 2; dy *= 2; break; case 'R': /* Retro floaters */ dx = -dx; dy = -dy; break; } floater[i].x += dx; floater[i].y += dy; } /* if no motion, or motion carries it off the screen, then * choose a new random position & contrasting color. */ if (delta == 0 || floater[i].x < 0 || floater[i].x >= img_width || floater[i].y < 0 || floater[i].y >= img_height) { /* choose a new random position */ floater[i].x = rand_0_to(img_width - 9) + 2; floater[i].y = rand_0_to(img_height - 9) + 2; if (IMG_PIXEL(floater[i].x, floater[i].y) > 0x80) floater[i].color = 0; else floater[i].color = 0xfe; floater[i].age = 0; } /* draw the floater */ render_dot(floater[i].x, floater[i].y, floater[i].color); } prevfloaters = nfloaters; }
static gboolean panel_applet_draw (GtkWidget *widget, cairo_t *cr) { PanelApplet *applet = PANEL_APPLET (widget); GtkStyleContext *context; int border_width = 0; int focus_width = 0; gdouble x, y, width, height; GTK_WIDGET_CLASS (panel_applet_parent_class)->draw (widget, cr); if (applet->priv->has_handle) { GdkRectangle rect = applet->priv->handle_rect; GdkRGBA bg = { 1.0, 1.0, 1.0, .2 }; GdkRGBA lighter = { .0, .0, .0, .2 }; GdkRGBA darker = { .0, .0, .0, .4 }; gint xx; gint yy; cairo_save (cr); // bg cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height); gdk_cairo_set_source_rgba (cr, &bg); cairo_fill(cr); // dots for (yy = rect.y; yy < rect.y + rect.height; yy += 3) { for (xx = rect.x; xx < rect.x + rect.width; xx += 6) { render_dot (cr, &lighter, &darker, xx, yy, 2); render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2); } } cairo_restore (cr); } if (!gtk_widget_has_focus (widget)) return FALSE; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); /* * We are deliberately ignoring focus-padding here to * save valuable panel real estate. */ gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); x = 0; // FIXME: border_width ? y = 0; // FIXME: border_width ? width -= 2 * border_width; height -= 2 * border_width; context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); cairo_save (cr); gtk_render_focus (context, cr, x, y, width, height); cairo_restore (cr); gtk_style_context_restore (context); return FALSE; }