-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScatteredCircleBrush.cpp
69 lines (51 loc) · 1.52 KB
/
ScatteredCircleBrush.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// ScatteredCircleBrush.cpp
//
// The implementation of Point Brush. It is a kind of ImpBrush. All your brush implementations
// will look like the file with the different GL primitive calls.
//
#include "impressionistDoc.h"
#include "impressionistUI.h"
#include "ScatteredCircleBrush.h"
#include <math.h>
extern float frand();
ScatteredCircleBrush::ScatteredCircleBrush( ImpressionistDoc* pDoc, char* name ) :
ImpBrush(pDoc,name)
{
}
void ScatteredCircleBrush::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 );
}
void ScatteredCircleBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "ScatteredCircleBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
int maximum = rand() % 4 + 1;
while (maximum) {
int x_offset = rand() % size;
int y_offset = rand() % size;
glBegin(GL_TRIANGLE_FAN);
Point newSource = Point(target.x + x_offset, target.y + y_offset);
SetColor(newSource);
for (int i = 0; i < 360; i++) {
float angle = (i * 3.14159) / 180;
glVertex2d(newSource.x + size*cos(angle), newSource.y + size*sin(angle));
}
glEnd();
maximum -= 1;
}
}
void ScatteredCircleBrush::BrushEnd( const Point source, const Point target )
{
// do nothing so far
}