• Home
    • SMap
    • reveal
    • blog
  • about
  • w2-w4
    • ipv4
    • ipv6
    • INFO
  • w5
  • w6
    • 美國國旗
    • 中國國旗
    • 日本國旗
    • 英國國旗
    • 韓國國旗
  • w7
    • gd
    • chinese
    • korea
  • w9
  • w13
  • w14
  • w15
    • A1
    • A2
  • w16
  • 寒假
  • file
  • brython

41223125 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • about
  • w2-w4
    • ipv4
    • ipv6
    • INFO
  • w5
  • w6
    • 美國國旗
    • 中國國旗
    • 日本國旗
    • 英國國旗
    • 韓國國旗
  • w7
    • gd
    • chinese
    • korea
  • w9
  • w13
  • w14
  • w15
    • A1
    • A2
  • w16
  • 寒假
  • file
  • brython
美國國旗 << Previous Next >> 日本國旗

中國國旗

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <gd.h>
#include <math.h>
 
 
void draw_star(gdImagePtr img, int x, int y, int size, int color, int rotation);
void draw_proc_flag(gdImagePtr img);
 
int main() {
   
    int width = 1200;
 
    int height = (int)(width * 2.0 / 3.0);
 
    gdImagePtr img = gdImageCreateTrueColor(width, height);
    gdImageAlphaBlending(img, 0);
 
    draw_proc_flag(img);
 
    FILE *outputFile = fopen("Y:/tmp/c_ex/proc01.png", "wb");
    if (outputFile == NULL) {
        fprintf(stderr, "Error opening the output file.\n");
        return 1;
    }
    gdImagePngEx(img, outputFile, 9);
    fclose(outputFile);
    gdImageDestroy(img);
    return 0;
}
 
void draw_star(gdImagePtr img, int x, int y, int size, int color, int rotation) {
    double deg = M_PI / 180.0;
    gdPoint points[10];
    int num_points = 10;
 
    for (int i = 0; i < num_points; i++) {
 
        double angle = M_PI / 2 + i * 2 * M_PI / 10 + rotation * deg;
        int radius = (i % 2 == 0) ? size : size * sin(18 * deg) / cos(36 * deg);
        points[i].x = x + radius * cos(angle);
        points[i].y = y - radius * sin(angle);
    }
 
    gdImageFilledPolygon(img, points, num_points, color);
}
 
void draw_proc_flag(gdImagePtr img) {
    double deg = M_PI / 180.0;
    int width = gdImageSX(img);
    int height = gdImageSY(img);
    int red, yellow;
    double angle;
 
    int center_x = (int)(width / 6);
    int center_y = (int)(height / 4);
 
    int big_star_radius = (int)(width / 10);
 
    int small_star_radius = (int)(width / 30);
    
    red = gdImageColorAllocate(img, 238, 28, 37);
    yellow = gdImageColorAllocate(img, 255, 255, 0);
 
    gdImageFilledRectangle(img, 0, 0, width, height, red);
 
    draw_star(img, center_x, center_y, big_star_radius, yellow, 0);
 
    center_x = (int) width/3;
    center_y = (int) width/15;
 
    angle = 180 - atan(5/3)/deg;
    draw_star(img, center_x, center_y, small_star_radius, yellow, angle);
    // the second small star
    center_x = (int) 2*width/5;
    center_y = (int) 2*width/15;
 
    angle = 180 - atan(7/1)/deg;
    draw_star(img, center_x, center_y, small_star_radius, yellow, angle);
    // the third small star
    center_x = (int) 2*width/5;
    center_y = (int) 7*width/30;
 
    angle = atan(7/2)/deg;
    draw_star(img, center_x, center_y, small_star_radius, yellow, angle);
    // the fourth small star
    center_x = (int) width/3;
    center_y = (int) 3*width/10;
    angle = atan(5/4)/deg;
    draw_star(img, center_x, center_y, small_star_radius, yellow, angle);
}


美國國旗 << Previous Next >> 日本國旗

Copyright ©2025 All rights reserved | This template is made with by Colorlib