void draw_numeral( int x, int y, int n, int height, int width) { switch(n) { case 1: draw_one(x, y, height, width) ; break ; case 2: draw_two(x, y, height, width) ; break ; case 3: draw_three(x, y, height, width) ; break ; case 4: draw_four(x, y, height, width) ; break ; case 5: draw_five(x, y, height, width) ; break ; case 6: draw_six(x, y, height, width) ; break ; case 7: draw_seven(x, y, height, width) ; break ; case 8: draw_eight(x, y, height, width) ; break ; case 9: draw_nine(x, y, height, width) ; break ; case 0: draw_zero(x, y, height, width) ; break ; } }
int main (void) { int xSize=600, ySize=600, xMouse, yMouse, j; float h=100; char c; gfx_open(xSize, ySize, "Window"); while (1) { c = gfx_wait(); xMouse = gfx_xpos(); yMouse = gfx_ypos(); switch (c) { case '0': draw_zero(xMouse, yMouse, h); break; case '1': draw_one(xMouse, yMouse, h); break; case '2': draw_two(xMouse, yMouse, h); break; case '3': draw_three(xMouse, yMouse, h); break; case '4': draw_four(xMouse, yMouse, h); break; case '5': draw_five(xMouse, yMouse, h); break; case '6': draw_six(xMouse, yMouse, h); break; case '7': draw_seven(xMouse, yMouse, h); break; case '8': draw_eight(xMouse, yMouse, h); break; case '9': draw_nine(xMouse, yMouse, h); break; case '-': h = h/2; break; case '=': h = h*2; break; case 'q': return 0; } } return 0; }
/*F****************************************************************** * draw_digit(float x_position, float y_position, unsigned int digit, float size) * * PURPOSE : Draws the specified digit to the specified coordinates * at the specified size * * RETURN : void * * NOTES : *F*/ void draw_digit(float x_position, float y_position, unsigned int digit, float size) { glClearColor(255, 255, 255, 1); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); switch(digit) { case 0: draw_zero(x_position, y_position, size); return; case 1: draw_one(x_position, y_position, size); return; case 2: draw_two(x_position, y_position, size); return; case 3: draw_three(x_position, y_position, size); return; case 4: draw_four(x_position, y_position, size); return; case 5: draw_five(x_position, y_position, size); return; case 6: draw_six(x_position, y_position, size); return; case 7: draw_seven(x_position, y_position, size); return; case 8: draw_eight(x_position, y_position, size); return; case 9: draw_nine(x_position, y_position, size); return; default: return; } glEnd(); glutSwapBuffers(); }
void line(t_crd *pt1, t_crd *pt2, t_mlx ml) { t_lne lne; lne.dx = ft_abs(pt2->x - pt1->x); lne.dy = ft_abs(pt2->y - pt1->y); lne.x = pt1->x; lne.y = pt1->y; if (pt1->x < pt2->x) lne.x_incr = 1; else lne.x_incr = -1; if (pt1->y < pt2->y) lne.y_incr = 1; else lne.y_incr = -1; if (lne.dx > lne.dy) draw_one(&lne, ml); else draw_two(&lne, ml); }