-
Notifications
You must be signed in to change notification settings - Fork 3
/
PixelizeBrush.cpp
70 lines (54 loc) · 1.49 KB
/
PixelizeBrush.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
//
// PixelizeBrush.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 "PixelizeBrush.h"
extern float frand();
PixelizeBrush::PixelizeBrush(ImpressionistDoc* pDoc, char* name) :
ImpBrush(pDoc, name)
{
}
void PixelizeBrush::BrushBegin(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
int size = pDoc->getSize();
BrushMove(source, target);
}
void PixelizeBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* pUI = pDoc->m_pUI;
if (pDoc == NULL) {
printf("PixelizeBrush::BrushMove document is NULL\n");
return;
}
if (source.x > pDoc->m_nPaintWidth || source.y < 0)
{
return;
}
int ksize = pUI->getSize(), csize = pUI->getLineWidth();
int w = pDoc->m_nPaintWidth, h = pDoc->m_nPaintHeight;
glPointSize(1.0);
glBegin(GL_POINTS);
for(int i = -ksize/2; i < ksize / 2; i++)
{
for (int j = -ksize / 2; j < ksize / 2; j++) {
Point sample, subTarget;
sample.x = source.x+i - (source.x+i) % csize;
sample.y = source.y+j - (source.y+j) % csize;
subTarget.x = target.x + i;
subTarget.y = target.y + j;
SetColor(sample);
glVertex2d(subTarget.x, subTarget.y);
}
}
glEnd();
}
void PixelizeBrush::BrushEnd(const Point source, const Point target)
{
}