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(); } }
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(); }
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(); }
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(); }
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(); } }
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(); } }
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(); } }
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(); }
//---------------------------------------------------- // 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 ); }
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); }
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); }
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(); }
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(); }
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(); }
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); }
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(); }
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); } }
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); }
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); }
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 ); }
//------------------------------------------------------------ // 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(); }
void ImpBrush::AngleDragBegin(const Point source) { ImpressionistDoc* pDoc = GetDocument(); if(pDoc->getAngleRadio() != 1) return; pDoc->setRightClickStart(source); }
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); }
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); }
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 ); }
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 ); }
//---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); } }
//---------------------------------------------------- // 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 ); }
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); } }