Esempio n. 1
0
void draw_mass(SDL_Renderer *ren, mass *m) {
  /* 0xAABBGGRR */
  if(!m->dead)
    circleColor(ren, m->pos.x, m->pos.y, 2, 0xFFFFFFFF);
  else
    circleColor(ren, m->pos.x, m->pos.y, 2, 0xFF000055);
}
Esempio n. 2
0
/* Here we draw the vectorscope layout */
void make_vectorscope_layout()
	{
	int i, p1_x, p1_y, p2_x, p2_y;
	double temp;
	char text[4];

	boxColor(screen, vector_x-130, vector_y+130, 
			 vector_x+130, vector_y-130, black); 

	hlineColor(screen, vector_x-20, vector_x-128, vector_y, white);
	hlineColor(screen, vector_x+20, vector_x+128, vector_y, white);
	vlineColor(screen, vector_x, vector_y-20, vector_y-128, white);
	vlineColor(screen, vector_x, vector_y+20, vector_y+128, white);
	circleColor(screen,vector_x, vector_y, 20, white);
	circleColor(screen,vector_x, vector_y, 50, white);
	circleColor(screen,vector_x, vector_y, 80, white);
	circleColor(screen,vector_x, vector_y,112, white);
	
	for (i =0; i<36; i++)
		{		/* Here we draw the degree scale */
			temp = 112* cos (i*(10/57.3)) ;  /* sin & cos only accept radiant */
			p1_x = round(temp);					/* and not degree input */
			temp = 112* sin (i*(10/57.3) );
			p1_y = round(temp);
			temp = 117* cos (i*(10/57.3) );
			p2_x = round(temp);
			temp = 117* sin (i*(10/57.3) );
			p2_y = round(temp);

			lineColor(screen, vector_x + p1_x, vector_y + p1_y,
									vector_x + p2_x, vector_y + p2_y, white);
		}

	sprintf(text, "0"); /* Creating the grad description */
	stringColor(screen, vector_x + 135 , vector_y - 3, text, white);
	sprintf(text, "90");
	stringColor(screen, vector_x - 7 , vector_y - 145, text, white);
	sprintf(text, "180");
	stringColor(screen, vector_x - 155 , vector_y - 3, text, white);
	sprintf(text, "270");
	stringColor(screen, vector_x - 10 , vector_y + 135, text, white);

	makepoint( 90, 60); /* length, arc, for purple */	
	makepoint( 96, 104); /* length, arc, for red */	
	makepoint( 67, 166); /* length, arc, for yellow */	
	makepoint( 90, 241); /* length, arc, for green */	
	makepoint( 96, 283); /* length, arc, for cyan */	
	makepoint( 67, 346); /* length, arc, for blue */	

	}
Esempio n. 3
0
void Draw_Geometry()
{
    int flag = 1;

    SDL_FillRect(WINDOW, NULL, 0xffffffff);
    while( flag ){
        switch( rand() % 7 ){
        case 0: hlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break;
        case 1: vlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break;
        case 2: rectangleColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break;
        case 3: lineColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break;
        case 4: circleColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break;
        case 5: pieColor(WINDOW, AXIS, AXIS, AXIS, THETA, THETA, COLOR); break;
        case 6: trigonColor(WINDOW, AXIS, AXIS, AXIS, AXIS, AXIS, AXIS, COLOR); break;
        default: break;
        }
        SDL_UpdateRect(WINDOW, 0, 0, 0, 0);

        printf("again->'a' reset->'r' exit->'e'\n");
        char ch = getchar(), c = getchar();
        switch( ch ){
        case 'a': flag = 1; break;
        case 'r': SDL_FillRect(WINDOW, NULL, 0xffffffff); break;
        case 'e': flag = 0; break;
        default : flag = 1; break;
        }
    }
}
Esempio n. 4
0
int GeoLayer::circle(int16_t x, int16_t y, int16_t r, uint32_t col) {
    if(!surf) {
        error("%s can't run: layer not initialized", __PRETTY_FUNCTION__);
        return -1;
    }
    res = circleColor(surf, x, y, r, col);
    if(res < 0) error("error in %s", __PRETTY_FUNCTION__);
    return(res);
}
Esempio n. 5
0
/********************
集団をプロット
********************/
void Unit_Prot(Indiv pop[],SDL_Surface *window,int N)
{
	int i;
	for(i=0;i<N;i++){
		circleColor(window,
			(pop[i].n[0]*2)+center[0],
			(pop[i].n[1]*2)+center[1],
			4,
			0x000000ff);
	}
}
/*****************************************************************
関数名	: DrawCircle
機能	: メインウインドウに円を表示する
引数	: int		x		: 円の x 座標
		  int		y		: 円の y 座標
		  int		r		: 円の半径
出力	: なし
*****************************************************************/
void DrawCircle(int x,int y,int r)
{
#ifndef NDEBUG
	printf("#####\n");
    printf("DrawCircle()\n");
    printf("x=%d,y=%d,tyokkei=%d\n",x,y,r);
#endif

    circleColor(gMainWindow,x,y,r,0x000000ff);
	SDL_Flip(gMainWindow);
}
Esempio n. 7
0
CAMLprim value ml_circleColor(value dst,value p,value ra, value col)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect prect;
  int r;

  SDLRect_of_value(&prect,p);
  r=circleColor(sur,prect.x,prect.y,Int_val(ra),Int32_val(col));

  return Val_bool(r);
}
Esempio n. 8
0
/*
 * vykresluje znacky do hraciho pole
 */
int drawTurn(SDL_Surface *screen, TCoord c, int player)
{
  if(player == CROSS) {
    lineColor(screen, c.y * FIELD_SIZE + 2, c.x * FIELD_SIZE + 2, c.y * FIELD_SIZE + FIELD_SIZE - 2, c.x * FIELD_SIZE + FIELD_SIZE - 2, 0xff0000ff);
    lineColor(screen, c.y * FIELD_SIZE + FIELD_SIZE - 2, c.x * FIELD_SIZE + 2, c.y * FIELD_SIZE + 2, c.x * FIELD_SIZE + FIELD_SIZE - 2, 0xff0000ff);
  }
  else {
    circleColor(screen, c.y * FIELD_SIZE + FIELD_SIZE / 2, c.x * FIELD_SIZE + FIELD_SIZE / 2, FIELD_SIZE / 2 - 2, 0xffff00ff);
  }
  SDL_UpdateRect(screen, 0,0,0,0);
  return 0;
}
Esempio n. 9
0
/********************
pop集団をプロット
********************/
void Pop_Prot(Indiv pop[],SDL_Surface *window)
{
	int i;
	for(i=0;i<Ns;i++){
		if(pop[i].flag == 0){
			circleColor(window,
				(pop[i].n[0]*2)+center[0],
				(pop[i].n[1]*2)+center[1],
				4,
				0xff0000ff);
		}
	}
}
Esempio n. 10
0
// TODO I could make this much faster by using an array or vector of vectors - the index is the group
void ParticleSystem::draw(int group)
{
  for(unsigned int i = 0; i < particles.size(); i++)
    if(particles[i].group == group)
      switch(particles[i].type)
      {
        case PIXEL:
          pixelColor(display, (int)particles[i].x, (int)particles[i].y, particles[i].color);
          break;
        case CIRCLE:
          circleColor(display, (int)particles[i].x, (int)particles[i].y, particles[i].size, particles[i].color);
          break;
        case SQUARE:
          FillRect(particles[i].x, particles[i].y, particles[i].size, particles[i].size, particles[i].color >> 8);
          break;
      }
}
Esempio n. 11
0
void Boid::DrawFlockingDebug(SDL_Renderer* renderer)
{
	float drawFactor = 100.0f;

	circleColor(renderer, position.x, position.y, K_FLOCK_NEIGHBOURHOOD, Colors::PUMPKIN);

	SDL_SetRenderDrawColor(renderer, 255, 255, 0, 255);
	SDL_RenderDrawLine(renderer, position.x, position.y, 
		position.x + alignment.x * K_FLOCK_ALIGNMENT * drawFactor,
		position.y + alignment.y * K_FLOCK_ALIGNMENT * drawFactor);

	SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
	SDL_RenderDrawLine(renderer, position.x, position.y, 
		position.x + cohesion.x * K_FLOCK_COHESION * drawFactor,
		position.y + cohesion.y * K_FLOCK_COHESION * drawFactor);

	SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
	SDL_RenderDrawLine(renderer, position.x, position.y,
		position.x + separation.x * K_FLOCK_SEPARATION * drawFactor,
		position.y + separation.y * K_FLOCK_SEPARATION * drawFactor);
}
Esempio n. 12
0
static PyObject*
_gfx_circlecolor (PyObject *self, PyObject* args)
{
    PyObject *surface, *color, *pt;
    int x, y, r;
    pguint32 c;

    ASSERT_VIDEO_INIT (NULL);

    if (!PyArg_ParseTuple (args, "OOiO:circle", &surface, &pt, &r, &color))
    {
        PyErr_Clear ();
        if (!PyArg_ParseTuple (args, "OiiiO:circle", &surface, &x, &y, &r,
            &color))
        return NULL;
    }
    else
    {
        if (!PointFromObj (pt, &x, &y))
            return NULL;
    }
    
    if (!PySDLSurface_Check (surface))
    {
        PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
        return NULL;
    }

    if (!ColorFromObj (color, &c))
        return NULL;

    if (circleColor (((PySDLSurface*)surface)->surface,
            (Sint16)x, (Sint16)y, (Sint16)r, (Uint32)c) == -1)
    {
        PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
        return NULL;
    }
    Py_RETURN_NONE;
}
Esempio n. 13
0
void sfml_drawsurface::circleColor(Point& a, unsigned int radius, int t_color, bool debug) {
	My_Color color(t_color);
	circleColor(a, radius, color.red, color.green, color.blue, debug);
}
Esempio n. 14
0
void graphics_draw_circle(GContext *ctx, GPoint p, int radius) {
    GPoint topOffset=getTopOffset ();
    circleColor(getTopScreen(), topOffset.x+p.x, topOffset.y+p.y, radius, getRawColor(ctx->stroke_color));
}
Esempio n. 15
0
void
draw (void)
{
	double now, dt;
	struct unit *up;
	struct pathblock *pp;

	now = get_secs ();

	if (destimg.drawing) {
		dt = floor (10 * (now - destimg.lasttime));
		if (dt < 8) {
			switch ((int) dt) {
			case 0:
				draw_blit (destimg.frames[0],
					   destimg.x, destimg.y);
				break;
			case 1:
				draw_blit (destimg.frames[1],
					   destimg.x, destimg.y);
				break;
			case 2:
				draw_blit (destimg.frames[2],
					   destimg.x, destimg.y);
				break;
			case 3:
				draw_blit (destimg.frames[3],
					   destimg.x, destimg.y);
				break;
			case 4:
				draw_blit (destimg.frames[4],
					   destimg.x, destimg.y);
				break;
			case 5:
				draw_blit (destimg.frames[5],
					   destimg.x, destimg.y);
				break;
			case 6:
				draw_blit (destimg.frames[6],
					   destimg.x, destimg.y);
				break;
			case 7:
				draw_blit (destimg.frames[7],
					   destimg.x, destimg.y);
				break;
			}

		} else {
			destimg.drawing = 0;
		}
	}

	for (pp = first_pathblock; pp; pp = pp->next) {
		boxColor (screen, pp->left, pp->top, pp->right, pp->bottom,
			  pp->color);
	}

	for (up = first_unit; up; up = up->next) {
		boxColor (screen, up->left, up->top, up->right, up->bottom,
			  up->color);
		if (up->selected == 1) {
			circleColor (screen, up->center_x, up->center_y,
				     hypot (up->h / 2, up->w / 2) + 3,
				     0x00ff00ff);
			aacircleColor (screen, up->center_x, up->center_y,
				       hypot (up->h / 2, up->w / 2) + 3,
				       0x00ff00ff);
		}
	}

	if (selectbox.drawing) {
		rectangleColor (screen, selectbox.x1, selectbox.y1,
				selectbox.x2, selectbox.y2, selectbox.color);
	}
}
Esempio n. 16
0
void CellGrid::draw_active_water(Coord here) {
  //Draw the water located at 'here' to water_surface
  //...fancy!
  CellBox cell = CellBox(*this, here, AIR, ROCK, INACTIVE_WATER, INACTIVE_WATER);
  int exposed_count = cell.count(EXPOSED_WATER);
  int inactive_count = cell.count(INACTIVE_WATER);
  int air_count = cell.count(AIR);

  //We draw either a bubble, or a wave.
  bool draw_bubble = true;
  //These are directions, for drawing waves.
  //a1 and a2 indicate what the lines will be drawn through.
  int a1 = -1, a2 = -1;
  //'under' indicates what part is under water
  int under = -1;
 

  //Determine how to proceed
  if (air_count == 3 && exposed_count == 0 && inactive_count == 1) {
    //tower of water?
    int d = cell.find(INACTIVE_WATER);
    a1 = rotate_cc(d);
    a2 = rotate_co(d);
    under = d;
    draw_bubble = false;
  }
  else if (air_count == 2 && exposed_count == 1 && inactive_count == 1) {
    int e = cell.find(EXPOSED_WATER), i = cell.find(INACTIVE_WATER);
    int ei_angle = normalize_angle(angle(e, i));
    if (ei_angle == 4) {
      //opposite
      a1 = rotate_cc(i);
      a2 = rotate_co(i);
      under = i;
    }
    else if (ei_angle == 2 || ei_angle == 6) {
      //adjacent
      a1 = e;
      under = i;
      //a2 is i rotated away from a1
      if (ei_angle == 6) {
        a2 = rotate_cc(i);
      }
      else {
        a2 = rotate_co(i);
      }
    }
    else {
      throw ei_angle;
    }
    draw_bubble = false;
  }
  else if (air_count == 1 && exposed_count == 2 && inactive_count == 1) {
    int e1 = cell.find(EXPOSED_WATER, 0), e2 = cell.find(EXPOSED_WATER, 1);
    if (normalize_angle(angle(e1, e2)) == 4) {
      //We've got two exposeds opposite, with an inactive on one side
      //put the line between the two inactives
      a1 = e1;
      a2 = e2;
      draw_bubble = false;
      under = cell.find(INACTIVE_WATER);
    }
  }
  else if (air_count == 1 && exposed_count == 1 && inactive_count == 2) {
    //similiar to above, except we want two inactives adjacent
    int i1 = cell.find(INACTIVE_WATER, 0), i2 = cell.find(INACTIVE_WATER, 1);
    int n = normalize_angle(angle(i1, i2));
    if (n == 2 || n == 6) {
      draw_bubble = false;
      int e = cell.find(EXPOSED_WATER);
      int between = opposite(cell.find_air());
      a1 = e;
      a2 = opposite(e);
      under = between;
      int direction = normalize_angle(angle(between, a2));
      if (direction == 6) {
        a2 = rotate_cc(a2);
      }
      else {
        a2 = rotate_co(a2);
      }
    }
  }
  

  
  //Now do the drawing
  int seed = (here.x << here.y) + (ticks/15); //used for RNG
  const Uint32 surface_color = CellData::color(EXPOSED_WATER);
  const Uint32 under_water = CellData::color(INACTIVE_WATER);
  SDL_FillRect(water_surface, NULL, CellData::color(AIR));

  if (draw_bubble) {
    if (air_count == 4) {
      //draw drop of water instead
      seed = (here.x * 191) >> 3;
      const int offset = (block_pixel_size/2) - 1;
      const int radius = (block_pixel_size/3)-(seed % 5);
      filledCircleColor(water_surface, offset, offset, radius, under_water);
      circleColor(water_surface, offset, offset, radius, surface_color);
    }
    else {
      //A few random foamy bubbles
      if (inactive_count == 4) {
Esempio n. 17
0
void Obstacle::render(SDL_Renderer* renderer)
{
    circleColor(renderer, m_center.x, m_center.y, m_fRadius, m_iColor);
}
Esempio n. 18
0
void Renderer::draw ( const Circle& ent )
{
    vec2d pos = ent.get_position();
    circleColor( m_renderer, pos.x, pos.y, ent.get_radius(), ent.get_colour() );
}