コード例 #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();
    }
}
コード例 #2
0
void TriangleBrush::BrushMove(const Point source, const Point target) {
	ImpressionistDoc* pDoc = GetDocument();
	if (pDoc == NULL) {
		printf("TriangleBrush::BrushMove  document is NULL\n");
		return;
	}

	int size = pDoc->getSize(); // get brush size
	float alphaValue = pDoc->getAlpha();

	glPushMatrix();
	glTranslatef(target.x, target.y, 0); // move (0, 0) to the tip of mouse cursor

	glBegin(GL_POLYGON);

	SetColor(source, alphaValue);
	for (int i = 0; i < 3; i++) {
		float theta = -M_PI / 6 + 2.0f * M_PI * float(i) / float(3); // get the current angle (start from -30 degree)
		float x = cosf(theta) * size / 2; // calculate the x component 
		float y = sinf(theta) * size / 2; // calculate the y component 

		glVertex2f(x, y); // output vertex 
	}

	glEnd();

	glPopMatrix();
}
コード例 #3
0
void PointBrush::BrushMove( const Point source, const Point target )
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;
	int size = pDoc->getSize();

	// rand size start
	if(dlg->getIsPaint() && dlg->getIsRandSize()){
		size = rand() % pDoc->getSize() + 1;
	}
	// rand size end
	
	glPointSize( (float)size );

	if ( pDoc == NULL ) {
		printf( "PointBrush::BrushMove  document is NULL\n" );
		return;
	}
	
	glBegin( GL_POINTS );
		SetColor( source );

		glVertex2d( target.x, target.y );

	glEnd();
}
コード例 #4
0
void ScatteredCirclesBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	int size = pDoc->getSize();
	double PI = 3.1415;

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_POINTS);
		

		for (int k = 0; k < 3; ++k){
			double randx = (double)(rand() % size/2);
			double randy = (double)(rand() % size/2);
			Point randpt = Point((int)(target.x + pow((-1.0), randx)* randx), (int)(target.y + pow((-1.0), randy)* randy));
			SetColor(randpt);
			for (int j = 0; j < size; ++j){
				for (int i = 0; i < 300; ++i)
					glVertex2d(randpt.x + j / 2 * cos(2 * PI / 300 * i), randpt.y + j / 2 * sin(2 * PI / 300 * i));
			}
		}

	glEnd();
}
コード例 #5
0
void ScatteredCircleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL)
	{
		printf("CircleBrush::BrushMove document is NULL\n");
		return;
	}

	int size = pDoc->getSize();
	this->radius = (double)size;

	int loop_time = irand(2) + 2;
	for (int i = 0; i < loop_time; ++i)
	{
		glBegin(GL_POLYGON);
		int Xoffset = irand(this->radius) - this->radius/2;
		int Yoffset = irand(this->radius) - this->radius/2;
		SetColor(source.x + Xoffset,source.y + Yoffset);

		for (int i = 0; i < 360; ++i)
		{
			double theta = i * 3.14159 / 180;
			glVertex2d(target.x + Xoffset - radius * cos(theta), target.y + Yoffset - radius * sin(theta));
		}

		glEnd();
	}
}
コード例 #6
0
void ScatteredLineBrush::BrushMove(const Point source, const Point target)
{
    ImpressionistDoc* pDoc = GetDocument();
    ImpressionistUI* dlg = pDoc->m_pUI;

    if (pDoc == NULL) {
        printf("PointBrush::BrushMove  document is NULL\n");
        return;
    }

    int lineAmount = 4;
    int size = pDoc->getSize();

    for (int i = 0; i < lineAmount; i++) {
        // Get random numbers to set scatter location in the brush area
        int randomX = rand() % size + (-size / 2);
        int randomY = rand() % size + (-size / 2);

        // We need to set a new Point source for the brush as well to
        // match the location of the source and the target point
        Point newSource(source.x + randomX, source.y + randomY);
        Point newTarget(target.x + randomX, target.y + randomY);

        LineBrush::BrushMove(newSource, newTarget);
    }
}
void ScatteredTriangleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;
	int size = pDoc->getSize();

	glPointSize((float)size);

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}
	for (int i = 0; i < rand() % 6 + 2; i++){

		// rand size start
		if(dlg->getIsPaint() && dlg->getIsRandSize()){
			size = rand() % pDoc->getSize() + 1;
		}
		// rand size end
		
		int randx = target.x - size / 2 + irand(size);
		int randy = target.y - size / 2 + irand(size);
		glBegin(GL_TRIANGLES);
		SetColor(source);
		glVertex2d(randx, randy + sqrt(0.75 * size * size) / 2);
		glVertex2d(randx - 0.5 * size, randy - sqrt(0.75 * size * size) / 2);
		glVertex2d(randx + 0.5 * size, randy - sqrt(0.75 * size * size) / 2);
		glEnd();
	}
}
コード例 #8
0
void FilterBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("FilterBrush::BrushMove  document is NULL\n");
		return;
	}

	int size = pDoc->getSize();
	double opacity = pDoc->getOpac();

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	if (isBlur){
		glPointSize(2);
		glBegin(GL_POINTS);
		Blur(source, opacity);
		glVertex2d(target.x, target.y);
		glEnd();
	}
	else{
		glPointSize(2);
		glBegin(GL_POINTS);
		Sharpen(source, opacity);
		glVertex2d(target.x, target.y);
		glEnd();
	}
}
コード例 #9
0
void TriangleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;
	int size = pDoc->getSize();

	glPointSize((float)size);

	// rand size start
	if(dlg->getIsPaint() && dlg->getIsRandSize()){
		size = rand() % pDoc->getSize() + 1;
	}
	// rand size end

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_TRIANGLES);
	SetColor(source);

	glVertex2d(target.x, target.y + sqrt(0.75 * size * size) / 2);
	glVertex2d(target.x - 0.5 * size, target.y - sqrt(0.75 * size * size) / 2);
	glVertex2d(target.x + 0.5 * size, target.y - sqrt(0.75 * size * size) / 2);

	glEnd();
}
コード例 #10
0
ファイル: impbrush.cpp プロジェクト: ohwang/Impressionist
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample 
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source, int optional_alpha)
{
	ImpressionistDoc* pDoc = GetDocument();

	GLubyte color[4];

	memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
	color[3] = static_cast<GLubyte>(255.0f * m_pDoc->getAlpha());

	// dirty patch
	// just bear it, this is life

	// for debug
	/*
	int tset = optional_alpha;
	char msg[222];
	sprintf(msg, "%d\n\n", tset);
	OutputDebugString(msg);
	*/

	if (optional_alpha > 0) {
		// OutputDebugString("called, gengge\n");
		color[3] = (GLubyte)optional_alpha;
	}

	for (int i = 0; i < 3; i++) {
		if (m_pDoc->m_pUI->m_ReverseColorButton->value()) color[i] = (GLubyte) (255 - color[i] * m_pDoc->m_pUI->blendColor[i]);
		else color[i] = (GLubyte) (color[i] * m_pDoc->m_pUI->blendColor[i]);
	}
 
	glColor4ubv( color );
}
コード例 #11
0
void ImpressionistUI::cb_paintlyStyleChoice(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	int type = (int)v;
	pDoc->setPaintlyStyle(type);
}
コード例 #12
0
void ImpressionistUI::cb_paintlyLayersSlider(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	int val = int(((Fl_Slider *)o)->value());
	pDoc->setPaintlyLayers(val);
}
コード例 #13
0
ファイル: triangleBrush.cpp プロジェクト: prashar/Graphics
void TriangleBrush::BrushMove( const ImpBrush::Point source, const ImpBrush::Point target )
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;
	int size = pDoc->getSize(); 
	int Ax, Ay, Bx, By, Cx, Cy; 
	Ax = target.x - (.5*size); 
	Bx = target.x + (.5*size);
	Cx = target.x;
	Ay = target.y - (.5*size);
	By = target.y - (.5*size);
	Cy = target.y + (.5*size);

	if ( pDoc == NULL ) {
		printf( "TriangleBrush::BrushMove  document is NULL\n" );
		return;
	}

	glBegin( GL_POLYGON );
		SetColor( source );
		glVertex2i(Ax, Ay);
		glVertex2i(Bx, By);
		glVertex2i(Cx, Cy);
	glEnd();
}
コード例 #14
0
void ScatteredPointBrush::BrushMove( const Point source, const Point target )
{
    ImpressionistDoc* pDoc = GetDocument();
    ImpressionistUI* dlg=pDoc->m_pUI;

    //スライダーつけたあと

    if ( pDoc == NULL ) {
        printf( "ScatteredPointBrush::BrushMove  document is NULL\n" );
        return;
    }

    int size=pDoc->getSize();
    float Ax,Ay;
    glPointSize(1.0);
    glBegin(GL_POINTS);
    SetColor(source);

    for(int i=0; i < 10 ; i++) {
        Ax = target.x - size/2+rand()%size;
        Ay = target.y - size/2+rand()%size;
        glVertex2i(Ax , Ay);
    }

    glEnd();
}
コード例 #15
0
void SPointsBrush::BrushMove( const Point source, const Point target )
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;
	int x, y, i, j, size = pDoc->getSize();

	if ( pDoc == NULL ) {
		printf( "SPointsBrush::BrushMove  document is NULL\n" );
		return;
	}
	
	glPointSize( 1.0f );
	glBegin( GL_POINTS );

		for(x = target.x - (size >> 1), i = 0; i <= size; i++, x++) {
			for(y = target.y - (size >> 1), j = 0; j <= size; j++, y++) {
				if(!irand(5)) { // Make it more scattered
					SetColor( Point(x, y) );
					glVertex2d(x, y);
				}
			}
		}


	glEnd();
}
コード例 #16
0
void ImpressionistUI::cb_paintlyJvSlider(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	double val = double(((Fl_Slider *)o)->value());
	pDoc->setPaintlyJv(val);
}
コード例 #17
0
void MotionBlurBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	int size = pDoc->getSize();
	// Set to one, we want to get color per pixel
	glPointSize(1.0);

	glBegin(GL_POINTS);

	for (int i = -size / 2; i <= size / 2; i++) {
		for (int j = -size / 2; j <= size / 2; j++) {
			SetColor(Point(source.x + i, source.y + j));
			glVertex2d(target.x + i, target.y + j);
		}
	}

	glEnd();
}
コード例 #18
0
void ImpressionistUI::cb_load_dissolve_image(Fl_Menu_* o, void* v) {
    ImpressionistDoc *pDoc = whoami(o)->getDocument();

    char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName());
    if (newfile != NULL) {
        pDoc->loadDissolveImage(newfile);
    }
}
コード例 #19
0
void ImpressionistUI::cb_strokeDirectionChoice(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI*)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();

	int type = (int)v;
	pDoc->setStrokeDirectionType(type);
}
コード例 #20
0
ファイル: lineBrush.cpp プロジェクト: sfpotter/imp
void
LineBrush::BrushBegin(const ImpBrush::Point source, const ImpBrush::Point target)
{
  ImpressionistDoc* pDoc = GetDocument();
  ImpressionistUI* dlg = pDoc->m_pUI;

  glLineWidth(pDoc->getLineWidth());
  BrushMove(source, target);
}
コード例 #21
0
ファイル: pointBrush.cpp プロジェクト: rapidsnow/imp
void PointBrush::BrushBegin( const Point source, const Point target )
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;

	int size = pDoc->getSize();
	glPointSize( (float)size );
	BrushMove( source, target );
}
コード例 #22
0
//------------------------------------------------------------
// Extract edge
// Called by the UI when the EdgeExtraction button is pushed
//------------------------------------------------------------
void ImpressionistUI::cb_EdgeExtraction(Fl_Widget* o, void* v)
{
	ImpressionistUI *pUI = ((ImpressionistUI*)(o->user_data()));
	ImpressionistDoc * pDoc = ((ImpressionistUI*)(o->user_data()))->getDocument();

	//calculate the edge map according to the threshold
	pDoc->CalculateEdgeMap(pUI->m_nEdgeThreshold);
	pUI->m_origView->viewMode = OriginalView::EDGE_MODE;
	pUI->m_origView->refresh();
}
コード例 #23
0
ファイル: impBrush.cpp プロジェクト: rapidsnow/imp
void	ImpBrush::AngleDragBegin(const Point source) 
{
	ImpressionistDoc* pDoc = GetDocument();

	if(pDoc->getAngleRadio() != 1)
		return;

	pDoc->setRightClickStart(source);

}
コード例 #24
0
void ScatteredLineBrush::BrushBegin(const Point source, const Point target)
{
    ImpressionistDoc* pDoc = GetDocument();
    ImpressionistUI* dlg = pDoc->m_pUI;

    int width = pDoc->getLineWidth();
    glLineWidth(width);

    startCoord = Point(target.x, target.y);
    BrushMove(source, target);
}
コード例 #25
0
void ScatteredPointBrush::BrushBegin(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	m_size = (float)pDoc->getBrushSize();

	glPointSize(m_size);

	BrushMove(source, target);
}
コード例 #26
0
ファイル: lineBrush.cpp プロジェクト: rapidsnow/imp
void LineBrush::BrushBegin( const Point source, const Point target )
{
    ImpressionistDoc* pDoc = GetDocument();
    ImpressionistUI* dlg=pDoc->m_pUI;

    int lineWidth = pDoc->getLineWidth();
    glLineWidth((GLfloat) lineWidth);

    pDoc->setLastPoint( source );
    BrushMove( source, target );
}
コード例 #27
0
void ScatteredLinesBrush::BrushBegin(const ImpBrush::Point source, const ImpBrush::Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg=pDoc->m_pUI;

	int dWidth = pDoc->getLineSize();

	glLineWidth((float)dWidth);

	BrushMove( source, target );
}
コード例 #28
0
//---The light button callback for edge clipping---------------------
void ImpressionistUI::cb_EdgeClipping(Fl_Widget* o, void* v)
{
	ImpressionistUI *pUI = ((ImpressionistUI*)(o->user_data()));

	if (pUI->m_bEdgeClipping == TRUE) pUI->m_bEdgeClipping = FALSE;
	else {
		pUI->m_bEdgeClipping = TRUE;
		ImpressionistDoc* pDoc = pUI->getDocument();
		pDoc->CalculateEdgeMap(pUI->m_nEdgeThreshold);
	}
}
コード例 #29
0
ファイル: impBrush.cpp プロジェクト: deveshsahu/Impressionist
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample 
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
	ImpressionistDoc* pDoc = GetDocument();


	GLubyte color[3];

	memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
 
	glColor3ubv( color );

}
コード例 #30
0
void ImpressionistUI::cb_load_dissolve(Fl_Menu_* o, void* v)
{
	ImpressionistDoc *pDoc = whoami(o)->getDocument();
	if (!pDoc->m_ucBitmap) {
		fl_alert("Please load a background image first.");
		return;
	}
	char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName());
	if (newfile != NULL) {
		pDoc->loadDissolveImage(newfile);
	}
}