من کدهام هم اینجا می ذارم
کد تصویر اول
#include <graphics.h>
int main() {
int gd = DETECT, gm;
// Initialize the graphics system
initgraph(&gd, &gm, NULL);
int left = 100; // Left coordinate of the square
int top = 100; // Top coordinate of the square
int right = 200; // Right coordinate of the square
int bottom = 200; // Bottom coordinate of the square
// Draw the square using rectangle function
rectangle(left, top, right, bottom);
// Draw diagonal lines (hatching) inside the square
for (int i = left; i <= right; i += 10) {
// Upper left to lower right diagonal
line(i, top, right, top + (i - left));
// Lower left to upper right diagonal
line(i, bottom, right, bottom - (i - left));
}
for (int j = top; j <= bottom; j += 10) {
// Upper left to lower right diagonal
line(left, j, left + (j - top), bottom);
// Upper right to lower left diagonal
line(right, j, right - (j - top), bottom);
}
getch(); // Wait for the user's input
closegraph(); // Close the graphics window
return 0;
}
کد تصویر دوم
#include <graphics.h>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL); // Initialize the graphics system
// Drawing a square
int topLeftX = 100, topLeftY = 100;
int bottomRightX = 300, bottomRightY = 200;
rectangle(topLeftX, topLeftY, bottomRightX, bottomRightY);
// Drawing filled rectangles and arcs inside the square
for (int i = 50; i <= 100; i += 50) {
setfillstyle(SOLID_FILL, LIGHTGRAY);
bar(topLeftX + i, topLeftY, bottomRightX - i, bottomRightY);
setcolor(WHITE);
// Calculate radius for arcs
int radius = (bottomRightX - topLeftX) / 2 - i;
// Draw arcs in the top-left and bottom-right corners
arc(topLeftX + radius, topLeftY, 0, 90, radius); // Arc from top-left corner
arc(bottomRightX - radius, bottomRightY, 180, 270, radius); // Arc from bottom-right corner
}
getch(); // Wait for a key press
closegraph(); // Close the graphics mode
return 0;
}