-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScatteredPointsBrush.cpp
72 lines (53 loc) · 1.62 KB
/
ScatteredPointsBrush.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
69
70
71
#include "ScatteredPointsBrush.h"
#include "impressionistDoc.h"
#include "impressionistUI.h"
extern float frand();
ScatteredPointsBrush::ScatteredPointsBrush(ImpressionistDoc* pDoc, char* name) :
ImpBrush(pDoc, name)
{
}
void ScatteredPointsBrush::BrushBegin(const Point source, const Point target, int DirectionType)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
int size = pDoc->getSize();
glPointSize(1.0);
BrushMove(source, target,DirectionType);
}
void ScatteredPointsBrush::BrushMove(const Point source, const Point target, int DirectionType)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
Blend();
if (pDoc == NULL) {
printf("ScatteredPointsBrush::BrushMove document is NULL\n");
return;
}
int size = pDoc->getSize();
int radio = (int)((0.7 + 1 / 5 * frand()) * size); //by row and column
int end = radio * radio;
for (int i = 0; i < end; i++) {
Point a(source.x - 0.5 * size + (int)(frand() * size), source.y - 0.5 * size + (int)(frand() * size));
Point b(target.x - 0.5 * size + (int)(frand() * size), target.y - 0.5 * size + (int)(frand() * size));
DrawOnePoint(a,b);
}
}
void ScatteredPointsBrush::DrawOnePoint(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;
}
glPointSize(1.0);
Blend();
glBegin(GL_POINTS);
SetColor(target);
glVertex2d(target.x, target.y);
glEnd();
}
void ScatteredPointsBrush::BrushEnd(const Point source, const Point target)
{
// do nothing so far
}