-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pen.cpp
50 lines (44 loc) · 1.02 KB
/
Pen.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
//
// Project: BrushWorkApp
// Title: Pen.cpp
// Author: Jacob Grafenstein
// Author URI: https://github.com/Jake-Grafenstein
// Description: This class inherits from the Tool class. It creates a mask to apply to the canvas.
//
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include "Tool.h"
#include "Pen.h"
using namespace std;
using std::cerr;
using std::endl;
using std::fill;
Pen::Pen() {
int i, j;
maskSize = 7;
// Allocate space for mask, double array
mask=(float**) malloc(7*sizeof(float*));
for (i=0;i<maskSize;i++) {
mask[i]=(float*) malloc(maskSize*sizeof(float));
}
// Store float values within the mask
for (i=0;i<maskSize;i++) {
for (j=0;j<maskSize;j++) {
if (((2 < i) && (i < 6)) && ((2 < j) && (j < 6))) {
mask[i][j] = 1.0;
}
else {
mask[i][j] = 0;
}
}
}
}
// Deallocate space created by the Pen mask
Pen::~Pen() {
int i;
for (i=0;i<maskSize;i++) {
free(mask[i]);
}
free(mask);
}