-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScatteredPointBrush.cpp
65 lines (50 loc) · 1.44 KB
/
ScatteredPointBrush.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
//
// ScatteredPointBrush.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 "ScatteredPointBrush.h"
#include <random>
extern float frand();
ScatteredPointBrush::ScatteredPointBrush( ImpressionistDoc* pDoc, char* name ) :
ImpBrush(pDoc,name)
{
}
void ScatteredPointBrush::BrushBegin( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
int size = pDoc->getSize();
glPointSize( 1.0 );
BrushMove( source, target );
}
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;
}
glBegin( GL_POINTS );
int size = pDoc->getSize();
std::mt19937 e(std::random_device{}());
std::bernoulli_distribution d;
for (int i = -size/2; i < size/2; i++) {
for (int j = -size/2; j < size/2; j++) {
if (d(e)) {
Point newsource = Point(source.x + i, source.y + j);
SetColor(newsource);
glVertex2d(newsource.x, newsource.y);
}
}
}
glEnd();
}
void ScatteredPointBrush::BrushEnd( const Point source, const Point target )
{
// do nothing so far
}