void LineBrush::BrushMove( const ImpBrush::Point source, const ImpBrush::Point target ) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg=pDoc->m_pUI; if ( pDoc == NULL ) { printf( "LineBrush::BrushMove document is NULL\n" ); return; } int size = pDoc->getSize(); int width = pDoc->getLineSize(); int angle = pDoc->getLineAngle(); int direction = pDoc->getStrokeDirection(); if(direction == STROKE_DIRECTION_GRADIENT) { // // Use sobel gradient // angle = SobelGradient(source); } GLint Ax,Ay,Bx,By,Qx,Qy; // // Compute Line points // Ax = target.x - (.5*size); Bx = target.x + (.5*size); Ay = target.y; By = target.y; // // Translate, Rotate, Translate // glPushMatrix(); glTranslatef(target.x, target.y, 0); glRotatef (angle, 0.0, 0.0, 1.0); glTranslatef(-target.x, -target.y, 0); SetColor( source ); glBegin( GL_LINES ); glVertex2i( Ax, Ay ); glVertex2i( Bx, By ); glEnd(); glPopMatrix(); }
void ScatteredLinesBrush::BrushMove(const ImpBrush::Point source, const ImpBrush::Point target) { // Get the basic pointers to document and UI. ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg=pDoc->m_pUI; // Draw Random Lines m_ccount >= INT_MAX ? m_ccount = 0 : m_ccount++; srand(time(NULL) + m_ccount); ImpBrush::Point temp_point; GLint total_lines = 4; GLint A1x, A2x, AxMid, A1y, A2y, Ox, Oy; if ( pDoc == NULL ) { printf( "SingleLineBrush::BrushMove document is NULL\n" ); return; } // Get the size, width, angle, and direction of the stroke int dSize = pDoc->getSize(); int dWidth = pDoc->getLineSize(); int dAngle = pDoc->getLineAngle(); int dDirection = pDoc->getStrokeDirection(); // Overwrite stroke if GRADIENT chosen if (dDirection == STROKE_DIRECTION_GRADIENT) { dAngle = SobelGradient(source); } // Compute Line Points Ox = target.x - (.5 * dSize); Oy = target.y - (.5 * dSize); GLint rand_lines = rand() % total_lines + 1; for (int i = 0; i < rand_lines; i++) { // Get Y first A1y = rand() % dSize + Oy; A2y = A1y; // Get X1 and X2 ( start and end lines ) A1x = rand() % dSize + Ox; A2x = A1x + dSize; AxMid = .5*(A1x + A2x); temp_point.x = source.x + (AxMid - target.x); temp_point.y = source.y + (A1y - target.y); SetColor(temp_point); // Translate, Rotate, Translate glPushMatrix(); glTranslatef(target.x, target.y, 0); glRotatef(dAngle, 0.0, 0.0, 1.0); glTranslatef(-target.x, -target.y, 0); glBegin(GL_LINES); glVertex2i(A1x, A1y); glVertex2i(A2x, A2y); glEnd(); glPopMatrix(); } }