Skip to content

Instantly share code, notes, and snippets.

@ssi-anik
Created August 18, 2015 03:07
Show Gist options
  • Save ssi-anik/f5b804df136e8ceba841 to your computer and use it in GitHub Desktop.
Save ssi-anik/f5b804df136e8ceba841 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<graphics.h>
#include<math.h>
int driver = DETECT, mode, width, height;
void drawCircle(int scaling_factor);
int main() {
width = getmaxwidth() - 100;
height = getmaxheight() - 50;
int scaling_factor;
printf("what is your scaling factory (1-9): ");
while(true){
scanf("%d", &scaling_factor);
if(scaling_factor >= 1 && scaling_factor <= 9){
break;
}
printf("Can't take more than 9 and less than 1.\nInsert again: ");
}
drawCircle(scaling_factor);
return 0;
}
void drawCircle(int scaling_factor){
initgraph(&driver, &mode, "C:\\TC\\BIN");
char title[600];
sprintf(title, "Scaling with factory: %d", scaling_factor);
initwindow(width, height, title, 50, 0);
int circle_center_x = (int) floor(width / 5);
int circle_center_y = (int) floor(height / 2);
int circle_radius = 80;
circle(circle_center_x, circle_center_y, circle_radius);
int scaled_circle_center_x = (int) floor(((width - ( width / 5)) / 2));
int scaled_circle_center_y = (int) floor(height / 2);
int scaled_circle_radius = 80 * scaling_factor;
circle(scaled_circle_center_x, scaled_circle_center_y, scaled_circle_radius);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment