Ejemplo n.º 1
0
void PolkadotsBrush::BrushBegin( const Point source, const Point target )
{
  ImpressionistDoc* pDoc = GetDocument();
  ImpressionistUI* dlg=pDoc->m_pUI;
  
  int superRadiusStep;
  int X, Y, angle, centerx, centery, outerAngle;
  float density = 0.3;
  int radius = pDoc->getSize ();
  int thickness = pDoc->getThickness ();

  int disp = rand () % thickness;

  for (outerAngle = 30; outerAngle < 360; outerAngle+=30)
    {


      centerx = target.x + (cos (outerAngle) * disp);
      centery = target.y + (sin (outerAngle) * disp);
      
      glBegin (GL_TRIANGLE_FAN);
      SetColor (source);
      glVertex2d (centerx, centery);
      
      for (angle = 0; angle <= 360; angle+=5)
	{
	  glVertex2d (centerx + (sin (angle) * radius), centery + (cos (angle) * radius));
	}
      glEnd();
    }
}
Ejemplo n.º 2
0
void LineBrush::BrushBegin( const Point source, const Point target )
{
  ImpressionistDoc* pDoc = GetDocument();
  ImpressionistUI* dlg=pDoc->m_pUI;

  if (dlg->directionOfStroke == CLICK_STROKE_DIRECTION)
    {
      int newX, newY;
      int size = pDoc->getSize ();
      int angle = pDoc->getAngle ();
      int disp;
	
      int thickness = pDoc->getThickness ();
      if (size < 5)
	disp = size * 2;
      else
	disp = size;
      if (!angle || (angle == 180))
	{
	  newY = target.y;
	  newX = target.x + disp;
	}
      else if (angle == 90)
	{
	  newY = target.y + disp;
	  newX = target.x;
	}
      else
	{
	  int tanAngle = (int) tan (angle);
	  int c = target.y - (tanAngle * target.x);
	    
	  newY = target.y + disp;
	  newX = (newY - c) / tanAngle;
	}
      printf ("Setting line thickness to %d\n", thickness);
      glLineWidth( (float) thickness );

	
      printf ("In LineBrush::BrushBegin with source (%d, %d) and Target (%d, %d)\n",
	      source.x, source.y, target.x, target.y);
	
      glBegin( GL_LINES );
      SetColor( source );

      glVertex2d( target.x, target.y);
      glVertex2d( newX, newY);
      glEnd();
    }
  else
    return ;
}
Ejemplo n.º 3
0
void LineBrush::BrushBegin( const Point source, const Point target )
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;

	int width = pDoc->getThickness();



	//glPointSize( (float)size );
	glLineWidth( (float)width );

	BrushMove( source, target );
}
Ejemplo n.º 4
0
void SpraycanBrush::BrushBegin( const Point source, const Point target )
{
  ImpressionistDoc* pDoc = GetDocument();
  ImpressionistUI* dlg=pDoc->m_pUI;
  int pointNo;
  int X, Y;
  float density = 0.8;
  int size = pDoc->getSize ();
  int thickness = pDoc->getThickness ();
  
  int topLeftX = target.x - (thickness / 2);
  int topLeftY = target.y + (size / 2);
  int bottomRightX = target.x + (thickness / 2);
  int bottomRightY = target.y - (size / 2);

  int totalPoints = thickness * size;

  int fillPoints = (int) (density * totalPoints);

  glPointSize (1.0);
  for (int i = 0; i < fillPoints; i++)
    {
      pointNo = rand () % totalPoints;
      Y = topLeftY - (pointNo / thickness);
      X = topLeftX + (pointNo % thickness);

      glBegin( GL_POINTS );
      SetColor( source );
      
      glVertex2d(X, Y);
      
      glEnd();

    }
  

}
Ejemplo n.º 5
0
void LineBrush::BrushMove( const Point source, const Point target )
{
  int newX, newY, sourceNewX, sourceNewY;
  ImpressionistDoc* pDoc = GetDocument();
  ImpressionistUI* dlg=pDoc->m_pUI;

  if ( pDoc == NULL ) {
    printf( "LineBrush::BrushMove:document is NULL\n" );
    return;
  }
#if DEBUG
  printf ("In LineBrush::BrushMove with Source (%d, %d) and Target (%d, %d)\n",
	  source.x, source.y, target.x, target.y);

#endif
  if (dlg->directionOfStroke == CLICK_STROKE_DIRECTION)
    {
      int size = pDoc->getSize ();
      int angle = pDoc->getAngle ();
      int disp;
      int thickness = pDoc->getThickness ();

      if (size < 5)
	disp = size * 2;
      else
	disp = size;

      if (!angle || (angle == 180))
	{
	  newY = target.y;
	  newX = target.x + disp;
	  // 	    sourceNewY = source.y;
	  // 	    sourceNewX = source.x + disp;
	    
	}
      else if (angle == 90)
	{
	  newY = target.y + disp;
	  newX = target.x;
	  // 	    sourceNewY = source.y + disp;
	  // 	    sourceNewX = source.x;

	}
      else
	{
	  int tanAngle = (int) tan (angle);
	  int c = target.y - (tanAngle * target.x);
	    
	  newY = target.y + disp;
	  newX = (newY - c) / tanAngle;
	  // 	    sourceNewY = source.y + disp;
	  // 	    sourceNewX = (sourceNewY - c) / tanAngle;

	}
      glLineWidth( (float)thickness );
	
#if DEBUG
      printf ("LineBrush::BrushMove: Drawing a line from (%d,%d) to (%d,%d) of angle %d\n", 
	      target.x, target.y, newX, newY, angle);
#endif	

      glBegin( GL_LINES );
      SetColor( source );
       
      glVertex2d( target.x, target.y);
      glVertex2d( newX, newY);
      glEnd();
    }
  else if (dlg->directionOfStroke == DRAG_STROKE_DIRECTION)
    {

      int size = pDoc->getSize ();
      int angle = pDoc->getAngle ();
      int thickness = pDoc->getThickness ();
      glLineWidth( (float)thickness );
	

      if (lastPointX != -1)
	{
#if DEBUG
	  printf ("LineBrush::BrushMove: Drawing a line from (%d,%d) to (%d,%d) of angle %d\n", 
		  target.x, target.y, newX, newY, angle);
#endif	

	  glBegin( GL_LINES );
	  SetColor( source );
	  glVertex2d (lastPointX, lastPointY);
	  glVertex2d( target.x, target.y);
	  glEnd();
	  lastPointX = target.x;
	  lastPointY = target.y;
	}
      else
	{
	  lastPointX = target.x;
	  lastPointY = target.y;
	}
    }
}