C ++ ZBYT DUŻY
Próbowałem to przy użyciu mojej domowej biblioteki rysunków PPM . Jest technicznie skalowalny, ale jestem ograniczony przez moją funkcję rekurencyjnego wypełniania, ponieważ jest zawodna i lubi segfault, myślę, że zużywa zbyt dużo pamięci, więc nie pozwolę użytkownikowi ustawić skali. Obraz jest nieregularny, ponieważ współrzędne, które wpisałem dla każdego rogu słupków, są nieco wyłączone.
Ustawiłem go tak, aby zaczynał od czarnego tła, następnie umieściłem biały okrąg na środku, a następnie czerwony i niebieski okrąg. Użyto rekurencyjnych wypełnień, aby dodać resztę czerwieni i niebieskiego. Następnie narysuj prostokąty białymi liniami, aby zaznaczyć czarne pasy. Podziel czarne tło na 4 sekcje z białymi liniami i użyj 4 rekurencyjnych wypełnień, aby każda sekcja była biała. Wykonanie tego w jednym przejściu spowodowałoby awarię. Renderowanie jest nadal bardzo wolne.
Nieskluczony kod główny (reszta biblioteki jest za duża, gra w golfa nie ma znaczenia)
#include "PPMDraw.h"
#include <iostream>
int main(){
std::cout << "Drawing Korean Flag" << std::endl;
int scale = 150;
int width = 3 * scale;
int height = 2 * scale;
int xc = width/2;
int yc = height/2;
// coords for the bar corners
float nwax = -0.773; float nway = -0.813;
float nwbx = -0.707; float nwby = -0.773;
float nwcx = -1.000; float nwcy = -0.360;
float nwdx = -1.050; float nwdy = -0.400;
float nwex = -0.667; float nwey = -0.747;
float nwfx = -0.613; float nwfy = -0.693;
float nwgx = -0.880; float nwgy = -0.293;
float nwhx = -0.947; float nwhy = -0.333;
float nwix = -0.560; float nwiy = -0.667;
float nwjx = -0.507; float nwjy = -0.627;
float nwkx = -0.773; float nwky = -0.227;
float nwlx = -0.840; float nwly = -0.267;
float neax = 0.747; float neay = -0.813;
float nebx = 0.867; float neby = -0.627;
float necx = 0.813; float necy = -0.587;
float nedx = 0.680; float nedy = -0.773;
float neex = 0.893; float neey = -0.587;
float nefx = 1.030; float nefy = -0.400;
float negx = 0.960; float negy = -0.360;
float nehx = 0.840; float nehy = -0.547;
float neix = 0.640; float neiy = -0.747;
float nejx = 0.920; float nejy = -0.333;
float nekx = 0.853; float neky = -0.293;
float nelx = 0.587; float nely = -0.693;
float nemx = 0.533; float nemy = -0.667;
float nenx = 0.667; float neny = -0.493;
float neox = 0.600; float neoy = -0.440;
float nepx = 0.480; float nepy = -0.627;
float neqx = 0.693; float neqy = -0.440;
float nerx = 0.813; float nery = -0.267;
float nesx = 0.747; float nesy = -0.227;
float netx = 0.627; float nety = -0.400;
float swax = -0.773; float sway = 0.200;
float swbx = -0.507; float swby = 0.613;
float swcx = -0.560; float swcy = 0.653;
float swdx = -0.840; float swdy = 0.253;
float swex = -0.880; float swey = 0.280;
float swfx = -0.760; float swfy = 0.453;
float swgx = -0.813; float swgy = 0.493;
float swhx = -0.947; float swhy = 0.320;
float swix = -0.733; float swiy = 0.507;
float swjx = -0.613; float swjy = 0.680;
float swkx = -0.667; float swky = 0.720;
float swlx = -0.787; float swly = 0.547;
float swmx = -0.987; float swmy = 0.347;
float swnx = -0.707; float swny = 0.760;
float swox = -0.773; float swoy = 0.800;
float swpx = -1.053; float swpy = 0.387;
float seax = 0.747; float seay = 0.200;
float sebx = 0.813; float seby = 0.253;
float secx = 0.693; float secy = 0.427;
float sedx = 0.627; float sedy = 0.387;
float seex = 0.853; float seey = 0.280;
float sefx = 0.920; float sefy = 0.320;
float segx = 0.800; float segy = 0.507;
float sehx = 0.733; float sehy = 0.453;
float seix = 0.960; float seiy = 0.347;
float sejx = 1.036; float sejy = 0.387;
float sekx = 0.893; float seky = 0.573;
float selx = 0.840; float sely = 0.520;
float semx = 0.600; float semy = 0.427;
float senx = 0.667; float seny = 0.467;
float seox = 0.547; float seoy = 0.653;
float sepx = 0.480; float sepy = 0.613;
float seqx = 0.707; float seqy = 0.493;
float serx = 0.773; float sery = 0.547;
float sesx = 0.640; float sesy = 0.733;
float setx = 0.547; float sety = 0.680;
float seux = 0.813; float seuy = 0.573;
float sevx = 0.880; float sevy = 0.613;
float sewx = 0.747; float sewy = 0.800;
float sexx = 0.693; float sexy = 0.747;
PPMDraw flag = PPMDraw(width, height);
flag.fill(0, 0, 0);
// draw white circle in middle
flag.set_color(255, 255, 255);
flag.draw_fill_circle(xc, yc, scale/2);
// draw red and blue portions of circle
flag.set_color(255, 0, 0);
flag.draw_fill_circle(xc - .21*scale, yc - .14*scale, scale/3.9);
flag.set_color(0, 0, 255);
flag.draw_fill_circle(xc + .21*scale, yc + .14*scale, scale/3.9);
flag.set_color(255, 0, 0);
flag.recursive_fill(xc + .21*scale, yc - .21*scale);
flag.set_color(0, 0, 255);
flag.recursive_fill(xc - .21*scale, yc + .21*scale);
// draw the northwest bars
flag.set_color(255, 255, 255);
flag.draw_line(xc + nwax*scale, yc + nway*scale, xc + nwbx*scale, yc + nwby*scale);
flag.draw_line(xc + nwax*scale, yc + nway*scale, xc + nwdx*scale, yc + nwdy*scale);
flag.draw_line(xc + nwbx*scale, yc + nwby*scale, xc + nwcx*scale, yc + nwcy*scale);
flag.draw_line(xc + nwcx*scale, yc + nwcy*scale, xc + nwdx*scale, yc + nwdy*scale);
flag.draw_line(xc + nwex*scale, yc + nwey*scale, xc + nwfx*scale, yc + nwfy*scale);
flag.draw_line(xc + nwex*scale, yc + nwey*scale, xc + nwhx*scale, yc + nwhy*scale);
flag.draw_line(xc + nwfx*scale, yc + nwfy*scale, xc + nwgx*scale, yc + nwgy*scale);
flag.draw_line(xc + nwhx*scale, yc + nwhy*scale, xc + nwgx*scale, yc + nwgy*scale);
flag.draw_line(xc + nwix*scale, yc + nwiy*scale, xc + nwjx*scale, yc + nwjy*scale);
flag.draw_line(xc + nwix*scale, yc + nwiy*scale, xc + nwlx*scale, yc + nwly*scale);
flag.draw_line(xc + nwjx*scale, yc + nwjy*scale, xc + nwkx*scale, yc + nwky*scale);
flag.draw_line(xc + nwlx*scale, yc + nwly*scale, xc + nwkx*scale, yc + nwky*scale);
//NE
flag.draw_line(xc + neax*scale, yc + neay*scale, xc + nebx*scale, yc + neby*scale);
flag.draw_line(xc + neax*scale, yc + neay*scale, xc + nedx*scale, yc + nedy*scale);
flag.draw_line(xc + nebx*scale, yc + neby*scale, xc + necx*scale, yc + necy*scale);
flag.draw_line(xc + necx*scale, yc + necy*scale, xc + nedx*scale, yc + nedy*scale);
flag.draw_line(xc + neex*scale, yc + neey*scale, xc + nefx*scale, yc + nefy*scale);
flag.draw_line(xc + neex*scale, yc + neey*scale, xc + nehx*scale, yc + nehy*scale);
flag.draw_line(xc + nefx*scale, yc + nefy*scale, xc + negx*scale, yc + negy*scale);
flag.draw_line(xc + nehx*scale, yc + nehy*scale, xc + negx*scale, yc + negy*scale);
flag.draw_line(xc + neix*scale, yc + neiy*scale, xc + nejx*scale, yc + nejy*scale);
flag.draw_line(xc + neix*scale, yc + neiy*scale, xc + nelx*scale, yc + nely*scale);
flag.draw_line(xc + nejx*scale, yc + nejy*scale, xc + nekx*scale, yc + neky*scale);
flag.draw_line(xc + nelx*scale, yc + nely*scale, xc + nekx*scale, yc + neky*scale);
flag.draw_line(xc + nemx*scale, yc + nemy*scale, xc + nenx*scale, yc + neny*scale);
flag.draw_line(xc + nemx*scale, yc + nemy*scale, xc + nepx*scale, yc + nepy*scale);
flag.draw_line(xc + nepx*scale, yc + nepy*scale, xc + neox*scale, yc + neoy*scale);
flag.draw_line(xc + nenx*scale, yc + neny*scale, xc + neox*scale, yc + neoy*scale);
flag.draw_line(xc + neqx*scale, yc + neqy*scale, xc + nerx*scale, yc + nery*scale);
flag.draw_line(xc + neqx*scale, yc + neqy*scale, xc + netx*scale, yc + nety*scale);
flag.draw_line(xc + nerx*scale, yc + nery*scale, xc + nesx*scale, yc + nesy*scale);
flag.draw_line(xc + netx*scale, yc + nety*scale, xc + nesx*scale, yc + nesy*scale);
//sw
flag.draw_line(xc + swax*scale, yc + sway*scale, xc + swbx*scale, yc + swby*scale);
flag.draw_line(xc + swax*scale, yc + sway*scale, xc + swdx*scale, yc + swdy*scale);
flag.draw_line(xc + swbx*scale, yc + swby*scale, xc + swcx*scale, yc + swcy*scale);
flag.draw_line(xc + swcx*scale, yc + swcy*scale, xc + swdx*scale, yc + swdy*scale);
flag.draw_line(xc + swex*scale, yc + swey*scale, xc + swfx*scale, yc + swfy*scale);
flag.draw_line(xc + swex*scale, yc + swey*scale, xc + swhx*scale, yc + swhy*scale);
flag.draw_line(xc + swfx*scale, yc + swfy*scale, xc + swgx*scale, yc + swgy*scale);
flag.draw_line(xc + swhx*scale, yc + swhy*scale, xc + swgx*scale, yc + swgy*scale);
flag.draw_line(xc + swix*scale, yc + swiy*scale, xc + swjx*scale, yc + swjy*scale);
flag.draw_line(xc + swix*scale, yc + swiy*scale, xc + swlx*scale, yc + swly*scale);
flag.draw_line(xc + swjx*scale, yc + swjy*scale, xc + swkx*scale, yc + swky*scale);
flag.draw_line(xc + swlx*scale, yc + swly*scale, xc + swkx*scale, yc + swky*scale);
flag.draw_line(xc + swmx*scale, yc + swmy*scale, xc + swnx*scale, yc + swny*scale);
flag.draw_line(xc + swmx*scale, yc + swmy*scale, xc + swpx*scale, yc + swpy*scale);
flag.draw_line(xc + swpx*scale, yc + swpy*scale, xc + swox*scale, yc + swoy*scale);
flag.draw_line(xc + swnx*scale, yc + swny*scale, xc + swox*scale, yc + swoy*scale);
//se
flag.draw_line(xc + seax*scale, yc + seay*scale, xc + sebx*scale, yc + seby*scale);
flag.draw_line(xc + seax*scale, yc + seay*scale, xc + sedx*scale, yc + sedy*scale);
flag.draw_line(xc + sebx*scale, yc + seby*scale, xc + secx*scale, yc + secy*scale);
flag.draw_line(xc + secx*scale, yc + secy*scale, xc + sedx*scale, yc + sedy*scale);
flag.draw_line(xc + seex*scale, yc + seey*scale, xc + sefx*scale, yc + sefy*scale);
flag.draw_line(xc + seex*scale, yc + seey*scale, xc + sehx*scale, yc + sehy*scale);
flag.draw_line(xc + sefx*scale, yc + sefy*scale, xc + segx*scale, yc + segy*scale);
flag.draw_line(xc + sehx*scale, yc + sehy*scale, xc + segx*scale, yc + segy*scale);
flag.draw_line(xc + seix*scale, yc + seiy*scale, xc + sejx*scale, yc + sejy*scale);
flag.draw_line(xc + seix*scale, yc + seiy*scale, xc + selx*scale, yc + sely*scale);
flag.draw_line(xc + sejx*scale, yc + sejy*scale, xc + sekx*scale, yc + seky*scale);
flag.draw_line(xc + selx*scale, yc + sely*scale, xc + sekx*scale, yc + seky*scale);
flag.draw_line(xc + semx*scale, yc + semy*scale, xc + senx*scale, yc + seny*scale);
flag.draw_line(xc + semx*scale, yc + semy*scale, xc + sepx*scale, yc + sepy*scale);
flag.draw_line(xc + sepx*scale, yc + sepy*scale, xc + seox*scale, yc + seoy*scale);
flag.draw_line(xc + senx*scale, yc + seny*scale, xc + seox*scale, yc + seoy*scale);
flag.draw_line(xc + seqx*scale, yc + seqy*scale, xc + serx*scale, yc + sery*scale);
flag.draw_line(xc + seqx*scale, yc + seqy*scale, xc + setx*scale, yc + sety*scale);
flag.draw_line(xc + serx*scale, yc + sery*scale, xc + sesx*scale, yc + sesy*scale);
flag.draw_line(xc + setx*scale, yc + sety*scale, xc + sesx*scale, yc + sesy*scale);
flag.draw_line(xc + seux*scale, yc + seuy*scale, xc + sevx*scale, yc + sevy*scale);
flag.draw_line(xc + seux*scale, yc + seuy*scale, xc + sexx*scale, yc + sexy*scale);
flag.draw_line(xc + sevx*scale, yc + sevy*scale, xc + sewx*scale, yc + sewy*scale);
flag.draw_line(xc + sexx*scale, yc + sexy*scale, xc + sewx*scale, yc + sewy*scale);
// fill in the black to white
flag.draw_line(xc, yc - scale/2, xc, 0);
flag.draw_line(xc, yc + scale/2, xc, height);
flag.draw_line(xc - scale/2, yc, 0, yc);
flag.draw_line(xc + scale/2, yc, width, yc);
flag.recursive_fill(0, 0);
flag.recursive_fill(0, height-1);
flag.recursive_fill(width - 1, 0);
flag.recursive_fill(width - 1, height - 1);
flag.save("flag.ppm");
}