-
Notifications
You must be signed in to change notification settings - Fork 0
/
XPen.cpp
53 lines (47 loc) · 1.06 KB
/
XPen.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
//
// Project: BrushWorkApp
// Title: XPen.cpp
// Author: Jacob Grafenstein
// Author URI: https://github.com/Jake-Grafenstein
// Description: The XPen class inherits from Tool class. It defines the mask for the XPen.
//
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include "Tool.h"
#include "XPen.h"
using namespace std;
using std::cerr;
using std::endl;
using std::fill;
XPen::XPen() {
int i, j;
maskSize = 21;
// Allocate space for mask, double array
mask=(float**) malloc(maskSize*sizeof(float*));
for (i=0;i<maskSize;i++) {
mask[i]=(float*) malloc(maskSize*sizeof(float));
}
// Stores the float values inside the mask
for (i=0;i<maskSize;i++) {
for (j=0;j<maskSize;j++) {
mask[i][j] = 0.0;
}
}
for (i=0;i<maskSize;i++) {
for (j=0;j<maskSize;j++) {
if (i == j) {
mask[i][j] = 1.0;
mask[i][maskSize-j-1] = 1.0;
}
}
}
}
// Deallocates the space created by the mask
XPen::~XPen() {
int i;
for (i=0;i<maskSize;i++) {
free(mask[i]);
}
free(mask);
}