Пример #1
0
void DrawHand(SDL_Renderer *renderer, int hour, int minute, int second)
{
    double a_hour, a_min,  a_sec, a_sec1;
    int    x_hour, y_hour,
           x_min,  y_min,
           x_sec,  y_sec,
           x1_sec, y1_sec;
    a_sec  = second  * 2 * M_PI / 60;
    a_sec1 = (second > 30 ? second-30 : second+30) * 2 * M_PI / 60;
    a_min  = minute  * 2 * M_PI / 60 + a_sec / 60;
    a_hour = hour    * 2 * M_PI / 12 + a_min / 12;

    x_sec  = WIDTH/2  + (int)(HEIGHT/2 * 0.95 * sin(a_sec));
    y_sec  = HEIGHT/2 - (int)(HEIGHT/2 * 0.95 * cos(a_sec));
    x1_sec = WIDTH/2  + (int)(HEIGHT/2 * 0.20 * sin(a_sec1));
    y1_sec = HEIGHT/2 - (int)(HEIGHT/2 * 0.20 * cos(a_sec1));
    x_min  = WIDTH/2  + (int)(HEIGHT/2 * 0.85 * sin(a_min));
    y_min  = HEIGHT/2 - (int)(HEIGHT/2 * 0.85 * cos(a_min));
    x_hour = WIDTH/2  + (int)(HEIGHT/2 * 0.65 * sin(a_hour));
    y_hour = HEIGHT/2 - (int)(HEIGHT/2 * 0.65 * cos(a_hour));

    thickLineRGBA(renderer, WIDTH/2, HEIGHT/2, x_hour, y_hour, I_ZOOM*5,
                  0,        0,       255,      255);
    thickLineRGBA(renderer, WIDTH/2, HEIGHT/2, x_min,  y_min,  I_ZOOM*4,
                  0,        255,     0,        255);
    thickLineRGBA(renderer, x1_sec,  y1_sec,   x_sec,  y_sec,  I_ZOOM*1,
                  255,      0,       0,        255);

    filledCircleRGBA(renderer, WIDTH/2, HEIGHT/2, I_ZOOM*8, 255, 160, 255, 240);
}
Пример #2
0
 void DrawingArea::DrawThickLine(const int x1, const int y1, const int x2, const int y2, const int width, const SSDL::Color Color) {
     if (x1 <= x2) {
         thickLineRGBA(this->surface, x1, y1, x2, y2, width, Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha());
     } else {
         thickLineRGBA(this->surface, x2, y2, x1, y1, width, Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha());
     }
 }
Пример #3
0
void Draw_Highway(way* w, char* role, RGBA* color, int length, char* type)
{
	Sint16 *vx, *vy;
	Sint16 mx1, my1, mx2, my2;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon, offset = 0;
	double alpha, num, distance, decimal_part;
	int i, j, index, compteur = 0;
	bool visible;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));
	
	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}
	
	if(type != NULL && !strcmp(type, "pedestrian"))
	{
		rgba = colorConverter(PEDESTRIAN_FILL_COLOR);
		filledPolygonRGBA(pRenderer, vx, vy, compteur, rgba.r, rgba.g, rgba.b, rgba.a);
		//rgba = colorConverter(PEDESTRIAN_CONTOUR_COLOR);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], length, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], length, color->r, color->g, color->b, color->a);
	
	free(vx);
	free(vy);
}
Пример #4
0
void gline(float x1, float y1, float x2, float y2, float width, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
	#ifdef	OPENGL
		glColor4f(((float) r) / 255.0, ((float) g) / 255.0, ((float) b) / 255.0, ((float) a) / 255.0);
		//   c1x,c1y
		//  0,0......
		//   c4x,c4y  ........       c2x,c2y
		//                    ........ px,py
		//                       c3x,c3y
		float c1x, c1y, c1l, c2x, c2y, c2l, c3x, c3y, c3l, c4x, c4y, c4l;

		float px = x2 - x1;
		float py = y2 - y1;

		c1x = -py;
		c1y = px;
		c1l = hypotf(c1x, c1y);
		c1x = (c1x * width / c1l / 2.0) + x1;
		c1y = (c1y * width / c1l / 2.0) + y1;

		c2x = -py;
		c2y = px;
		c2l = hypotf(c2x, c2y);
		c2x = (c2x * width / c2l / 2.0) + px + x1;
		c2y = (c2y * width / c2l / 2.0) + py + y1;

		c3x = py;
		c3y = -px;
		c3l = hypotf(c3x, c3y);
		c3x = (c3x * width / c3l / 2.0) + px + x1;
		c3y = (c3y * width / c3l / 2.0) + py + y1;

		c4x = py;
		c4y = -px;
		c4l = hypotf(c4x, c4y);
		c4x = (c4x * width / c4l / 2.0) + x1;
		c4y = (c4y * width / c4l / 2.0) + y1;

		if (width == 4.0)
			printf("LINE: [%3.0f,%3.0f]->[%3.0f,%3.0f]->[%3.0f,%3.0f]->[%3.0f,%3.0f]\n", c1x, c1y, c2x, c2y, c3x, c3y, c4x, c4y);

		glVertex2f(c1x, c1y);
		glVertex2f(c2x, c2y);
		glVertex2f(c3x, c3y);
		glVertex2f(c4x, c4y);
	#else
	thickLineRGBA(Surf_Display,
		(x1 - viewPortL) * zoomFactor,
		(viewPortB - y1) * zoomFactor,
		(x2 - viewPortL) * zoomFactor,
		(viewPortB - y2) * zoomFactor,
		mind(maxd(width * zoomFactor, 1), 2),
		r, g, b, a
		);
	#endif
}
Пример #5
0
void draw_shot_anim (Sint16 unit_x, Sint16 unit_y, Sint16 target_x, Sint16 target_y, Sint16 zoom)
{
	Sint16 x1 = ((unit_x - world_up_x) * zoom) + (zoom / 2);
	Sint16 y1 = ((unit_y - world_up_y) * zoom) + (zoom / 2);
	
	Sint16 x2 = (target_x - world_up_x) * zoom + (zoom / 2);
	Sint16 y2 = (target_y - world_up_y) * zoom + (zoom / 2);
	
	thickLineRGBA (screen, x1, y1, x2, y2, zoom / 8, 0, 0, 0, 255);
	update_screen ();
	
	SDL_Delay (1500);
}
Пример #6
0
//http://www.ferzkopp.net/Software/SDL2_gfx/Docs/html/_s_d_l2__gfx_primitives_8h.html
//utilisation de la primitive gfx
// ici on ajoute des cercles pein ou vide
// on peut aussi ajouter des courbes de bézier, des polygones,des lignes épaisses...
void createShapes(){
        Sint16 circleR = 100;
        Sint16 circleX = 300;
        Sint16 circleY = 300;
        SDL_Renderer* renderer=SDLS_getRenderer();
        filledCircleColor(renderer, circleX, circleY, circleR, 0xFF0000FF);
        circleRGBA(renderer,200,200,100,0,255,0,255);
        roundedRectangleRGBA(renderer,10,10,100,100,30,120,120,0,255);
        thickLineRGBA(renderer,450,150,150,450,50,255,0,255,255);
        trigonRGBA(renderer,100,100,200,200,100,300,0,255,120,255);
        Sint16 vx[10]={10,50,150,200, 220,240,410,500,200,250};
         Sint16 vy[10]={10,80,10,0,10,30,50,80,30,150};
        bezierRGBA(renderer,vx,vy,10,3,50,0,255,255);
}
Пример #7
0
void Draw_Natural(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	if(type != NULL)
		if(!strcmp(type, "cliff"))
			for(i = 0; i < compteur - 1; i++)
				thickLineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], CLIFF_LENGTH, color->r, color->g, color->b, color->a);
		else
			if(!strcmp(type, "coastline"))
				for(i = 0; i < compteur - 1; i++)
					aalineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], color->r, color->g, color->b, color->a);
	else
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
Пример #8
0
void Draw_Leisure(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	if(!strcmp(type, "garden"))
	{
		rgba = colorConverter(WHITE);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA (pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], 2, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
Пример #9
0
void DrawPlate(SDL_Renderer *renderer)
{
    int w, l, x1, x2, y1, y2;
    filledCircleRGBA(renderer, WIDTH/2, HEIGHT/2, HEIGHT/2, 255, 154, 69, 255);
    filledCircleRGBA(renderer, WIDTH/2, HEIGHT/2, HEIGHT/2-I_ZOOM*10, 0, 0, 0, 255);
    for(int i=0; i<60; i++)
    {
        if(i%5==0)
        {
            w=4*I_ZOOM;
            l=15*I_ZOOM;
        }
        else
        {
            w=2*I_ZOOM;
            l=10*I_ZOOM;
        }
        x1=HEIGHT/2*sin(i*6*M_PI/180)+WIDTH/2;
        y1=HEIGHT/2*cos(i*6*M_PI/180)+HEIGHT/2;
        x2=(HEIGHT/2-l)*sin(i*6*M_PI/180)+WIDTH/2;
        y2=(HEIGHT/2-l)*cos(i*6*M_PI/180)+HEIGHT/2;
        thickLineRGBA(renderer, x1, y1, x2, y2, w, 111, 123, 75, 255);
    }
}
Пример #10
0
void draw_line_rotated (SDL_Surface *screen, Sint16 x, Sint16 y, Sint16 length, Sint16 angle, Sint16 width, Uint8 r, Uint8 g, Uint8 b)
{
	double aspect_ratio = 1.0, dangle, rads, dr;
	double dradius = length / (aspect_ratio * 2.0);
	int ra, x2, y2;
	
	dangle = angle;
	rads = (dangle + 90.0) * M_PI / 180.0;
			
	dr = cos (rads);
	dr = dr * dradius;
	ra = dr;
		
	x2 = x + ra;
		
	dr = sin (rads);
	dr = dr * dradius * aspect_ratio;
		
	ra = dr;
		
	y2 = y - ra;
	
	thickLineRGBA (screen, x, y, x2, y2, width, r, g, b, 255);
}
Пример #11
0
void Renderer::ThickLine(Point p, Point p2, int width, Uint8 rr, Uint8 gg, Uint8 bb, Uint8 aa){
    thickLineRGBA(_renderer, p.x(), p.y(), p2.x(), p2.y(), width, rr, gg, bb, aa);
}
Пример #12
0
void fillWay(Way * way){
	if(map == NULL){
		fprintf(stderr,"La map est NULL dans line fonction fillWay\n");
		return;
	}
	if(way == NULL){
		fprintf(stderr,"Le way est NULL dans line fonction fillWay\n");
		return;
	}
	ListNode * l = way->listNd;
	if(l == NULL){
		fprintf(stderr,"Le way %ld a pas de noeud : line.c fonction fill way\n",way->id );
		return;
	}
	refListNode * current =l->firstRef;
	int nbre=0;
	if(way->size != 0){
		short coord_x [way->size];
		short coord_y [way->size];
		while(current != NULL){
			Node * currentNode = searchNode(map->avl,current->nd);
			if(currentNode != NULL){
				if(currentNode->c != NULL){
					coord_x[nbre] = miseAEchelleX(currentNode->c->x,map->bounds->max->x,windows_Width);
					coord_y[nbre] = miseAEchelleY(currentNode->c->y,map->bounds->max->y,windows_Height);
					nbre++;
				}
				else{
					fprintf(stderr,"le node %ld n'a pas de coordonnees\n",current->nd );
				}
				current = current->next;
			}
			else{
				fprintf(stderr,"Le node %ld n'est pas définis dans le fichier d'entree \n",current->nd );
			}
		}
		if(way->tag != NULL && way->tag->tagKey != NULL && way->tag->c != NULL){
			if(strcmp(way->tag->tagKey,"highway")==0){
				int draw = 1;
				int thick = 0;
				if(way->tag->thick != 0){
					thick = (way->tag->thick+modifThink);
					if(thick < 1){
						draw = zoomDrawHighway(way->tag->tagValue,modifThink);
						thick = 1;
					}
					thick *= zoom;
				}
				int i;
				int x = coord_x[0];
				int y = coord_y[0];
				if(draw == 1){
					for(i=0;i<way->size;i++){
						thickLineRGBA(renderer,x,y,coord_x[i],coord_y[i],thick,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255);
						if(drawContour ==1){
							int diff = 100;
							thickLineRGBA(renderer,x+thick/2,y+thick/2,coord_x[i]+thick/2,coord_y[i]+thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255);
							thickLineRGBA(renderer,x-thick/2,y-thick/2,coord_x[i]-thick/2,coord_y[i]-thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255);
						}
						x = coord_x[i];
						y = coord_y[i];
					}

					//highway(way,coord_y,coord_x,thick);
					//nameHighway(way,l);
				}
			}

			else{
				if(drawContour == 1){
					polygonRGBA(renderer,coord_x,coord_y,way->size,139,71,137,255);
				}
				filledPolygonRGBA(renderer,coord_x,coord_y,way->size,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255);
			}
		}
		else{
			filledPolygonRGBA(renderer,coord_x,coord_y,way->size,0,0,255,255);
		}
	}
}
Пример #13
0
void highway(Way *way, short coord_y[way->size],short coord_x[way->size],int thick){
	Sint16 coord_xNode[4] = {0.0,0.0,0.0,0.0};
	Sint16 coord_yNode[4] = {0.0,0.0,0.0,0.0};
	int i;
	for(i = 1;i < way->size;i++){

		if(i == 1){
			float length = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float fx = normalize(coord_y[i-1],coord_y[i],length);
			float gx = fx;
			float fy = 0.0-normalize(coord_x[i-1],coord_x[i],length);
			float gy = fy;
			coord_xNode[0] = fx;
			coord_xNode[1] = gx;
			coord_yNode[0] = fy;
			coord_yNode[1] = gy;
			float coeff = (coord_y[i-1]-coord_y[i])/(coord_x[i-1]-coord_x[i]);
			if(coeff>0){
				extremite(coord_x[i-1],fx*thick/2,gx*thick/2,coord_xNode,1,1);
				extremite(coord_y[i-1],fy*thick/2,gy*thick/2,coord_yNode,1,1);
			}
			else{
				extremite(coord_x[i-1],fx*thick/2,gx*thick/2,coord_xNode,0,1);
				extremite(coord_y[i-1],fy*thick/2,gy*thick/2,coord_yNode,0,1);
			}
		}
		if(i==way->size-1){
			int j;
			for(j=0;j<4;j++){
				printf("Fin X : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");
			float length = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float fx = normalize(coord_y[i-1],coord_y[i],length);
			float gx = fx;
			float fy = 0.0-normalize(coord_x[i-1],coord_x[i],length);
			float gy = fy;
			coord_xNode[2] = fx;
			coord_xNode[3] = gx;
			coord_yNode[2] = fy;
			coord_yNode[3] = gy;
			float coeff = (coord_y[i-1]-coord_y[i])/(coord_x[i-1]-coord_x[i]);
			if(coeff>0){
				extremite(coord_x[i],fx*thick/2,gx*thick/2,coord_xNode,1,2);
				extremite(coord_y[i],fy*thick/2,gy*thick/2,coord_yNode,1,2);
			}
			else{
				extremite(coord_x[i],fx*thick/2,gx*thick/2,coord_xNode,0,2);
				extremite(coord_y[i],fy*thick/2,gy*thick/2,coord_yNode,0,2);
			}
			for(j=0;j<4;j++){
				printf("Fin XX : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");

			filledPolygonRGBA(renderer,coord_xNode,coord_yNode,4,255,0,0,255);
		}
		else{
			float lengthAB = distanceXY(coord_x[i-2],coord_y[i-2],coord_x[i-1],coord_y[i-1]);
			float resABy = normalize(coord_y[i-2],coord_y[i-1],lengthAB);
			float resABx = normalize(coord_x[i-2],coord_x[i-1],lengthAB);

			float lengthBC = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float resBCx = normalize(coord_x[i-1],coord_x[i],lengthBC);
			float resBCy = normalize(coord_y[i-1],coord_y[i],lengthBC);

			float X = (resABx - resBCx)*thick/2;
			float Y = (resABy - resBCy)*thick/2;

			double angleCal = angle(coord_x[i-2],coord_y[i-2],coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			if(angleCal >0){
				midle(coord_x[i-1],X,0,coord_xNode);
				midle(coord_y[i-1],Y,0,coord_yNode);
			}
			else{
				midle(coord_x[i-1],X,1,coord_xNode);
				midle(coord_y[i-1],Y,1,coord_yNode);
			}
			int j;
			for(j=0;j<4;j++){

				printf("Inter X : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");
			filledPolygonRGBA(renderer,coord_xNode,coord_yNode,4,255,0,0,255);
			if(i !=way->size-1){
				swap(coord_yNode);
				swap(coord_xNode);
			}
		}
		thickLineRGBA(renderer,coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i],thick,way->tag->c->red,way->tag->c->green,way->tag->c->blue,105);
	}
}