-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from dipsywong98/wip/pixelize
pixelize brush
- Loading branch information
Showing
10 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// 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) | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// PixelizeBrush.h | ||
// | ||
// The header file for Point Brush. | ||
// | ||
|
||
#ifndef PixelizeBrush_H | ||
#define PixelizeBrush_H | ||
|
||
#include "ImpBrush.h" | ||
|
||
class PixelizeBrush : public ImpBrush | ||
{ | ||
public: | ||
PixelizeBrush(ImpressionistDoc* pDoc = NULL, char* name = NULL); | ||
|
||
void BrushBegin(const Point source, const Point target); | ||
void BrushMove(const Point source, const Point target); | ||
void BrushEnd(const Point source, const Point target); | ||
char* BrushName(void); | ||
|
||
Point startSource, startTarget; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters