forked from dipsywong98/COMP4411-impressionist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlphaMapBrush.cpp
62 lines (49 loc) · 1.2 KB
/
AlphaMapBrush.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
#include "AlphaMapBrush.h"
#include "impressionistDoc.h"
#include "impressionistUI.h"
#include "AlphaMapBrush.h"
AlphaMapBrush::AlphaMapBrush(ImpressionistDoc* pDoc, char* name) :
ImpBrush(pDoc, name)
{
}
AlphaMapBrush::~AlphaMapBrush()
{
}
void AlphaMapBrush::BrushBegin(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
BrushMove(source, target);
}
void AlphaMapBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("AlphaMapBrush::BrushMove document is NULL\n");
return;
}
if (source.x > pDoc->m_nPaintWidth || source.y < 0)
{
return;
}
glPointSize((float)1);
glBegin(GL_POINTS);
int aw = pDoc->m_alphaMapWidth;
int ah = pDoc->m_alphaMapHeight;
float alphaOriginal = pDoc->m_pUI->getAlpha();
for(int i = 0; i<aw; i++)
{
for(int j=0; j<ah; j++)
{
pDoc->m_pUI->setAlpha(pDoc->GetAlpha(i, j));
SetColor(source);
glVertex2d(target.x + i - aw/2, target.y + j - ah/2);
}
}
pDoc->m_pUI->setAlpha(alphaOriginal);
glEnd();
}
void AlphaMapBrush::BrushEnd(const Point source, const Point target)
{
}