Question: help fix my code: #include asciigen.h #include #include using namespace std; / / * * * * * * * * * * *

help fix my code:
#include "asciigen.h"
#include
#include
using namespace std;
//***************************************
// private functions
//***************************************
// Prints the title centered in a 2*DIM width
void print_title(const char title[], ostream &out){
int len = static_cast(strlen(title));
int offset = DIM - len /2;
char centred[DIM*2+1]={}; //+1 for null terminator
for (int i =0; i < DIM *2; ++i)
centred[i]='';
strncpy(centred + offset, title, len);
out <<"|"<< centred <<'|'<< endl;
}
// Copies the contents of rhs to art
void copy(char art[DIM][DIM], const char rhs[DIM][DIM]){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
art[r][c]= rhs[r][c];
}
}
}
// Get the pixel value at the given position.
// Returns empty if out of bounds.
char get(const char art[DIM][DIM], int x, int y){
char value = EMPTY;
if (x >=0 && x < DIM && y >=0 && y < DIM){
value = art[y][x];
}
return value;
}
//***************************************
// public functions
//***************************************
void print(const char art[DIM][DIM], const char title[], std::ostream &out){
print_title(title, out);
for (int r =0; r < DIM; ++r){
out <<"|";
for (int c =0; c < DIM; ++c){
out << art[r][c];
}
out <<"|"<< endl;
}
}
void init(char art[DIM][DIM]){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
art[r][c]= EMPTY;
}
}
}
void draw_circle(char art[DIM][DIM], int radius, int x, int y){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
if ((c - x)*(c - x)+(r - y)*(r - y)<= radius * radius){
art[r][c]= FILL;
}
}
}
}
void draw_rectangle(char art[DIM][DIM], int width, int height, int x, int y){
for (int r = y; r < y + height && r < DIM; ++r){
for (int c = x; c < x + width && c < DIM; ++c){
if (r >=0 && c >=0){
art[r][c]= FILL;
}
}
}
}
void draw_equilateral(char art[DIM][DIM], int side, int x, int y){
int height = static_cast(sqrt(3)/2* side);
int half_width = side /2;
for (int row =0; row < height && (y + row)< DIM; ++row){
int row_start = x -(row * half_width / height);
int row_end = x +(row * half_width / height);
for (int col = row_start; col <= row_end && col < DIM; ++col){
if (col >=0 && (y + row)>=0){
art[y + row][col]= FILL;
}
}
}
}
void calc_union(char lhs[DIM][DIM], const char rhs[DIM][DIM]){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
if (rhs[r][c]== FILL)
lhs[r][c]= FILL;
}
}
}
void calc_intersection(char lhs[DIM][DIM], const char rhs[DIM][DIM]){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
if (rhs[r][c]!= FILL)
lhs[r][c]= EMPTY;
}
}
}
void calc_complement(char art[DIM][DIM]){
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
art[r][c]=(art[r][c]== FILL)? EMPTY : FILL;
}
}
}
void rotate(char art[DIM][DIM], double radians){
char temp[DIM][DIM];
init(temp);
const double cosine = cos(radians);
const double sine = sin(radians);
static const int cx = DIM /2;
static const int cy = DIM /2;
for (int r =0; r < DIM; ++r){
for (int c =0; c < DIM; ++c){
int src_x = static_cast(cosine *(c - cx)- sine *(r - cy)+ cx);
int src_y = static_cast(sine *(c - cx)+ cosine *(r - cy)+ cy);
temp[r][c]=

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!