-
Notifications
You must be signed in to change notification settings - Fork 0
/
SprayCan.cpp
47 lines (41 loc) · 883 Bytes
/
SprayCan.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
// SprayCan.cpp
// Created by Stevie Frisbie
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <cmath>
#include "Tool.h"
#include "SprayCan.h"
using namespace std;
using std::cerr;
using std::endl;
using std::fill;
SprayCan::SprayCan() {
int i, j;
maskSize = 41;
// Allocate space for mask
mask = (float**) malloc(maskSize * sizeof(float*));
for (i = 0; i < maskSize; i++) {
mask[i] = (float*) malloc(41 * sizeof(float));
}
// Set float values for mask
for (i = 0; i < maskSize; i++) {
for (j = 0; j < maskSize; j++) {
float distance = calculateDistance(i, j, 20.0);
if (distance >= 20.0) {
mask[i][j] = 0;
}
else {
mask[i][j] = (20.0 - distance) * .01;
}
}
}
}
// Deallocate Space created by the Spray Can Mask
SprayCan::~SprayCan() {
int i;
for (i=0;i<maskSize;i++) {
free(mask[i]);
}
free(mask);
}