41223108 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • About
  • 倉儲維護
    • s.cycu.org維護
    • windows維護
  • weekly progress
    • w1~4
    • w5
    • w6
    • w7
    • w9
    • w12
      • helloworld
      • GD繪圖程式1
    • W13
    • w15
  • ANSIC
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
    • 6.
    • 7.
    • 8.
    • 9.
    • 10.
  • NOTE
    • ssh
    • puttygen
  • 國旗練習
    • Thai
    • Laos
    • Bangladesh
    • vietnam
    • Italian
    • Russia
    • Belgium
    • Ukraine
    • Korea
  • 課程評分
  • Brython
  • setup
  • C_lib
  • replit
  • MSD
  • Final
Bangladesh << Previous Next >> Italian

vietnam

#include <stdio.h>
#include <gd.h>
#include <math.h>

#define WIDTH 600
#define HEIGHT 400
#define RED 0xDC143C  // Crimson color
#define YELLOW 0xFFFF00

void drawStar(gdImagePtr im, int x, int y, int outerRadius, int innerRadius, int color) {
    double angle = -M_PI / 2.0;  // Starting angle for the star

    gdPoint starPoints[10];

    for (int i = 0; i < 10; i++) {
        int radius = i % 2 == 0 ? outerRadius : innerRadius;
        starPoints[i].x = x + radius * cos(angle);
        starPoints[i].y = y + radius * sin(angle);
        angle += M_PI / 5.0;  // Angle between two consecutive points
    }

    gdImageFilledPolygon(im, starPoints, 10, color);
}

void drawVietnamFlag() {
    gdImagePtr im;
    FILE *output;

    im = gdImageCreateTrueColor(WIDTH, HEIGHT);
    output = fopen("./../images/vietnam_flag.png", "wb");

    // Draw red background
    gdImageFilledRectangle(im, 0, 0, WIDTH - 1, HEIGHT - 1, RED);

    // Draw yellow star in the center
    int starSize = 60;
    int starX = WIDTH / 2;
    int starY = HEIGHT / 2;

    drawStar(im, starX, starY, starSize, starSize / 2, YELLOW);

    gdImagePng(im, output);
    fclose(output);
    gdImageDestroy(im);
}

int main() {
    drawVietnamFlag();
    return 0;
}


Bangladesh << Previous Next >> Italian

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