-
Notifications
You must be signed in to change notification settings - Fork 3
/
CircleBrush.cpp
68 lines (55 loc) · 1.36 KB
/
CircleBrush.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
#include "CircleBrush.h"
//
// CircleBrush.cpp
//
// The implementation of Line 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 <ostream>
#include <iostream>
extern float frand();
extern double degToRad(double);
CircleBrush::CircleBrush(ImpressionistDoc* pDoc, char* name) :
ImpBrush(pDoc, name)
{
}
void CircleBrush::BrushBegin(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
BrushMove(source, target);
}
void CircleBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("CircleBrush::BrushMove document is NULL\n");
return;
}
if (source.x > pDoc->m_nPaintWidth || source.y < 0)
{
return;
}
int size = pDoc->getSize();
SetColor(source);
DrawCircle(target, size);
}
void CircleBrush::BrushEnd(const Point source, const Point target)
{
}
void CircleBrush::DrawCircle(const Point target, int size)
{
glBegin(GL_POLYGON);
for (int i = 0; i < 360; i++)
{
double rad = degToRad(i);
glVertex2f(
static_cast<GLfloat>(target.x) + cos(rad)*size / 2.f,
static_cast<GLfloat>(target.y) + sin(rad)*size / 2.f
);
}
glEnd();
}