void sk_test_c_api(sk_canvas_t* canvas) { do_draw(canvas); sk_imageinfo_t info = { W, H, sk_colortype_get_default_8888(), OPAQUE_SK_ALPHATYPE }; sk_surface_t* surf = sk_surface_new_raster(&info); do_draw(sk_surface_get_canvas(surf)); sk_image_t* img0 = sk_surface_new_image_snapshot(surf); sk_surface_unref(surf); sk_canvas_draw_image(canvas, img0, W + 10, 10, NULL); sk_data_t* data = sk_image_encode(img0); sk_image_unref(img0); sk_image_t* img1 = sk_image_new_from_data(data); sk_data_unref(data); if (img1) { sk_canvas_draw_image(canvas, img1, W/2, H/2, NULL); sk_image_unref(img1); } }
void LRMarker::draw(Canvas* c, const Allocation& a) const { if (c != nil) { if (marked_ && underlay_ != nil) { do_draw( c, underlay_, left_, right_, x1_, y1_, y1_ + h1_, x2_, y2_, y2_ + h2_ ); } } MonoGlyph::draw(c, a); if (c != nil) { if (marked_ && overlay_ != nil) { do_draw( c, overlay_, left_, right_, x1_, y1_, y1_ + h1_, x2_, y2_, y2_ + h2_ ); } } }
/* * Draw a map with x,y as centre and rad as radius using * standard map characters. */ draw_area_around(int x, int y, int rad) { if(out_of_bounds(x - rad, y + rad, rad * 2 + 1, rad * 2 + 1)) { write("Someone spilled spam on that part of the map.\n"); return 1; } do_draw(x - rad, y + rad, rad * 2 + 1, rad * 2 + 1); return 0; }
/* * Draw one map character on the players terminal. */ int get_one_square(int x, int y) { if(out_of_bounds(x, y, 1, 1)) { write("Someone spilled spam on that part of the map.\n"); return 1; } do_draw(x, y, 1, 1); return 1; }
void Logo::DrawPolygon () { float scalex = float(xmax+2)/1300; float scaley = float(ymax+2)/1300; output->SetOrigin(xmax/2, ymax/2); do_draw(output, canvas, 0, scalex, scaley); do_draw(output, canvas, 90, scalex, -scaley); do_draw(output, canvas, 90, scalex, scaley); do_draw(output, canvas, 0, scalex, -scaley); do_draw(output, canvas, 0, -scalex, -scaley); do_draw(output, canvas, 90, -scalex, scaley); do_draw(output, canvas, 90, -scalex, -scaley); do_draw(output, canvas, 0, -scalex, scaley); output->SetOrigin(0, 0); }
static gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { do_draw(NULL); gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixmap, // Only copy the area that was exposed. event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); return TRUE; }
/* * Draw a map with the top left corner in x,y. Use the standard * map characters. */ varargs int draw_area_from_corner(int x, int y, int range, int y__width) { if(range < 1 || range > 40 || y__width > 40) { write("Illegal range\n"); return 1; } if(!y__width) y__width = range; if(out_of_bounds(x, y, range, y__width)) { write("Someone spilled spam on that part of the map.\n"); return 1; } do_draw(x, y, range, y__width); return 0; }
void onDraw(SkCanvas* canvas) override { const SkScalar L = 10; const SkScalar T = 10; const SkScalar R = 310; const SkScalar B = 630; canvas->clipRect({ L, T, R, B }); for (int i = 0; i < 100; ++i) { SkAutoCanvasRestore acr(canvas, true); if (Mode::kClipped == fMode) { save_layer_unclipped(canvas, L, T, R, T + 20); save_layer_unclipped(canvas, L, B - 20, R, B); } else { SkASSERT(Mode::kUnclipped == fMode); canvas->saveLayer({ L, T, R, B }, nullptr); } do_draw(canvas); } }
int main(int argc, char ** argv) { int count; struct life_t life; init(&life, &argc, &argv); while (1) { if (life.do_display) do_draw(&life); copy_bounds(&life); eval_rules(&life); update_grid(&life); throttle(&life); } cleanup(&life); exit(EXIT_SUCCESS); }
void Renderable::draw() { do_draw(); }
void draw() { std::cout << "Shape::draw" << std::endl; do_draw(); }
int new_snake_window(int argc, char **argv) { GR_SCREEN_INFO si; fin = 0; snake_count = 0; game_speed = start_speed; GrGetScreenInfo(&si); /* Get screen info */ srand(time(0)); game_state = SNAKE_START; /* Make the window */ /*swindow = GrNewWindowEx(WM_PROPS, "nxsnake", GR_ROOT_WINDOW_ID, 10, 10, WWIDTH, WHEIGHT, BLACK);*/ swindow = pz_new_window (0,HEADER_TOPLINE+1,si.cols,si.rows-HEADER_TOPLINE-1, do_draw,nxsnake_handle_event); GrSelectEvents(swindow, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_TIMER); nxsnake_timer = GrCreateTimer( swindow, 5 ); offscreen = pz_new_window (0,HEADER_TOPLINE+1,si.cols,si.rows-HEADER_TOPLINE-1, do_draw,nxsnake_handle_event); //offscreen = GrNewPixmap(WWIDTH, WHEIGHT, 0); do_draw(); GrMapWindow(swindow); GrMapWindow(offscreen); /* Draw the instructions into the buffer */ draw_string( (char *) welcome, 1); while(fin != 1) { GR_EVENT event; /* We start at 130ms, but it goes down every */ /* time a nibble is eaten */ /* If they get this far, then they rock! */ if (game_speed < 5) game_speed = 5; GrGetNextEventTimeout(&event, game_speed); switch(event.type) { case GR_EVENT_TYPE_EXPOSURE: case GR_EVENT_TYPE_KEY_DOWN: nxsnake_handle_event(&event); break; case GR_EVENT_TYPE_TIMER: handle_idle(); break; } } return(1); }
/*------------------------------------------------------------------------ * Display call back * * Input: none * Output: * it will draw a box (which is the same size as the brain) and a yellow * sphere, if no datafile is specified (when running ./stereoTest -stereo) * * Otherwise, it will draw a box and a brain. * (when running ./stereoTest -stereo -f ./test.data) * * The model is set to be behind the screen when it is first loaded. */ static void draw(void) { XYZ r; double ratio, radians, wd2, ndfl; double left, right, top, bottom; /* Clip to avoid extreme stereo */ double near = camera.focallength / 5; double far = (Yminmax[1]-Yminmax[2]) * 40.0; /* Misc stuff */ ratio = camera.screenwidth / (double) camera.screenheight; radians = DTOR * camera.aperture / 2.; wd2 = near * tan(radians); ndfl = near / camera.focallength; /* Clear the buffers */ glDrawBuffer(GL_BACK_LEFT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDrawBuffer(GL_BACK_RIGHT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Derive the two eye positions */ CROSSPROD(camera.vd, camera.vu, r); Normalise(&r); r.x *= camera.eyesep / 2.0; r.y *= camera.eyesep / 2.0; r.z *= camera.eyesep / 2.0; // left eye glMatrixMode(GL_PROJECTION); glLoadIdentity(); left = -ratio * wd2 - 0.5 * camera.eyesep * ndfl; right = ratio * wd2 - 0.5 * camera.eyesep * ndfl; top = wd2; bottom = -wd2; glFrustum(left, right, bottom, top, near*2, far); glMatrixMode(GL_MODELVIEW); glDrawBuffer(GL_BACK_RIGHT); glLoadIdentity(); gluLookAt(camera.vp.x + r.x, camera.vp.y + r.y, camera.vp.z + r.z, camera.vp.x + r.x + camera.vd.x, camera.vp.y + r.y + camera.vd.y, camera.vp.z + r.z + camera.vd.z, camera.vu.x, camera.vu.y, camera.vu.z); do_draw(); // right eye glMatrixMode(GL_PROJECTION); glLoadIdentity(); left = -ratio * wd2 + 0.5 * camera.eyesep * ndfl; right = ratio * wd2 + 0.5 * camera.eyesep * ndfl; top = wd2; bottom = -wd2; glFrustum(left, right, bottom, top, near*2, far); glMatrixMode(GL_MODELVIEW); glDrawBuffer(GL_BACK_LEFT); glLoadIdentity(); gluLookAt(camera.vp.x - r.x, camera.vp.y - r.y, camera.vp.z - r.z, camera.vp.x - r.x + camera.vd.x, camera.vp.y - r.y + camera.vd.y, camera.vp.z - r.z + camera.vd.z, camera.vu.x, camera.vu.y, camera.vu.z); do_draw(); //glutSwapBuffers(); }