w15 <<
Previous Next >> 2
1
直接在青天與滿地紅的圖案中, 利用白色作為畫線顏色, 將第二組的 ABED 等四個點的座標, 以直線相連
#include <stdio.h>
#include <gd.h>
#include <math.h>
void draw_roc_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_roc_flag(img);
FILE *outputFile = fopen("roc_flag.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_roc_flag(gdImagePtr img) {
int width = gdImageSX(img);
int height = gdImageSY(img);
int red, white, blue;
int center_x = (int)(width / 4);
int center_y = (int)(height / 4);
red = gdImageColorAllocate(img, 255, 0, 0);
white = gdImageColorAllocate(img, 255, 255, 255);
blue = gdImageColorAllocate(img, 0, 0, 149);
gdImageFilledRectangle(img, 0, 0, width, height, red);
gdImageFilledRectangle(img, 0, 0, (int)(width / 2.0), (int)(height / 2.0), blue);
int A_x = 429;
int A_y = 125;
int B_x = 279;
int B_y = 165;
int E_x = 170;
int E_y = 274;
int D_x = 319;
int D_y = 234;
gdImageLine(img, A_x, A_y, B_x, B_y, white);
gdImageLine(img, B_x, B_y, E_x, E_y, white);
gdImageLine(img, E_x, E_y, D_x, D_y, white);
gdImageLine(img, D_x, D_y, A_x, A_y, white);
}
w15 <<
Previous Next >> 2