-
Notifications
You must be signed in to change notification settings - Fork 0
/
impBrush.cpp
85 lines (66 loc) · 2.04 KB
/
impBrush.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// impBrush.cpp
//
// The implementation of virtual brush. All the other brushes inherit from it.
//
#include "impressionistDoc.h"
#include "impressionistUI.h"
#include "impBrush.h"
// Static class member initializations
int ImpBrush::c_nBrushCount = 0;
ImpBrush** ImpBrush::c_pBrushes = NULL;
ImpBrush::ImpBrush(ImpressionistDoc* pDoc,
const char* name) :
m_pDoc(pDoc),
m_pBrushName(name)
{
}
//---------------------------------------------------
// Return m_pDoc, which connects the UI and brushes
//---------------------------------------------------
ImpressionistDoc* ImpBrush::GetDocument(void)
{
return m_pDoc;
}
//---------------------------------------------------
// Return the name of the current brush
//---------------------------------------------------
const char* ImpBrush::BrushName(void)
{
return m_pBrushName;
}
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[3] = (GLubyte)pDoc->getAlpha(); //Set the alpha channel to whatever the slider says
glColor4ubv( color );
}
//-------------------------------------------------------
// Use right click and drag to set the angle of the brush
//-------------------------------------------------------
void ImpBrush::AngleDragBegin(const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
if(pDoc->getAngleRadio() != 1)
return;
pDoc->setRightClickStart(source);
}
void ImpBrush::AngleDragMid(const Point source)
{
}
void ImpBrush::AngleDragEnd(const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
if(pDoc->getAngleRadio() != 1)
return;
Point start = pDoc->getRightClickStart();
int angle = int( atan( float( (source.y - start.y) )/(source.x - start.x) ) * (180./M_PI));
pDoc->setBrushAngle(angle);
}