41223133

  • Home
    • SMap
    • reveal
    • blog
  • About
  • W5
    • 曲線圖
  • W6
  • W12
    • GD圖
  • W13
  • homework
    • 台灣國旗
    • 美國國旗
    • 日本國旗
    • 中國國旗
    • 英國國旗
    • 韓國國旗
  • 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <stdio.h>
#include <gd.h>
#include <math.h>
 
void draw_uk_flag(gdImagePtr img);
void fillTriangle(gdImagePtr img, int x1, int y1, int x2, int y2, int x3, int y3, int color);
 
int main() {
    // 设置国旗的宽和高
    int width = 1200;
    int height = width / 2;
 
    // 创建图像
    gdImagePtr img = gdImageCreateTrueColor(width, height);
    gdImageAlphaBlending(img, 0);
 
    // 绘制英国国旗
    draw_uk_flag(img);
 
    // 将图像保存到文件
    FILE *outputFile = fopen("./../images/uk_flag.png", "wb");
    if (outputFile == NULL) {
        fprintf(stderr, "打开输出文件时发生错误。\n");
        return 1;
    }
    gdImagePngEx(img, outputFile, 9);
    fclose(outputFile);
    gdImageDestroy(img);
    return 0;
}
 
 
 
void draw_uk_flag(gdImagePtr img) {
    int width = gdImageSX(img);
    int height = gdImageSY(img);
 
    int red, white, blue;
    red = gdImageColorAllocate(img, 204, 0, 0);       // 红色
    white = gdImageColorAllocate(img, 255, 255, 255); // 白色
    blue = gdImageColorAllocate(img, 0, 0, 153);      // 蓝色
 
    gdImageFilledRectangle(img, 0, 0, width, height, blue);
 
 
  int x1, y1, x2, y2, x3, y3;
  {
    int line_thickness = 100;
    gdImageSetThickness(img, line_thickness);
 
    int x1, y1, x2, y2, x3, y3;
 
    // 绘制白色斜线
    x1 = 0;
    y1 = 600;
    x2 = 1200;
    y2 = 0;
    gdImageLine(img, x1, y1, x2, y2, white);
 
    x1 = 0;
    y1 = 0;
    x2 = 1200;
    y2 = 600;
    gdImageLine(img, x1, y1, x2, y2, white);
}
  {
    int line_thickness = 33;
    gdImageSetThickness(img, line_thickness);
 
 
    // 绘制红色斜线
    x1 = 566;
    y1 = 300;
    x2 = 1166;
    y2 = 0;
    gdImageLine(img, x1, y1, x2, y2, red);
 
    x1 = 1233;
    y1 = 600;
    x2 = 633;
    y2 = 300;
    gdImageLine(img, x1, y1, x2, y2, red);
 
    x1 = 566;
    y1 = 300;
    x2 = -33;
    y2 = 0;
    gdImageLine(img, x1, y1, x2, y2, red);
 
    x1 = 600;
    y1 = 316.5;
    x2 = 0;
    y2 = 616.5;
    gdImageLine(img, x1, y1, x2, y2, red);
  }
  {
  int line_thickness = 33;
  gdImageSetThickness(img, line_thickness);
 
  int x1, y1, x2, y2, x3, y3;
 
  // 绘制  斜线
  x1 = 0;
  y1 = 600;
  x2 = 1200;
  y2 = 0;
  gdImageLine(img, x1, y1, x2, y2, red );
 
 
  x1 = 1200;
    y1 = 16.5;
    x2 = 600;
    y2 = 316.5;
    gdImageLine(img, x1, y1, x2, y2, white);
 
 
  x1 = 0;
    y1 = 583.5;
    x2 = 600;
    y2 = 283.5;
    gdImageLine(img, x1, y1, x2, y2, white);
 
 
  }
 
    // 绘制白色十字
    int cross_width = width / 32;
    int cross_arm_width = width / 32;
    int center_x = width / 2;
    int center_y = height / 2;
 
    gdImageFilledRectangle(img, center_x + 2.7 * cross_width, 0, center_x - 2.7 * cross_width, height, white);
    gdImageFilledRectangle(img, 0, center_y + 2.7 * cross_arm_width, width, center_y - 2.7 * cross_arm_width, white);
 
    // 绘制红色十字
    gdImageFilledRectangle(img, center_x + 1.5 * cross_width, 0, center_x - 1.5 * cross_width, height, red);
    gdImageFilledRectangle(img, 0, center_y + 1.5 * cross_arm_width, width, center_y - 1.5 * cross_arm_width, red);
}


中國國旗 << Previous Next >> 韓國國旗

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