예제 #1
0
파일: lab3.c 프로젝트: worm6206/lab3
//draw cylinder based on two circles and multiple triangles
void draw_cylinder (float baser, float topr, float h, int slices, float color[3],bool center,glm::mat4 M ) 
{
  glPushMatrix();
  glMultMatrixf(&M[0][0]);
  if(center) glTranslatef(0,0,h/2);

  glTranslatef(0,0,h/2);
  draw_circle(topr,color);
  glTranslatef(0,0,-h);
  draw_circle(baser,color);
  glTranslatef(0,0,h/2);
  for (int i = 0; i < slices; ++i)
  {
    //sida = 360/slices
    draw_triangle(baser*cos(i*2*PI/slices),baser*sin(i*2*PI/slices),-h/2,
                  baser*cos((i+1)*2*PI/slices),baser*sin((i+1)*2*PI/slices),-h/2,
                  topr*cos(i*2*PI/slices),topr*sin(i*2*PI/slices),h/2);

    draw_triangle(topr*cos(i*2*PI/slices),topr*sin(i*2*PI/slices),h/2,
                  topr*cos((i+1)*2*PI/slices),topr*sin((i+1)*2*PI/slices),h/2,
                  baser*cos((i+1)*2*PI/slices),baser*sin((i+1)*2*PI/slices),-h/2);
  }
  //draw_triangle(base,-1,-h/2, -1,-1,-h/2, -1,1,-h/2);



  glPopMatrix();
}
예제 #2
0
파일: gdowait.cpp 프로젝트: bratkov/tmos
void GWait::draw_this(LCD_MODULE* lcd)
{
	uint8_t mask=1;
	if(R > 5)
	{
		POINT_T p;//, r(R-2,R-2);
		for(int i=0; i < 8; i++, mask <<=1)
		{
			p = PolarToDevXY(i*45, R-4, lcd);
			p += base;
			if(last_state & mask)
			{
				lcd->color = PIX_BLACK;
				fill_circle(p, 2);
				lcd->color = PIX_WHITE;
				draw_circle(p, 2);
				continue;
			}
			if(new_state & mask)
				fill_circle(p, 2);
			else
				draw_circle(p, 2);
		}
	}
}
예제 #3
0
static void sun_layer_update(Layer *layer, GContext *ctx) {
  if (data_loaded) {
    const GRect entire_screen = GRect(0, 0, 180, 180);
    const GRect sun_outline_rect = GRect(70, 70, 40, 40);
    const GRect sun_rect = GRect(72, 72, 36, 36);

    draw_circle(ctx, entire_screen, GColorVividCerulean, 90, 360);

    graphics_context_set_stroke_color(ctx, GColorChromeYellow);
    graphics_context_set_stroke_width(ctx, 2);

    int i;
    for (i = 0; i < 360; i += 12) {
      const GPoint in = gpoint_from_polar(
        sun_outline_rect,
        GOvalScaleModeFitCircle,
        DEG_TO_TRIGANGLE(i)
      );
      const GPoint out = gpoint_from_polar(
        entire_screen,
        GOvalScaleModeFitCircle,
        DEG_TO_TRIGANGLE(i)
      );
      graphics_draw_line(ctx, out, in);
    }

    draw_circle(ctx, sun_outline_rect, GColorWindsorTan, 20, 360);
    draw_circle(ctx, sun_rect, GColorOrange, 18, 360);
  }
}
예제 #4
0
파일: Wristband.cpp 프로젝트: OpenGP/htrack
void energy::Wristband::track(LinearSystem &system)
{
    if(!handfinder->wristband_found()) return;
    if(!classifier_enable) return;

    /// @brief ugly hack to flip the direction of the PCA axis
    /// Ugly, but sufficient to get the teaser video recording!
    if(classifier_temporal){
        static Vector3 prev_wband_dir(0,1,0);
        if(handfinder->wristband_direction().dot(prev_wband_dir)<0)
            handfinder->wristband_direction_flip();
        prev_wband_dir = handfinder->wristband_direction();
    }

    int hand_id = skeleton->getID("Hand");
    Vector3 hand_root = skeleton->getJoint("Hand")->getGlobalTranslation();
    Vector3 wband_offpoint = handfinder->wristband_center() + handfinder->wristband_direction()*100;

    Vector2 root_scr = camera->world_to_image(hand_root);
    Vector2 wband_center_scr = camera->world_to_image(handfinder->wristband_center());
    Vector2 wband_offpnt_scr = camera->world_to_image(wband_offpoint);

#ifdef DEBUG_VIZ
    image = current_frame.color.clone();
    draw_circle(image, root_scr, cv::Scalar(255,0,0));
    draw_circle(image, wband_center_scr, cv::Scalar(0,255,0));
    draw_line(image, wband_center_scr, wband_offpnt_scr);
    cv::imshow("image", image);
#endif

    Vector2 n_wrist2 = (wband_center_scr-wband_offpnt_scr).normalized();
    n_wrist2 = Vector2(n_wrist2[1], -n_wrist2[0]);

    ///--- LHS
    Matrix_3xN J_sk = skeleton->jacobian(hand_id, hand_root);
    Matrix_2x3 J_pr = camera->projection_jacobian(hand_root);
    Matrix_1xN J = n_wrist2.transpose() * J_pr * J_sk;

    ///--- RHS
    Scalar rhs = n_wrist2.transpose() * (wband_center_scr - root_scr);

    ///--- Add to solver
    Scalar weight = classifier_weight;
    system.lhs += weight * J.transpose() * J;
    system.rhs += weight * J.transpose() * rhs;

    // std::ofstream("lhs.txt") << transp(J) * J;
    // std::ofstream("rhs.txt") << transp(J) * rhs;

    ///--- Visualize
    if(classifier_show_axis)
    {
        DebugRenderer::instance().clear();
        // Debug_renderer::instance().add_points(pts, Vector3(1,0,0));
        std::vector<std::pair<Vector3, Vector3>> segs;
        segs.push_back( std::make_pair(handfinder->wristband_center(), handfinder->wristband_center() + handfinder->wristband_direction()*100) );
        DebugRenderer::instance().add_segments(segs,Vector3(1,0,0));
    }
}
예제 #5
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_t *surface;

    cairo_translate (cr, PAD, PAD);

    cairo_save (cr);

    /* Draw overlapping circle and fallback circle */
    cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
    draw_circle (cr, CIRCLE_SIZE*0.5,  CIRCLE_SIZE*1.5);

    cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
    draw_circle (cr, CIRCLE_SIZE*0.75, CIRCLE_SIZE*1.75);

    /* Draw circles */
    cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
    cairo_translate (cr, CIRCLE_SIZE*2.5, CIRCLE_SIZE*0.6);
    draw_circles (cr);

    /* Draw fallback circles */
    cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
    cairo_translate (cr, 0, CIRCLE_SIZE*2);
    draw_circles (cr);

    cairo_restore (cr);
    cairo_translate (cr, 0, CIRCLE_SIZE * 3.5);

    /* Draw using fallback surface */
    surface = surface_create (cr);

    cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
    draw_circle (cr, CIRCLE_SIZE*0.5,  CIRCLE_SIZE*1.5);

    cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
    draw_image_circle (cr, surface, CIRCLE_SIZE/4, CIRCLE_SIZE + CIRCLE_SIZE/4);

    /* Draw circles */
    cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
    cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
    cairo_translate (cr, CIRCLE_SIZE*2.5, CIRCLE_SIZE*0.6);
    draw_circles (cr);

    cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
    cairo_translate (cr, -CIRCLE_SIZE/2, CIRCLE_SIZE*1.5);
    draw_image_circles (cr, surface);

    cairo_surface_destroy (surface);

    return CAIRO_TEST_SUCCESS;
}
예제 #6
0
파일: main.cpp 프로젝트: codders/soylent
void draw_avatar(Avatar* av) {
    glPushMatrix();
    glTranslatef(av->pos.x, av->pos.y, 0);
    glScalef(av->radius, av->radius, 1);
    draw_circle(true);
    glScalef(av->range / av->radius, av->range / av->radius, 1);
    draw_circle(false);
    glPopMatrix();
}
예제 #7
0
static void
draw_circles (cairo_t *cr)
{
    draw_circle (cr, 0,               -CIRCLE_SIZE*0.1);
    draw_circle (cr, CIRCLE_SIZE*0.4,  CIRCLE_SIZE*0.25);

    draw_circle (cr, CIRCLE_SIZE*2, 0);
    draw_circle (cr, CIRCLE_SIZE*4, 0);
    draw_circle (cr, CIRCLE_SIZE*6, 0);
}
예제 #8
0
// Constructor
RotateManipulator::RotateManipulator (Rotatable& rotatable, std::size_t segments, float radius) :
    m_free(rotatable), m_axis(rotatable), m_circle_x((segments << 2) + 1), m_circle_y((segments << 2) + 1), m_circle_z(
        (segments << 2) + 1), m_circle_screen(segments << 3), m_circle_sphere(segments << 3)
{
    draw_semicircle(segments, radius, m_circle_x.m_vertices.data(), RemapYZX());
    draw_semicircle(segments, radius, m_circle_y.m_vertices.data(), RemapZXY());
    draw_semicircle(segments, radius, m_circle_z.m_vertices.data(), RemapXYZ());

    draw_circle(segments, radius * 1.15f, m_circle_screen.m_vertices.data(), RemapXYZ());
    draw_circle(segments, radius, m_circle_sphere.m_vertices.data(), RemapXYZ());
}
예제 #9
0
// Given the coordinates of two endpoints, finds the y = mx + b equation for the 
// line and draws dots for every pixel in the relatively less constrained 
// dimmension
void draw_line(unsigned char pixelArray[PIXEL_DIMMENSION][PIXEL_DIMMENSION], 
		double brushRadius, int startY, int startX, int endY, int endX) {
	double slope = (double)(endY - startY) / (endX - startX);
	double b = calculate_b(startX, startY, slope);

	// if abs(slope) is less than 1, do operations on x, more than 1, y
	// if start of point is less that end, increment, otherwise decrement 
	int i;
	if (abs(slope) < 1) {
		if (startX >= endX) {
			for (i = startX; i >= endX; --i) {
				double y = calculate_other_coordinate('y', i, slope, b);
				if (startY == endY) {
					double y = startY;
				}
				draw_circle(pixelArray, PIXEL_DIMMENSION - i, round(y), 
						brushRadius);
			}
		} else {
			for (i = startX; i <= endX; ++i) {
				double y = calculate_other_coordinate('y', i, slope, b);
				if (startY == endY) {
					double y = startY;
				}
				draw_circle(pixelArray, PIXEL_DIMMENSION - i, round(y), 
						brushRadius);
			}
		}
	} else {
		if (startY >= endY) {
			for (i = startY; i >= endY; --i) {
				double x;
				if (startX == endX) {
					x = startX;
				} else {
					x = calculate_other_coordinate('x', i, slope, b);
				}
				draw_circle(pixelArray, PIXEL_DIMMENSION - round(x), i, 
						brushRadius);
			}
		} else {
			for (i = startY; i <= endY; ++i) {
				double x;
				if (startX == endX) {
					x = startX;
				} else {
					x = calculate_other_coordinate('x', i, slope, b);
				}
				draw_circle(pixelArray, PIXEL_DIMMENSION - round(x), i, 
						brushRadius);
			}
		}	
	}
}
예제 #10
0
파일: simple_drawing.c 프로젝트: atkm/cs441
void n_circles(cairo_t *cr, int n, double interval){
  // Draw n circles
  draw_circle(cr, interval*1.5, interval, 0);
  int i;
  for (i=1; i<n; i++){
    if (i%8 == 0){
      cairo_translate(cr, (-1)*interval*(8 + ((i/8)%2)) , interval);
      draw_circle(cr, interval*1.5, 0, i);
    }
    else
      draw_circle(cr, interval, 0, i);
  }
}
예제 #11
0
void draw(const Planet& p) {
    glPushMatrix();
    glColor4fv(color::planet_color);
    glColor4fv(color::WHITE);
    image::atm_image->activate();
    draw_circle(p.x(), p.y(), p.r());
    image::atm_image->deactivate();
    glColor4fv(color::WHITE);
    image::planet_images[p.type]->activate();
    draw_circle(p.x(), p.y(), p.inr());
    image::planet_images[p.type]->deactivate();
    glPopMatrix();
}
예제 #12
0
void draw(){
	if(testunit==0){
		display_string(2,title);
		display_string(3,author);
	}else if(testunit==1){
		display_string(1,string_line);
		draw_line(20+frame*4,20,40+frame*4,40);
		draw_line(40+frame*4,20,20+frame*4,40);
		draw_line(30+frame*4,20,30+frame*4,40);
		draw_line(20+frame*4,30,40+frame*4,30);
	}else if(testunit==2){
		display_string(1,string_box);
		draw_box(20,20,20,20,0);
		draw_box(30+frame*4,30,20,20,1);
	}else if(testunit==3){
		display_string(1,string_circle);
		draw_circle(30,30,10,0);
		draw_circle(40+frame*4,40,10,1);
	}else if(testunit==4){
		display_string(1,string_font1);
		display_string_58(0,15,test_string_l,0,1);
		display_string_58(0,24,test_string_l_2,0,1);
		display_string_58(0,33,test_string_s,0,1);
		display_string_58(0,42,test_string_s_2,0,1);
	}else if(testunit==5){
		display_string(1,string_font1);
		display_string_58(20+frame*2,20,test_string,90,1);
	}else if(testunit==6){
		display_string(1,string_font1);
		display_string_58(40+frame*2,30,test_string,180,1);
	}else if(testunit==7){
		display_string(1,string_font1);
		display_string_58(20+frame*2,40,test_string,270,1);
	}else if(testunit==8){
		display_string(2,finish);
	}
	if(frame==15){
		frame=0;
		if(testunit==8){
			;
		}else{
			testunit++;
		}
	}else{
		frame++;
	}
	delayms(100);
}
예제 #13
0
void draw_fisheye_magnifier(ViewInfo * view)
{
    if (get_mode(view)==MM_FISHEYE_MAGNIFIER) {
	float a;
	GLfloat mg_x, mg_y, mg_z;
	a = GetOGLDistance((int) view->fmg.constantR);
	view->fmg.R = (int) a;
	GetOGLPosRef((int) view->mouse.pos.x, (int) view->mouse.pos.y,
		     &mg_x, &mg_y, &mg_z);
	glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
		  (GLfloat) 1);
	if ((view->fmg.x != mg_x) || (view->fmg.y != mg_y)) {
	    if (view->active_camera == -1) {
		/* fisheye_polar(mg_x, mg_y, view->Topview); */
		draw_circle(mg_x, mg_y, a);
	    }
	    else {
		/* fisheye_spherical(mg_x, mg_y, 0.00, view->Topview); */
		if (!fisheyesphere)
		    fisheyesphere = gluNewQuadric();
		gluQuadricDrawStyle(fisheyesphere, GLU_LINE);
		glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8, (GLfloat) 0.05);
		glTranslatef(mg_x, mg_y, 0);
		gluSphere(fisheyesphere, a, 30, 30);
		glTranslatef(-mg_x, -mg_y, 0);
	    }
	    view->fmg.x = mg_x;
	    view->fmg.y = mg_y;
	}
    }
}
예제 #14
0
파일: boxshadow.c 프로젝트: add0/LCUI
static void Graph_DrawBottomRightShadow( LCUI_PaintContext paint, LCUI_Rect *box,
					 LCUI_BoxShadow *shadow )
{
	LCUI_Graph canvas;
	LCUI_Rect bound;
	LCUI_Pos pos;
	
	bound.x = BoxShadow_GetX( shadow ) + BLUR_WIDTH(shadow);
	bound.x += BoxShadow_GetBoxWidth( shadow, box->w );
	bound.x += INNER_SHADOW_WIDTH(shadow)*2;
	bound.y = BoxShadow_GetY( shadow ) + BLUR_WIDTH(shadow);
	bound.y += BoxShadow_GetBoxHeight( shadow, box->h );
	bound.y += INNER_SHADOW_WIDTH(shadow)*2;
	bound.w = bound.h = BLUR_WIDTH(shadow);
	pos.x = 0;
	pos.y = 0;
	if( LCUIRect_GetOverlayRect( &bound, &paint->rect, &bound ) ) {
		bound.x -= paint->rect.x;
		bound.y -= paint->rect.y;
		pos.x -= paint->rect.x;
		pos.y -= paint->rect.y;
		Graph_Quote( &canvas, &paint->canvas, &bound );
		draw_circle( &canvas, pos, bound.w, shadow->color );
	}
}
예제 #15
0
static gboolean
on_expose_event(GtkWidget      *widget,
		GdkEventExpose *event,
		gpointer        data)
{
	cairo_t *cr;
	gint x, y, width, height;
	int i;
	cr = gdk_cairo_create(widget->window);

	gdk_window_get_position(widget->window, &x, &y);
	gdk_drawable_get_size(widget->window, &width, &height);

	
	cairo_set_source_rgb (cr, 0, 0, 0);
	//cairo_set_source(cr, bgpattern);
	cairo_paint (cr);

	for (i = 0; i < NUM_CIRCLES; ++i) {
		draw_circle(cr, width, height, circles + i);
	}

	cairo_destroy(cr);

	return FALSE;
}
예제 #16
0
파일: 2dwrap.c 프로젝트: Comanche93/eech
void draw_2d_circle (float x, float y, const float r, const rgb_colour col)
{
	float
		xt,
		yt,
		rt;

	ASSERT (active_2d_environment);

	validate_2d_composite_transformation_matrix (active_2d_environment);

	xt = (x * active_2d_environment->composite_transformation[0][0]) +
		  (y * active_2d_environment->composite_transformation[1][0]) +
		  active_2d_environment->composite_transformation[2][0];

	yt = (x * active_2d_environment->composite_transformation[0][1]) +
		  (y * active_2d_environment->composite_transformation[1][1]) +
		  active_2d_environment->composite_transformation[2][1];

	rt = r * active_2d_environment->window_scaling[0][0];

	xt += active_2d_environment->offset_x * active_2d_environment->window_scaling[0][0] * 0.9;
	yt -= active_2d_environment->offset_y * active_2d_environment->window_scaling[1][1] * 0.9;

	draw_circle (xt, yt, rt, col);
}
예제 #17
0
void	draw_flat_map(t_map *map, t_img *img)
{
	float	s;
	t_pix	i;
	t_pix	os;

	s = FT_MIN(img->width / (float)map->width,
	img->height / (float)map->height) * 0.9;
	os.x = img->width / 2 - map->width * s / 2;
	os.y = img->height / 2 - map->height * s / 2;
	i.x = -1;
	while (++i.x < map->width)
	{
		i.y = -1;
		while (++i.y < map->height)
		  {
		    draw_tex(img, tile_at_index(map, i.x, i.y), (t_pix){i.x + os.x / s, i.y + os.y / s}, s);
		  }
	}
	set_color(0xFF0000);
	i = (t_pix){map->eye->pos.x * s + os.x, map->eye->pos.y * s + os.y};
	draw_circle(img, i, s / 2);
	set_color(0xFFFF00);
	draw_line(img, i, (t_pix){i.x + map->eye->dir.x * s,
				i.y + map->eye->dir.y * s});
	set_color(0x00FF00);
	draw_line(img, i, (t_pix){i.x + (map->eye->dir.x + map->eye->plane.x) * s,
				i.y + (map->eye->dir.y + map->eye->plane.y) * s});
	draw_line(img, i, (t_pix){i.x + (map->eye->dir.x - map->eye->plane.x) * s,
				i.y + (map->eye->dir.y - map->eye->plane.y) * s});
}
예제 #18
0
static void
d_draw_line (GfigObject *obj,
             cairo_t    *cr)
{
  DobjPoints *spnt;
  DobjPoints *epnt;

  spnt = obj->points;

  if (!spnt)
    return; /* End-of-line */

  epnt = spnt->next;

  while (spnt && epnt)
    {
      draw_sqr (&spnt->pnt, obj == gfig_context->selected_obj, cr);
      /* Go around all the points drawing a line from one to the next */
      gfig_draw_line (spnt->pnt.x, spnt->pnt.y, epnt->pnt.x, epnt->pnt.y, cr);
      spnt = epnt;
      epnt = epnt->next;
    }
  if (obj_creating == obj)
    draw_circle (&spnt->pnt, TRUE, cr);
  else
    draw_sqr (&spnt->pnt, obj == gfig_context->selected_obj, cr);
}
예제 #19
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolShape::update(bool global){
	if(!global){
		clearTempPathContext(false);
	}
	if((get_active())&&(get_on_drag())){
		if(get_mnu_cmd()==kShapeRect){
			if(_ctr){
				draw_c_rect();
			}
			else{
				draw_rect();
			}
		}
		else{
			if(_ctr){
				draw_c_circle();
			}
			else{
				draw_circle();
			}
		}
	}
	if(!global){
		validTempPathContext();
	}
}
예제 #20
0
static void ring_layer_update(Layer *layer, GContext *ctx) {
  if (data_loaded) {
    const GRect entire_screen = GRect(0, 0, 180, 180);
    draw_circle(ctx, entire_screen, GColorWhite, 20, 360);
    graphics_context_set_stroke_color(ctx, GColorOxfordBlue);
    graphics_context_set_stroke_width(ctx, 10);

    const GRect time_orbit = GRect(10, 10, 160, 160);

    int degree_icon = degreeify(hour, minute);
    int degree_rise = degreeify(hour_rise, minute_rise);
    int degree_set = degreeify(hour_set, minute_set);
    
    GBitmap *icon = degree_icon >= degree_set && degree_icon <= degree_rise ? moon : sun;

    const GRect icon_space = grect_centered_from_polar(
      time_orbit,
      GOvalScaleModeFitCircle,
      DEG_TO_TRIGANGLE(degree_icon),
      GSize(18, 18)
    );

    graphics_context_set_compositing_mode(ctx, GCompOpSet);
    graphics_draw_bitmap_in_rect(ctx, icon, icon_space);
  }
}
예제 #21
0
static pdf_obj *draw_radio_button(fz_context *ctx, pdf_annot *annot, fz_rect bbox, fz_matrix matrix, float w, float h, int yes)
{
	pdf_obj *ap;
	fz_buffer *buf;
	float b;

	buf = fz_new_buffer(ctx, 1024);
	fz_try(ctx)
	{
		fz_append_string(ctx, buf, "q\n");
		if (pdf_write_MK_BG_appearance(ctx, annot, buf))
			draw_circle_in_box(ctx, buf, "f\n", 0, 0, 0, w, h);
		b = pdf_write_border_appearance(ctx, annot, buf);
		if (b > 0 && pdf_write_MK_BC_appearance(ctx, annot, buf))
			draw_circle_in_box(ctx, buf, "s\n", b, 0, 0, w, h);
		if (yes)
		{
			fz_append_string(ctx, buf, "0 g\n");
			draw_circle(ctx, buf, "f\n", (w-b*2)/4, (h-b*2)/4, w/2, h/2);
		}
		fz_append_string(ctx, buf, "Q\n");
		ap = pdf_new_xobject(ctx, annot->page->doc, bbox, matrix, NULL, buf);
	}
	fz_always(ctx)
		fz_drop_buffer(ctx, buf);
	fz_catch(ctx)
		fz_rethrow(ctx);
	return ap;
}
예제 #22
0
파일: force.cpp 프로젝트: luqui/luqui-misc
int main(int argc, char** argv)
{
    init_gfx();
    init_2d();
    
    world = dWorldCreate();

    dBodyID ball = dBodyCreate(world);
    dBodySetPosition(ball, 0, 0, 0);

    for (;;) {
        Uint8* chars = SDL_GetKeyState(NULL);

        if (chars[SDLK_LEFT]) {
            dBodyAddForce(ball, -force, 0, 0);
        }
        if (chars[SDLK_RIGHT]) {
            dBodyAddForce(ball, +force, 0, 0);
        }
        if (chars[SDLK_UP]) {
            dBodyAddForce(ball, 0, +force, 0);
        }
        if (chars[SDLK_DOWN]) {
            dBodyAddForce(ball, 0, -force, 0);
        }

        const dReal* pos = dBodyGetPosition(ball);
        glTranslatef(pos[0], pos[1], pos[2]);
        draw_circle();

        dWorldQuickStep(world, 0.01);
        step();
    }
}
예제 #23
0
파일: test_pat_G.c 프로젝트: ttill/frei0r
//-----------------------------------------------------------
//draws a bullseye pattern
void tarca(unsigned char *sl, int w, int h, int size1, int size2, float ar)
{
unsigned char black,white;
int i;

black=0;
white=255;

for (i=0;i<(w*h);i++) sl[i]=black;	//black background

if (size1<20) size1=20;		//otherwise too slooooow...

draw_circle(sl, w, h, ar, w/2, h/2, 0, size2/2, white);
for (i=size1;i<(h/2);i=i+size1)
	draw_circle(sl, w, h, ar, w/2, h/2, i-size2/2, i+size2/2, white);
}
예제 #24
0
void board_layer_update_callback(Layer *layer, GContext* ctx) {
  graphics_context_set_stroke_color(ctx, COLOR_FOREGROUND);

  // Horizontal line
  graphics_draw_line_wide(ctx, GPoint(10, 89), GPoint(130, 89));
  draw_circle(ctx, GPoint(10, 10));
}
예제 #25
0
static void
d_draw_circle (GfigObject *obj,
               cairo_t    *cr)
{
  DobjPoints *center_pnt;
  DobjPoints *edge_pnt;
  gint        radius;

  center_pnt = obj->points;

  if (!center_pnt)
    return; /* End-of-line */

  draw_sqr (&center_pnt->pnt, obj == gfig_context->selected_obj, cr);

  edge_pnt = center_pnt->next;

  if (!edge_pnt)
    return;

  radius = calc_radius (&center_pnt->pnt, &edge_pnt->pnt);

  if (obj_creating == obj)
    draw_circle (&edge_pnt->pnt, TRUE, cr);
  else
    draw_sqr (&edge_pnt->pnt, obj == gfig_context->selected_obj, cr);

  gfig_draw_arc (center_pnt->pnt.x, center_pnt->pnt.y,
                 radius, radius, 0, 360, cr);
}
예제 #26
0
int main(int argc, char** argv)
{
    init_gfx();
    init_2d();
 
    // create world and set gravity   
    world = dWorldCreate();
    dWorldSetGravity(world, 0, -5, 0);
    
    // create a body for our ball
    dBodyID body = dBodyCreate(world);
    dBodySetPosition(body, 0, 0, 0);

    for (;;) {  // infinite loop

        // get the position and move there in OpenGL
        const dReal* pos = dBodyGetPosition(body);
        glTranslatef(pos[0], pos[1], pos[2]);
        
        draw_circle();

        // integrate all bodies
        dWorldQuickStep(world, 0.01);

        // redraw screen
        step();
    }
}
예제 #27
0
파일: paint2.c 프로젝트: opq290/software2
void circle_command(){
  int x0,y0,r;
  x0 = atoi(strtok(NULL," "));
  y0 = atoi(strtok(NULL," "));
  r  = atoi(strtok(NULL," "));
  draw_circle(x0,y0,r);
}
예제 #28
0
파일: arena.cpp 프로젝트: VasanthKumar/FIRA
static void onMouseSelect( int event, int x, int y, int, void* )
{
    switch( event ){
		case CV_EVENT_MOUSEMOVE: 
			{
				if(sel)
				point = Point2f((float)x,(float)y);
				break;
			}		
		case CV_EVENT_LBUTTONDOWN:
			{
				point = Point2f((float)x,(float)y);
				sel = true;
				break;
			}
		case CV_EVENT_LBUTTONUP:
			{
				sel = false;
				point = Point2f((float)x,(float)y);
				draw_circle(imageC,point,10);
				cnt++;
				flagc=1;
				break;
			}
		}
}
예제 #29
0
// helper function for drawing - no more need to go mess with
// the main function when just want to change what to draw...
void draw() {

    int x;
    
    // some pixels
    for (x = 0; x < vinfo.xres; x+=5) {
        put_pixel(x, vinfo.yres / 2, WHITE);
    }

    // some lines (note the quite likely 'Moire pattern')
    for (x = 0; x < vinfo.xres; x+=20) {
        draw_line(0, 0, x, vinfo.yres - 1, GREEN);
    }
    
    // some rectangles
    draw_rect(vinfo.xres / 4, vinfo.yres / 2 + 10, vinfo.xres / 4, vinfo.yres / 4, PURPLE);    
    draw_rect(vinfo.xres / 4 + 10, vinfo.yres / 2 + 20, vinfo.xres / 4 - 20, vinfo.yres / 4 - 20, PURPLE);    
    fill_rect(vinfo.xres / 4 + 20, vinfo.yres / 2 + 30, vinfo.xres / 4 - 40, vinfo.yres / 4 - 40, YELLOW);    

    // some circles
    int d;
    for(d = 10; d < vinfo.yres / 6; d+=10) {
        draw_circle(3 * vinfo.xres / 4, vinfo.yres / 4, d, RED);
    }
    
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 6, ORANGE);
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 8, RED);

}
예제 #30
0
파일: drawer.c 프로젝트: LeFranck/T1_remake
/** Dibuja un nucleo */
static void draw_core(cairo_t* cr, Core* core)
{
    /** Obtenemos el radio de este core */
    double r = core_radius(core);
    /* Centro de la celda en espacio de imagen */
    double cx = CELL_SIZE / 2 + core -> x * CELL_SIZE/2;
    double cy = CELL_SIZE / 2 + core -> y * CELL_SIZE/2;

    /* Marcamos la posicion de este core para el que la necesite */
    core -> buildings[0] -> x = cx;
    core -> buildings[0] -> y = cy;


    draw_circle(cr, cx, cy, r + (BORDER_SIZE + CURVE_SIZE / 2)/2);

    // cairo_set_source_rgb(cr,120.0/255.0,120.0/255.0,120.0/255.0);
    cairo_set_source_rgb(cr,0,0,0);
    cairo_fill_preserve(cr);
    cairo_set_line_width(cr,BORDER_SIZE + CURVE_SIZE / 2);
    cairo_stroke(cr);




    color_dip(cr, core -> buildings[0] -> color);
    double mult = 1;
    while(mult > 0.1)
    {
        cairo_set_line_width(cr, mult * CURVE_SIZE);
        draw_circle(cr, cx, cy, mult * r);
        cairo_stroke(cr);
        if(core -> sides == 8)
        {
            mult *= 0.5;
        }
        else
        {
            mult *= 0.4;

        }
    }


    /* Se marca como que se dibujó en la pasada anterior */
    /* Asi siempre estará marcado como que no se ha dibujado */
    core -> buildings[0] -> drawn = draw_count - 1;
}