For the arrow part, I was trying to set the x-value to the center of the triangl
ID: 3862459 • Letter: F
Question
For the arrow part, I was trying to set the x-value to the center of the triangle (middle of the green rectangle (217.5) and the row value between 75 and 100).
This is what I have:
void largeRectangle(int x_shift, int y_shift) {
int x_max, y_max, x_start, y_start;
for (x_max = 40 + x_shift; x_max < 155 + x_shift; x_max = x_max + 1) {
for (y_max = 75 + y_shift; y_max < 155 + y_shift; y_max = y_max + 1) {
// Draw light blue rectangle
drawPixel(x_max, y_max, 0x965F);
}
}
}
void smallRectangle(int x_shift, int y_shift) {
int x_max, y_max, x_start, y_start;
for (x_max = 60 + x_shift; x_max < 135 + x_shift; x_max = x_max + 1) {
for (y_max = 95 + y_shift; y_max < 135 + y_shift; y_max = y_max + 1) {
// Draw light red rectangle
drawPixel(x_max, y_max, 0xFD34);
}
}
}
void arrow(int x_shift, int y_shift) {
int x_max, y_max, x_start, y_start;
for (x_max = 200 + x_shift; x_max < 235 + x_shift; x_max = x_max + 1) {
for (y_max = 100 + y_shift; y_max < 155 + y_shift; y_max = y_max + 1) {
// light green arrow - rectangle
drawPixel(x_max, y_max, 0xB7F0);
}
}
for (y_max = 40 + y_shift; y_max < 155 + y_shift; y_max = y_max + 1) {
for (x_max = -(y_max-40) + x_shift; x_max < (y_max-40) + x_shift; x_max = x_max + 1) {
// light green arrow - triangle
drawPixel(x_max, y_max, 0xB7F0);
}
}
}
How can I fix the bolded part to output a green triangle?
Explanation / Answer
for (y_max = 40 + y_shift; y_max < 155 + y_shift; y_max = y_max + 1) {
for (x_max = (x_max-217.5) - x_shift; x_max < (x_max-75) + x_shift; x_max = x_max + 1) {
// light green arrow - triangle
drawPixel(x_max, y_max, 0xB7F0);
}
}
In the x axis we are required to draw the triangle at the center ie at 217.5. so we need to set the max value accordingly and the row value is between 75 and 100. So the min values could be considered as 75.