• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ draw_line函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中draw_line函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_line函数的具体用法?C++ draw_line怎么用?C++ draw_line使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了draw_line函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: draw_line

int BEE::draw_line(int x1, int y1, int x2, int y2, rgba_t color, bool is_hud) {
	return draw_line(x1, y1, x2, y2, get_enum_color(color), is_hud);
}
开发者ID:TheButlah,项目名称:BasicEventEngine,代码行数:3,代码来源:draw.cpp


示例2: main

int main() {

  screen s;
  color c;
 
  
  c.red = 0;
  c.green = 0;
  c.blue = 0;
  
  clear_screen(s);

  int i, j;

  for (i=0; i < YRES; i++)
    for (j=0; j < XRES; j++ )
      plot(s, c, i, j);
  
  c.green = MAX_COLOR;
  c.blue = MAX_COLOR;
  c.red = MAX_COLOR;

  //too lazy to finish the 2 of hearts

  draw_line(90, 1, 410, 1, s, c);
  draw_line(90, 499, 410, 499, s, c);
  draw_line(90, 1, 90, 499, s, c);
  draw_line(410, 1, 410, 499, s, c);
  draw_line(110, 480, 140, 480, s, c);
  draw_line(140, 480, 140, 460, s, c);
  draw_line(140, 460, 110, 445, s, c);
  draw_line(110, 445, 110, 425, s, c);
  draw_line(110, 425, 140, 425, s, c);

  draw_line(360, 20, 390, 20, s, c);
  draw_line(360, 20, 360, 40, s, c);
  draw_line(360, 40, 390, 55, s, c);
  draw_line(390, 55, 390, 75, s, c);
  draw_line(360, 75, 390, 75, s, c);

  //Note: Display may not work on your system
  //save_ppm and save_extension should be fine
  display(s);
  save_ppm(s, "pic.ppm");
  save_extension(s, "whatevs.png");
}  
开发者ID:stuydw,项目名称:line,代码行数:46,代码来源:main.c


示例3: draw_default_fixed_cockpit_clock_hands

void draw_default_fixed_cockpit_clock_hands (cockpit_panels panel)
{
	float
		hour_hand_value,
		minute_hand_value,
		second_hand_value,
		x_centre,
		y_centre;

	scale_data
		*hour_hand_scale,
		*minute_hand_scale,
		*second_hand_scale,
		*p;

	if (draw_virtual_cockpit_needles_on_fixed_cockpits)
	{
		return;
	}

	get_clock_hand_values (&hour_hand_value, &minute_hand_value, &second_hand_value);

	switch (panel)
	{
		////////////////////////////////////////
		case COCKPIT_PANEL_DOWN20_AHEAD:
		////////////////////////////////////////
		{
			x_centre = 45.0;

			y_centre = 388.0;

			hour_hand_scale = clock_small_hand_scale_down_20_ahead;

			minute_hand_scale = clock_large_hand_scale_down_20_ahead;

			second_hand_scale = clock_large_hand_scale_down_20_ahead;

			break;
		}
		////////////////////////////////////////
		case COCKPIT_PANEL_DOWN20_LEFT30:
		////////////////////////////////////////
		{
			x_centre = 317.0;

			y_centre = 349.0;

			hour_hand_scale = clock_small_hand_scale_down_20_left_30;

			minute_hand_scale = clock_large_hand_scale_down_20_left_30;

			second_hand_scale = clock_large_hand_scale_down_20_left_30;

			break;
		}
		////////////////////////////////////////
		case COCKPIT_PANEL_DOWN20_LEFT60:
		////////////////////////////////////////
		{
			x_centre = 589.0;

			y_centre = 386.0;

			hour_hand_scale = clock_small_hand_scale_down_20_left_60;

			minute_hand_scale = clock_large_hand_scale_down_20_left_60;

			second_hand_scale = clock_large_hand_scale_down_20_left_60;

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal (instrument_error);

			break;
		}
	}

	//
	// draw second hand over minute hand over hour hand
	//

	p = find_scale_value (hour_hand_scale, hour_hand_value);

	draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour);

	p = find_scale_value (minute_hand_scale, minute_hand_value);

	draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour);

	p = find_scale_value (second_hand_scale, second_hand_value);

	draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, red_needle_colour);

	if (test_cockpit_instruments && DEBUG_MODULE)
	{
//.........这里部分代码省略.........
开发者ID:Comanche93,项目名称:eech,代码行数:101,代码来源:df_instr.c


示例4: hough_lines

/*Hough space

180x120 x-y space to -->

angle
180
| OOOOOOOOOOOOOOOOOOOOOO
| OOOOOOOOOOOOOOOOOOOOOO
| OOOOOOOOOOOOOOOOOOOOOO
| OOOOOOOOOOOOOOOOOOOOOO
--------(diag)--------(diag*2)----->

*/
void hough_lines(U16* buf, U16 threshold_value,
                double resolution, U16 num_line, S16* p_radius, U16* p_theta,d_YUV* d_pixel_value){
	int width = 180, height = 120, r, c, i, j, k;
	U16 diagH = (U16)(sqrt((double)(180*180 + 120*120)));
	U16 diag = diagH*2;
	U16 res_step = (U16)(180/resolution); // In resolution 1, each step has 1 degree.
	U16 num_trans = diag*res_step;
	U16 hough_space[num_trans];
	U16 theta;
	memset(hough_space, 0, num_trans*sizeof(U16));

	for(r = 5; r < height - 5; r++){
	for(c = 5; c < width - 5; c++){

		int distance;
		// At each edge pixels
		if(BLUE_VALUE_IN565(buf[180*r + c]) > threshold_value){
			//printf("selected pixel : y=%d, x=%d\n", r, c);
			for(theta = 0; theta < 180; theta += (U16)resolution){
				distance = (int)(c*mysin(theta) + r*mycos(theta) + diagH + 0.5);
				hough_space[distance*res_step + (U16)(theta/resolution)]++;
			}
		}

	}
	}

	int highest_voted_pixel[6] = {0, 0, 0, 0, 0, 0};
	int highest_voted_pixel_index[6] = {0, 0, 0, 0, 0, 0};

	for(i = 0; i < num_trans; i++){
		if(hough_space[i] >= highest_voted_pixel[0]){
			// push highest_voted_pixel, index array
			for(j = 5; (j >= 0) && (hough_space[i] >= highest_voted_pixel[j]); j--){
				for(k = 1; k < j + 1; k++){
					highest_voted_pixel[k-1] = highest_voted_pixel[k];
					highest_voted_pixel_index[k-1] = highest_voted_pixel_index[k];
				}
				highest_voted_pixel[j] = hough_space[i];
				highest_voted_pixel_index[j] = i;
				break;
			}
		}
	}

	for(i = 0; i < 6; i++){
		p_radius[i] = (S16)(highest_voted_pixel_index[i]/res_step);
		p_theta[i] = (highest_voted_pixel_index[i] - p_radius[i]*res_step)*resolution;
		p_radius[i] -= diagH;
		//printf("line detected. voted : %d, index : %d,  r : %d / theta : %d\n", highest_voted_pixel[i], highest_voted_pixel_index[i], p_radius[i], p_theta[i]);
		//printf("\n");
	}
	float d_Usum=0,d_Vsum=0;
	for(i = 0; i < 6; i++){
		draw_line(buf, p_radius[i], p_theta[i],d_pixel_value);
		printf("each direct%d U_value : %0.3f, V_value : %0.3f\n",i+1,d_pixel_value->u_value,d_pixel_value->v_value);
	}

	/*for(line_count = 0; line_count < num_line; line_count++){
		printf("line no. %d  p_r : %d / p_t : %d\n", line_count, p_radius[line_count], p_theta[line_count]);
	}*/



}
开发者ID:shinik77,项目名称:VideoProcessingForSOC,代码行数:78,代码来源:graphic_api.c


示例5: main

int main()
{
	// 8位3通道图像
	image = cvCreateImage( cvSize( IMG_WIDTH, IMG_HEIGHT ), 
		IPL_DEPTH_8U, 3 );
	// 置零
	cvZero(image);
	
	temp = cvCloneImage( image );

	// 创建窗口并设置鼠标事件回调函数
	cvNamedWindow("Drawing");
	cvSetMouseCallback("Drawing", my_mouse_callback, (void*) image );

	while(1)
	{
		cvCopyImage( image, temp );

		switch(g_draw_mode)
		{
			// 画线模式
		case MODE_LINE:
			if(drawing_line)
				draw_line( temp );
			break;
			// 画圆模式
		case MODE_CIRCLE:
			if(drawing_circle)
				draw_circle( temp );
			break;
			// 画椭圆模式
		case MODE_ELLIPSE:
			if(drawing_ellipse)
				draw_ellipse( temp );
			break;
			// 画多边形模式
		case MODE_POLYGON:
			if(drawing_polygon)
				draw_polygon( temp );
			break;
		}
		cvShowImage("Drawing", temp);

		// Esc键退出
		// 对于不同的按键,画不同的图形(线、圆、椭圆、多边形)
		int choose = cvWaitKey(15);
		switch(choose)
		{
			// l-108 L-76
		case 76:
		case 108:
			printf("当前处于画线模式.\n");
			g_draw_mode = MODE_LINE;
			break;
			// c-99 C-67
		case 67:
		case 99:
			printf("当前处于画圆模式.\n");
			g_draw_mode = MODE_CIRCLE;
			break;
			// e-101 E-69
		case 69:
		case 101:
			printf("当前处于画椭圆模式.\n");
			g_draw_mode = MODE_ELLIPSE;
			break;
			// p-112 P-80
		case 80:
		case 112:
			printf("当前处于画多边形模式.\n");
			g_draw_mode = MODE_POLYGON;
			break;
			// Esc 退出
		case 27:
			goto end;
		}
	}

	end:
	// 释放资源
	cvReleaseImage( &image );
	cvReleaseImage( &temp );
	cvDestroyAllWindows();

	return 0;
}
开发者ID:qdsclove,项目名称:LearningOpenCV_Exercises,代码行数:86,代码来源:main.cpp


示例6: switch

void TextureProgress::_notification(int p_what){
	const float corners[12]={-0.125,-0.375,-0.625,-0.875,0.125,0.375,0.625,0.875,1.125,1.375,1.625,1.875};
	switch(p_what) {

		case NOTIFICATION_DRAW: {


			if (under.is_valid())
				draw_texture(under,Point2());
			if (progress.is_valid()) {
				Size2 s = progress->get_size();
				switch (mode) {
				case FILL_LEFT_TO_RIGHT: {
					Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
					draw_texture_rect_region(progress,region,region);
				} break;
				case FILL_RIGHT_TO_LEFT: {
					Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
					draw_texture_rect_region(progress,region,region);
				} break;
				case FILL_TOP_TO_BOTTOM: {
					Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
					draw_texture_rect_region(progress,region,region);
				} break;
				case FILL_BOTTOM_TO_TOP: {
					Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
					draw_texture_rect_region(progress,region,region);
				} break;
				case FILL_CLOCKWISE:
				case FILL_COUNTER_CLOCKWISE: {
					float val=get_unit_value()*rad_max_degrees/360;
					if (val==1) {
						Rect2 region=Rect2(Point2(),s);
						draw_texture_rect_region(progress,region,region);
					} else if (val!=0) {
						Array pts;
						float direction=mode==FILL_CLOCKWISE?1:-1;
						float start=rad_init_angle/360;
						float end=start+direction*val;
						pts.append(start);
						pts.append(end);
						float from=MIN(start,end);
						float to=MAX(start,end);
						for (int i=0;i<12;i++)
							if (corners[i]>from&&corners[i]<to)
								pts.append(corners[i]);
						pts.sort();
						Vector<Point2> uvs;
						Vector<Point2> points;
						uvs.push_back(get_relative_center());
						points.push_back(Point2(s.x*get_relative_center().x,s.y*get_relative_center().y));
						for (int i=0;i<pts.size();i++) {
							Point2 uv=unit_val_to_uv(pts[i]);
							if (uvs.find(uv)>=0)
								continue;
							uvs.push_back(uv);
							points.push_back(Point2(uv.x*s.x,uv.y*s.y));
						}
						draw_polygon(points,Vector<Color>(),uvs,progress);
					}
					if (get_tree()->is_editor_hint()) {
						Point2 p=progress->get_size();
						p.x*=get_relative_center().x;
						p.y*=get_relative_center().y;
						p=p.floor();
						draw_line(p-Point2(8,0),p+Point2(8,0),Color(0.9,0.5,0.5),2);
						draw_line(p-Point2(0,8),p+Point2(0,8),Color(0.9,0.5,0.5),2);
					}
				} break;
				default:
					draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
				}

				
			}
			if (over.is_valid())
				draw_texture(over,Point2());

		} break;
	}
}
开发者ID:AwsomeGameEngine,项目名称:godot,代码行数:81,代码来源:texture_progress.cpp


示例7: draw_line

 void draw_line (const Vector2d& pos1, const Vector2d& pos2, Color color, int wide = 0)
 {
   draw_line (pos1.x, pos1.y, pos2.x, pos2.y, color, wide);
 }
开发者ID:BackupTheBerlios,项目名称:construo-svn,代码行数:4,代码来源:graphic_context.hpp


示例8: draw_line

    void rasterizer::draw_triangle(int x0, int y0, int x1, int y1, int x2, int y2,
                                   const color_rgba8& c0, const color_rgba8& c1, const color_rgba8& c2)
    {
        
        int w = surface_->get_width();
        int h = surface_->get_height();
        if ((x0 < 0 || x0 > w) &&
            (y0 < 0 || y0 > h) &&
            (x1 < 0 || x1 > w) &&
            (y1 < 0 || y1 > h) &&
            (x2 < 0 || x2 > w) &&
            (y2 < 0 || y2 > h)) {
            // out of screen space...
            return;
        }
		// 退化为直线的情况
		if (((x0 == x1) && (x1 == x2)) || ((y0 == y1) && (y1 == y2))) {
			draw_line(x0, y0, x1, y1, c0, c1);
			draw_line(x0, y0, x2, y2, c0, c2);
			draw_line(x2, y2, x1, y1, c2, c1);
			return;
		}

		// ensure y0 < y1 < y2
		color_rgba8 tc0 = c0, tc1 = c1, tc2 = c2;
		if (y1 < y0) {// ensure y0 < y1
			std::swap(x0, x1);
			std::swap(y0, y1);
			std::swap(tc0, tc1);
		}
		if (y2 < y0) {// ensure y0 < y2
			std::swap(x0, x2);
			std::swap(y0, y2);
			std::swap(tc0, tc2);
		}
		if (y2 < y1) {// ensure y1 < y2
			std::swap(x1, x2);
			std::swap(y1, y2);
			std::swap(tc1, tc2);
		}

		enum trinagle_type
		{
			general = 0,
			flat_top = 1,
			flat_botton = 2
		};
		trinagle_type tt = general;
		if (y0 == y1) {
			tt = flat_top;
			if (x1 < x0) {
				std::swap(x0, x1);
				std::swap(y0, y1);
				std::swap(tc0, tc1);
			}
		}
		else if (y1 == y2) {
			tt = flat_botton;
			if (x2 < x1) {
				std::swap(x1, x2);
				std::swap(y1, y2);
				std::swap(tc1, tc2);
			}
		} else {
			tt = general;
		}

		float dxdy_left = 0.f;
		float dxdy_right = 0.f;
		float x_left = 0.f, x_right = 0.f;
		int y_start = 0, y_end = 0;
		int x_start = 0, x_end = 0;
		color_rgba8 c_start, c_end;
		color_rgba8 dc_left, dc_right;
		if (tt == general) {
			y_end = y2;
			if (y_end > h) y_end = h;
			int side = 0;
			int ys = y1; //转折点
			float dy_left = 0.f, dy_right = 0.f;
			if (y1 < 0) { //退化为平顶三角形
				//左右边斜率倒数
				dy_left = 1.f / (y2 - y1);
				dxdy_left = (x2 - x1) * dy_left;
				dy_right = 1.f / (y2 - y0);
				dxdy_right = (x2 - x0) * dy_right;
				//左右斜边初始值
				dy_right = -y0;
				dy_left = -y1;
				x_left = dxdy_left * dy_left + x1;
				x_right = dxdy_right * dy_right + x0;
				y_start = 0;
				if (dxdy_right > dxdy_left) {//交换
					std::swap(dxdy_left, dxdy_right);
					std::swap(x_left, x_right);
					std::swap(x1, x2);
					std::swap(y1, y2);
					std::swap(tc1, tc2);
					side = 1;
				}
//.........这里部分代码省略.........
开发者ID:nomadfighter,项目名称:softcore,代码行数:101,代码来源:rasterizer.cpp


示例9: main

int main() {

  screen s;
  color c;
 
  
  c.red = 50;
  c.green = 200;
  c.blue = 54;
  
  clear_screen(s);

  int i, j;

  for (i=0; i < YRES; i++)
    for (j=0; j < XRES; j++ )
      plot(s, c, i, j);
  
  c.green = 0;
  c.red = 0;
  c.blue=0;
  //  draw_line(20, 350, 300, 350, s, c); //oct 6
 i = 0;
 for(i;i<100;i++){
    draw_line(i,0,i,500,s,c);
    c.red = c.red +1;
 }
 c.red=0;
 i = 100;
 for(i;i<200;i++){
    draw_line(i,0,i,500,s,c);
    c.red = c.red +1;
 }
c.red=0;
 i = 200;
 for(i;i<300;i++){
    draw_line(i,0,i,500,s,c);
    c.red = c.red +1;
 }
c.red=0;
 i = 300;
 for(i;i<400;i++){
    draw_line(i,0,i,500,s,c);
    c.red = c.red +1;
 }
c.red=0;
 i = 400;
 for(i;i<500;i++){
    draw_line(i,0,i,500,s,c);
    c.red = c.red +1;
 }

 c.red = 255;
 c.green = 255;
 c.blue = 0;

 i = 0;

 for(i;i<100;i++){
    draw_line(i,0,500,500,s,c);
    draw_line(0,i,500,500,s,c);
    draw_line(500-i,0,0,500,s,c);
    draw_line(500,i,0,500,s,c);
 }
 c.red = 0;
 c.green = 0;
    draw_line(0,100,500,500,s,c);
    draw_line(100,0,500,500,s,c);

//Note: Display may not work on your system
  //save_ppm and save_extension should be fine
  //display(s);
  save_ppm(s, "pic.ppm");
  save_extension(s, "whatevs.png");
}  
开发者ID:stuydw,项目名称:line,代码行数:75,代码来源:main.c


示例10: setup_screen

void
setup_screen(const C_SCREEN *scp)
{
	static char	buffer[BUFSIZ];
	int	i, j;
	char	str[3];
	const char *airstr;

	initscr();
	/* size of screen depends on chosen game, but we need at least 80
	 * columns for "Information area" to work. */
	if (LINES < (INPUT_LINES + scp->height) ||
	    COLS < (PLANE_COLS + 2 * scp->width) ||
	    COLS < 80) {
		endwin();
		errx(1, "screen too small.");
	}
	setvbuf(stdout, buffer, _IOFBF, sizeof buffer);
	input = newwin(INPUT_LINES, COLS - PLANE_COLS, LINES - INPUT_LINES, 0);
	credit = newwin(INPUT_LINES, PLANE_COLS, LINES - INPUT_LINES, 
		COLS - PLANE_COLS);
	planes = newwin(LINES - INPUT_LINES, PLANE_COLS, 0, COLS - PLANE_COLS);

	str[2] = '\0';

	if (radar != NULL)
		delwin(radar);
	radar = newwin(scp->height, scp->width * 2, 0, 0);

	if (cleanradar != NULL)
		delwin(cleanradar);
	cleanradar = newwin(scp->height, scp->width * 2, 0, 0);

	/* minus one here to prevent a scroll */
	for (i = 0; i < PLANE_COLS - 1; i++) {
		wmove(credit, 0, i);
		waddch(credit, C_CREDIT);
		wmove(credit, INPUT_LINES - 1, i);
		waddch(credit, C_CREDIT);
	}
	wmove(credit, INPUT_LINES / 2, 1);
	waddstr(credit, AUTHOR_STR);

	for (i = 1; i < scp->height - 1; i++) {
		for (j = 1; j < scp->width - 1; j++) {
			wmove(radar, i, j * 2);
			waddch(radar, C_BACKROUND);
		}
	}

	/*
	 * Draw the lines first, since people like to draw lines
	 * through beacons and exit points.
	 */
	str[0] = C_LINE;
	for (i = 0; i < scp->num_lines; i++) {
		str[1] = ' ';
		draw_line(radar, scp->line[i].p1.x, scp->line[i].p1.y,
			scp->line[i].p2.x, scp->line[i].p2.y, str);
	}

	str[0] = C_TOPBOTTOM;
	str[1] = C_TOPBOTTOM;
	wmove(radar, 0, 0);
	for (i = 0; i < scp->width - 1; i++)
		waddstr(radar, str);
	waddch(radar, C_TOPBOTTOM);

	str[0] = C_TOPBOTTOM;
	str[1] = C_TOPBOTTOM;
	wmove(radar, scp->height - 1, 0);
	for (i = 0; i < scp->width - 1; i++)
		waddstr(radar, str);
	waddch(radar, C_TOPBOTTOM);

	for (i = 1; i < scp->height - 1; i++) {
		wmove(radar, i, 0);
		waddch(radar, C_LEFTRIGHT);
		wmove(radar, i, (scp->width - 1) * 2);
		waddch(radar, C_LEFTRIGHT);
	}

	str[0] = C_BEACON;
	for (i = 0; i < scp->num_beacons; i++) {
		str[1] = '0' + i;
		wmove(radar, scp->beacon[i].y, scp->beacon[i].x * 2);
		waddstr(radar, str);
	}

	for (i = 0; i < scp->num_exits; i++) {
		wmove(radar, scp->exit[i].y, scp->exit[i].x * 2);
		waddch(radar, '0' + i);
	}

	airstr = "^?>?v?<?";
	for (i = 0; i < scp->num_airports; i++) {
		str[0] = airstr[scp->airport[i].dir];
		str[1] = '0' + i;
		wmove(radar, scp->airport[i].y, scp->airport[i].x * 2);
		waddstr(radar, str);
//.........这里部分代码省略.........
开发者ID:radixo,项目名称:openbsd-src,代码行数:101,代码来源:graphics.c


示例11: wiki_trans_line

int wiki_trans_line( section_def *section, int alloc_size )
/*********************************************************/
{
    char                *ptr;
    char                *end;
    int                 ch;
    char                *ctx_name;
    char                *ctx_text;
    char                buf[500];
    int                 font_idx;
    int                 line_len;
    bool                term_fix;
    int                 ch_len;
    int                 len;
    char                *file_name;

    /* check for special column 0 stuff first */
    ptr = Line_buf;
    ch = *(unsigned char *)ptr;
    ch_len = 0;
    line_len = 0;

    switch( ch ) {

    case CH_TABXMP:
        if( *skip_blank( ptr + 1 ) == '\0' ) {
            Tab_xmp = FALSE;
            trans_add_str( "</pre>\n", section, &alloc_size );
            Blank_line_sfx = FALSE;     // remove following blanks
        } else {
            read_tabs( ptr + 1 );
            trans_add_str( "<pre>\n", section, &alloc_size );
            Tab_xmp = TRUE;
            Blank_line_pfx = FALSE;     // remove preceding blanks
        }
        return( alloc_size );

    case CH_BOX_ON:
        /* Table support is the closest thing to boxing in IPF, but it
           doesn't work well with changing fonts on items in the tables
           (the edges don't line up). So we draw long lines at the
           top and bottom instead */
        draw_line( section, &alloc_size );
        Blank_line_pfx = FALSE;
        return( alloc_size );

    case CH_BOX_OFF:
        draw_line( section, &alloc_size );
        Blank_line_sfx = FALSE;
        return( alloc_size );

    case CH_OLIST_START:
        trans_add_list( "# ", section, &alloc_size, ptr );
        Blank_line_pfx = FALSE;
        return( alloc_size );

    case CH_LIST_START:
        trans_add_list( "* ", section, &alloc_size, ptr );
        Blank_line_pfx = FALSE;
        return( alloc_size );

    case CH_DLIST_START:
        trans_add_str( "; ", section, &alloc_size );
        Blank_line_pfx = FALSE;
        return( alloc_size );

    case CH_SLIST_START:
        trans_add_list( "* ", section, &alloc_size, ptr );
        Blank_line_pfx = FALSE;
        return( alloc_size );

    case CH_SLIST_END:
        trans_add_str( "\n", section, &alloc_size );
        Blank_line_sfx = FALSE;
        return( alloc_size );

    case CH_OLIST_END:
        trans_add_str( "\n", section, &alloc_size );
        Blank_line_sfx = FALSE;
        return( alloc_size );

    case CH_LIST_END:
        trans_add_str( "\n", section, &alloc_size );
        Blank_line_sfx = FALSE;
        return( alloc_size );

    case CH_DLIST_END:
        trans_add_str( "\n", section, &alloc_size );
        Blank_line_sfx = FALSE;
        return( alloc_size );

    case CH_LIST_ITEM:
    case CH_DLIST_TERM:
        /* eat blank lines before list items and terms */
        Blank_line_pfx = FALSE;
        break;

    case CH_CTX_KW:
        ptr = whole_keyword_line( ptr );
        if( ptr == NULL ) {
//.........这里部分代码省略.........
开发者ID:NoSuchProcess,项目名称:open-watcom-v2,代码行数:101,代码来源:wiki.c


示例12: update_timer

void update_timer(int cycles_gone)
{
    static int collected = 0, vsync_collect = 0, div_collect = 0, redrawed = 0;
    #ifdef ENABLE_LINK
    static int serial_poll_collect = 0;
    #endif
    int hblank_start = 0;

    div_collect += cycles_gone;
    while (div_collect >= 64)
    {
        io_regs->div++;
        div_collect -= cycles_gone;
    }

    if (lcd_on)
    {
        vsync_collect += cycles_gone;

        io_regs->stat &= ~3;
        if (io_regs->ly >= 144)
            io_regs->stat |= 1;
        else
        {
            if (vsync_collect < 51)
                redrawed = 0;
            else if (vsync_collect < 71)
                io_regs->stat |= 2;
            else
            {
                io_regs->stat |= 3;
                if (!redrawed)
                {
                    draw_line(io_regs->ly);
                    redrawed = 1;
                }
            }
        }

        while (vsync_collect >= 114) // Eine Zeile wäre jetzt fertig
        {
            vsync_collect -= 114;

            #ifdef ENABLE_LINK
            if (!link_countdown && (++serial_poll_collect >= 10))
            {
                serial_poll_collect = 0;
                if (server != INVALID_CONN_VALUE)
                    tcp_server_poll(server);
                if (current_connection != INVALID_CONN_VALUE)
                    tcp_conn_poll(current_connection);
            }
            #endif

            hblank_start = 1;
            if (hdma_on)
                hdma_copy_16b();

            if (++io_regs->ly > 153)
                io_regs->ly = 0;
            if (io_regs->ly == 144)
            {
                io_regs->stat &= ~3;
                io_regs->stat |= 1;
                io_regs->int_flag |= INT_VBLANK;
            }

            if (io_regs->lyc == io_regs->ly)
            {
                io_regs->stat |= (1 << 2);
                if (io_regs->stat & (1 << 6))
                    io_regs->int_flag |= INT_LCDC_STAT;
            }
            else
                io_regs->stat &= ~(1 << 2);
        }

        if ((io_regs->stat & (1 << 5)) && ((io_regs->stat & 3) == 2))
            io_regs->int_flag |= INT_LCDC_STAT;
        else if ((io_regs->stat & (1 << 4)) && ((io_regs->stat & 3) == 1))
            io_regs->int_flag |= INT_LCDC_STAT;
        else if ((io_regs->stat & (1 << 3)) && hblank_start)
            io_regs->int_flag |= INT_LCDC_STAT;
    }

    #ifdef ENABLE_LINK
    if (link_countdown)
    {
        link_countdown -= cycles_gone;
        if (link_countdown <= 0)
            link_clock();
    }
    #endif

    if (!(io_regs->tac & (1 << 2)))
        return;

    collected += cycles_gone;
    while (collected >= collect_overflow[io_regs->tac & 3])
    {
//.........这里部分代码省略.........
开发者ID:XanClic,项目名称:xgbcemu,代码行数:101,代码来源:timer.c


示例13: switch

void RayCast2D::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			if (enabled && !get_tree()->is_editor_hint())
				set_fixed_process(true);
			else
				set_fixed_process(false);

			if (get_parent()->cast_to<PhysicsBody2D>()) {
				if (exclude_parent_body)
					exclude.insert( get_parent()->cast_to<PhysicsBody2D>()->get_rid() );
				else
					exclude.erase( get_parent()->cast_to<PhysicsBody2D>()->get_rid() );
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

			if (enabled)
				set_fixed_process(false);

		} break;

		case NOTIFICATION_DRAW: {

			if (!get_tree()->is_editor_hint()  && !get_tree()->is_debugging_collisions_hint())
				break;
			Matrix32 xf;
			xf.rotate(cast_to.angle());
			xf.translate(Vector2(0,cast_to.length()));

			//Vector2 tip = Vector2(0,s->get_length());
			Color dcol=get_tree()->get_debug_collisions_color();//0.9,0.2,0.2,0.4);
			draw_line(Vector2(),cast_to,dcol,3);
			Vector<Vector2> pts;
			float tsize=4;
			pts.push_back(xf.xform(Vector2(0,tsize)));
			pts.push_back(xf.xform(Vector2(0.707*tsize,0)));
			pts.push_back(xf.xform(Vector2(-0.707*tsize,0)));
			Vector<Color> cols;
			for(int i=0;i<3;i++)
				cols.push_back(dcol);

			draw_primitive(pts,cols,Vector<Vector2>()); //small arrow

		} break;


		case NOTIFICATION_FIXED_PROCESS: {

			if (!enabled)
				break;



			Ref<World2D> w2d = get_world_2d();
			ERR_BREAK( w2d.is_null() );

			Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
			ERR_BREAK( !dss );

			Matrix32 gt = get_global_transform();

			Vector2 to = cast_to;
			if (to==Vector2())
				to=Vector2(0,0.01);

			Physics2DDirectSpaceState::RayResult rr;

			if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {

				collided=true;
				against=rr.collider_id;
				collision_point=rr.position;
				collision_normal=rr.normal;
				against_shape=rr.shape;
			} else {
				collided=false;
			}



		} break;
	}
}
开发者ID:WalasPrime,项目名称:godot,代码行数:87,代码来源:ray_cast_2d.cpp


示例14: draw_lines

/*======== void draw_lines() ==========
Inputs:   struct matrix * points
         screen s
         color c 
Returns: 
Go through points 2 at a time and call draw_line to add that line
to the screen
====================*/
void draw_lines( struct matrix * points, screen s, color c) {
  int i;
  for (i = 0; i < points->lastcol - 1; i += 2) {
    draw_line(points->m[0][i], points->m[1][i], points->m[0][i+1], points->m[1][i+1], s, c);
  }
}
开发者ID:sarahjoseph723,项目名称:matrixx,代码行数:14,代码来源:draw.c


示例15: draw_tri

void draw_tri(FBDev *dev, int x1, int y1, int x2, int y2, int x3, int y3, uint32_t pixel) {
	draw_line(dev, x1, y1, x2, y2, pixel);
	draw_line(dev, x2, y2, x3, y3, pixel);
	draw_line(dev, x3, y3, x1, y1, pixel);
}
开发者ID:dluco,项目名称:fb,代码行数:5,代码来源:primitives.c


示例16: switch

void CollisionShape2D::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;
		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {

			if (!is_inside_tree())
				break;
			_update_parent();

		} break;
		/*
		case NOTIFICATION_TRANSFORM_CHANGED: {

			if (!is_inside_scene())
				break;
			_update_parent();

		} break;*/
		case NOTIFICATION_DRAW: {

			rect=Rect2();

			Color draw_col=Color(0,0.6,0.7,0.5);

			if (shape->cast_to<LineShape2D>()) {

				LineShape2D *l = shape->cast_to<LineShape2D>();
				Vector2 point = l->get_d() * l->get_normal();

				Vector2 l1[2]={point-l->get_normal().tangent()*100,point+l->get_normal().tangent()*100};
				draw_line(l1[0],l1[1],draw_col,3);
				Vector2 l2[2]={point,point+l->get_normal()*30};
				draw_line(l2[0],l2[1],draw_col,3);
				rect.pos=l1[0];
				rect.expand_to(l1[1]);
				rect.expand_to(l2[0]);
				rect.expand_to(l2[1]);

			} else if (shape->cast_to<SegmentShape2D>()) {

				SegmentShape2D *s = shape->cast_to<SegmentShape2D>();
				draw_line(s->get_a(),s->get_b(),draw_col,3);
				rect.pos=s->get_a();
				rect.expand_to(s->get_b());

			} else if (shape->cast_to<RayShape2D>()) {

				RayShape2D *s = shape->cast_to<RayShape2D>();

				Vector2 tip = Vector2(0,s->get_length());
				draw_line(Vector2(),tip,draw_col,3);
				Vector<Vector2> pts;
				float tsize=4;
				pts.push_back(tip+Vector2(0,tsize));
				pts.push_back(tip+Vector2(0.707*tsize,0));
				pts.push_back(tip+Vector2(-0.707*tsize,0));
				Vector<Color> cols;
				for(int i=0;i<3;i++)
					cols.push_back(draw_col);

				draw_primitive(pts,cols,Vector<Vector2>()); //small arrow

				rect.pos=Vector2();
				rect.expand_to(tip);
				rect=rect.grow(0.707*tsize);

			} else if (shape->cast_to<CircleShape2D>()) {

				CircleShape2D *s = shape->cast_to<CircleShape2D>();
				Vector<Vector2> points;
				for(int i=0;i<24;i++) {

					points.push_back(Vector2(Math::cos(i*Math_PI*2/24.0),Math::sin(i*Math_PI*2/24.0))*s->get_radius());
				}

				draw_colored_polygon(points,draw_col);
				rect.pos=-Point2(s->get_radius(),s->get_radius());
				rect.size=Point2(s->get_radius(),s->get_radius())*2.0;

			} else if (shape->cast_to<RectangleShape2D>()) {

				RectangleShape2D *s = shape->cast_to<RectangleShape2D>();
				Vector2 he = s->get_extents();
				rect=Rect2(-he,he*2.0);
				draw_rect(rect,draw_col);;

			} else if (shape->cast_to<CapsuleShape2D>()) {

				CapsuleShape2D *s = shape->cast_to<CapsuleShape2D>();

				Vector<Vector2> points;
				for(int i=0;i<24;i++) {
					Vector2 ofs = Vector2(0,(i>6 && i<=18) ? -s->get_height()*0.5 : s->get_height()*0.5);

					points.push_back(Vector2(Math::sin(i*Math_PI*2/24.0),Math::cos(i*Math_PI*2/24.0))*s->get_radius() + ofs);
					if (i==6 || i==18)
//.........这里部分代码省略.........
开发者ID:3miu,项目名称:godot,代码行数:101,代码来源:collision_shape_2d.cpp


示例17: draw_polygon

void draw_polygon(FBDev *dev, int *vx, int *vy, int n, uint32_t pixel) {
	int i;
	for (i = 0; i < n; i++) {
		draw_line(dev, vx[i], vx[(i+1)%n], vy[i], vy[(i+1)%n], pixel);
	}
}
开发者ID:dluco,项目名称:fb,代码行数:6,代码来源:primitives.c


示例18: render

static void render(struct widget *w)
{
    struct widget_priv *priv = w->priv;
    struct canvas *ca = &w->ca;
    int y, i, j;
    int x0, x1, y0, y1, offset, cx, cy;
    unsigned char size, gap;
    char buf[10];

    for (i = -RANGE/2; i <= RANGE/2; i++) {
        y = Y_CENTER - i;
        //j = priv->pitch_deg*SCALE + i;
        j = priv->pitch_deg + i;

        if (j % (MINOR_TICK*SCALE) == 0) {
            if (j == 0) {
                size = 40;
                gap = 10;
            } else {
                if (j % (MAJOR_TICK*SCALE) == 0)
                    size = 20;
                else
                    size = 10;
                gap = 10;
            }

            cx = X_CENTER + (int) (i * priv->sin_roll);
            cy = y + i - (int) (i * priv->cos_roll);

            if ((j != 0) && (j % (MAJOR_TICK*SCALE) == 0)) {
                sprintf(buf, "%d", j / SCALE);
                draw_jstr(buf, cx, cy, JUST_HCENTER | JUST_VCENTER, ca, 0);
            }
            
            offset = (int) gap * priv->cos_roll;
            x0 = cx + offset;
            offset = (int) size * priv->cos_roll;
            x1 = x0 + offset;

            
            offset = (int) gap * priv->sin_roll;
            y0 = cy + offset;
            offset = (int) size * priv->sin_roll;
            y1 = y0 + offset;
            
            if (j == 0) {
                draw_line(x0-1, y0-1, x1+1, y1-1, 3, ca);
                //draw_line(x0, y0-1, x1, y1-1, 1, ca);
            }
            draw_line(x0-1, y0+1, x1+1, y1+1, 3, ca);
            draw_line(x0, y0, x1, y1, 1, ca);

            offset = (int) gap * priv->cos_roll;
            x0 = cx - offset;
            offset = (int) size * priv->cos_roll;
            x1 = x0 - offset;


            offset = (int) gap * priv->sin_roll;
            y0 = cy - offset;
            offset = (int) size * priv->sin_roll;
            y1 = y0 - offset;

            if (j == 0) {
                draw_line(x0-1, y0-1, x1+1, y1-1, 3, ca);
                //draw_line(x0, y0-1, x1, y1-1, 1, ca);
            }
            draw_line(x0-1, y0+1, x1+1, y1+1, 3, ca);
            draw_line(x0, y0, x1, y1, 1, ca);

        }
    }


    draw_ohline(X_CENTER - 3, X_CENTER + 3, Y_CENTER, 1, 3, ca);
    draw_vline(X_CENTER, Y_CENTER - 3, Y_CENTER + 3, 1, ca);

    
    float cos_i, sin_i;

    for (i = -ROLL_RANGE/2; i <= ROLL_RANGE/2; i++) {
        y = Y_CENTER - i;
        //j = priv->pitch_deg*SCALE + i;
        //j = priv->roll_deg + i;

        if (i % (MINOR_ROLL_TICK) == 0) {
            gap = 70;
            if (i == 0) {
                size = 10;
            } else {
                if (i % (MAJOR_ROLL_TICK) == 0)
                    size = 10;
                else
                    size = 5;
            }

            cos_i = cos(DEG2RAD(i));
            sin_i = sin(DEG2RAD(i));
            
            cx = X_CENTER;// + (int) (gap * cos_i);
//.........这里部分代码省略.........
开发者ID:ljalves,项目名称:alceosd,代码行数:101,代码来源:horizon.c


示例19: draw_line

void DebugProcessor::draw_line(const Mat4f &transform, const Vec3f &start, const Vec3f &end, const Vec3f &color)
{
  draw_line(transform_point(transform, start), transform_point(transform, end), color);
}
开发者ID:majo33,项目名称:atom,代码行数:4,代码来源:debug_processor.cpp


示例20: get_size

void GradientEdit::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {
		if (!picker->is_connected("color_changed", this, "_color_changed")) {
			picker->connect("color_changed", this, "_color_changed");
		}
	}
	if (p_what == NOTIFICATION_DRAW) {

		int w = get_size().x;
		int h = get_size().y;

		if (w == 0 || h == 0)
			return; //Safety check. We have division by 'h'. And in any case there is nothing to draw with such size

		int total_w = get_size().width - get_size().height - 3;

		//Draw checker pattern for ramp
		_draw_checker(0, 0, total_w, h);

		//Draw color ramp
		Gradient::Point prev;
		prev.offset = 0;
		if (points.size() == 0)
			prev.color = Color(0, 0, 0); //Draw black rectangle if we have no points
		else
			prev.color = points[0].color; //Extend color of first point to the beginning.

		for (int i = -1; i < points.size(); i++) {

			Gradient::Point next;
			//If there is no next point
			if (i + 1 == points.size()) {
				if (points.size() == 0)
					next.color = Color(0, 0, 0); //Draw black rectangle if we have no points
				else
					next.color = points[i].color; //Extend color of last point to the end.
				next.offset = 1;
			} else {
				next = points[i + 1];
			}

			if (prev.offset == next.offset) {
				prev = next;
				continue;
			}

			Vector<Vector2> points;
			Vector<Color> colors;
			points.push_back(Vector2(prev.offset * total_w, h));
			points.push_back(Vector2(prev.offset * total_w, 0));
			points.push_back(Vector2(next.offset * total_w, 0));
			points.push_back(Vector2(next.offset * total_w, h));
			colors.push_back(prev.color);
			colors.push_back(prev.color);
			colors.push_back(next.color);
			colors.push_back(next.color);
			draw_primitive(points, colors, Vector<Point2>());
			prev = next;
		}

		//Draw point markers
		for (int i = 0; i < points.size(); i++) {

			Color col = i == grabbed ? Color(1, 0.0, 0.0, 0.9) : points[i].color.contrasted();
			col.a = 0.9;

			draw_line(Vector2(points[i].offset * total_w, 0), Vector2(points[i].offset * total_w, h / 2), col);
			draw_rect(Rect2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2, POINT_WIDTH, h / 2), Color(0.6, 0.6, 0.6, i == grabbed ? 0.9 : 0.4));
			draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), col);
			draw_line(Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
			draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), col);
			draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
		}

		//Draw "button" for color selector
		_draw_checker(total_w + 3, 0, h, h);
		if (grabbed != -1) {
			//Draw with selection color
			draw_rect(Rect2(total_w + 3, 0, h, h), points[grabbed].color);
		} else {
			//if no color selected draw grey color with 'X' on top.
			draw_rect(Rect2(total_w + 3, 0, h, h), Color(0.5, 0.5, 0.5, 1));
			draw_line(Vector2(total_w + 3, 0), Vector2(total_w + 3 + h, h), Color(1, 1, 1, 0.6));
			draw_line(Vector2(total_w + 3, h), Vector2(total_w + 3 + h, 0), Color(1, 1, 1, 0.6));
		}

		//Draw borders around color ramp if in focus
		if (has_focus()) {

			draw_line(Vector2(-1, -1), Vector2(total_w + 1, -1), Color(1, 1, 1, 0.6));
			draw_line(Vector2(total_w + 1, -1), Vector2(total_w + 1, h + 1), Color(1, 1, 1, 0.6));
			draw_line(Vector2(total_w + 1, h + 1), Vector2(-1, h + 1), Color(1, 1, 1, 0.6));
			draw_line(Vector2(-1, -1), Vector2(-1, h + 1), Color(1, 1, 1, 0.6));
		}
	}
}
开发者ID:Bonfi96,项目名称:godot,代码行数:97,代码来源:gra

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ draw_lines函数代码示例发布时间:2022-05-30
下一篇:
C++ draw_image函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap