Gambar bendera Korea Selatan


58

Ketika saya menemukan pertanyaan ini, saya ingat bahwa saya juga pernah melihat aturan yang tepat untuk pembuatan bendera Korea Selatan. Dan ini konstruksi yang sangat berbeda.

masukkan deskripsi gambar di sini

Sumber: Wikipedia

Jadi, Anda harus menggambar konstruksi yang tepat sekarang!

Spesifikasi

Anda dapat membuat bendera ke file atau layar menggunakan vektor atau grafik raster. Jika output Anda dirasterisasi, gambar Anda harus memiliki dimensi 450x300 piksel atau lebih.

Semua rasio panjang dan posisi harus persis seperti yang ditunjukkan pada diagram berikut:

masukkan deskripsi gambar di sini

Sumber: Wikipedia

Perhatikan bahwa pusat dari dua lingkaran kecil sejajar dengan diagonal.

Untuk warna, Anda harus menggunakan palet berikut:

  • Putih: #FFFFFF
  • Hitam: # 000000
  • Merah: # C60C30
  • Biru: # 003478

Batas hitam tidak boleh ditarik kecuali sistem gambar Anda tidak membiarkan Anda menentukan kanvas 3: 2 karena alasan teknis (jika tidak, Anda harus menggunakan kanvas 3: 2 dan bendera harus mengisi semua itu). Jika Anda perlu menambahkan batas, batasnya mungkin tebal - bendera harus dipertimbangkan secara ketat di dalam batas hitam. Garis bantu atau indikator panjang lainnya tidak boleh ditarik. Yaitu, bendera akan muncul persis seperti pada gambar pertama.

Mencetak gol

Ini kode golf, jadi jawaban tersingkat (dalam byte) menang.

Sebagai kata peringatan, menggunakan kompresi yang ada (seperti menanamkan GIF terkompresi) jatuh ke beberapa celah standar .


2
Menariknya, bendera Korea berisi bentuk awal sistem bilangan biner ( britton.disted.camosun.bc.ca/jbbinflag.htm )
britishtea

Apakah kita harus menggambar perbatasan ketika kita menggunakan halaman HTML yang lebih besar dari bendera, karena putih tidak ada pemisahan yang terlihat bahkan jika ukuran kanvas / elemen mirip dengan bendera
Pengoptimal

@Optimizer, tidak, jika kanvas dibatasi dengan cara yang entah bagaimana dapat dibuat terlihat (misalnya dengan menyorot "elemen inspeksi" browser), maka Anda tidak perlu batas. Perbatasan hitam hanya boleh digambar dalam kasus langka di mana luas kanvas tidak dapat didefinisikan secara teknis.
Martin Ender

3
Saya berasumsi CountryData["ROK","Flag"]tidak masuk hitungan?
wchargin

Jawaban:


13

PHP / HTML / SVG, 324

(jeda baris ditambahkan untuk keterbacaan)

<?=gzinflate(base64_decode('tVHBioMwFPyVwF5WSOzLi/tswQjdu9cevIk1KqtriaFd9utrgpSWFva0PPImMwzDkGTz
uWXnvrl8Tj8aOPAUebLNs5Y5W33PZrKjtpOrXPOuVEy7KMiD54mKMY3yrO5tPTTMaonM9MOg32qCWgHb5Nmpch076kIih/2y
PC4jRRCIU6BhbkwGV7lmAagk3d5nCfwQdKByVBwOFLagQu6exZLNzk5fjU+B9S4u/dF1Gh/apRw6Cb83uzHm0S69/cWbSIkx
YfSf5QT6dkk5UoACIeAfXTftepb/za8='));

Data terkompresi meluas ke data SVG yang sama dengan jawaban saya sebelumnya yang ditunjukkan di bawah ini, tetapi dengan dua perubahan untuk membantu kompresi:

  1. Dua <use>bagian diperluas ke konten asli <defs>bagian tersebut. Ini membuat teks sumber lebih panjang, tetapi mengurangi entropi sehingga kompres lebih baik.

  2. Pada <g>elemen pertama , saya berubah transform=translate(36,24)rotate(33.69)menjadi transform=rotate(33.69)translate(43.27). Ini memiliki efek yang sama secara geometris, tetapi kompres lebih baik karena urutannya ><g transform=rotate(sekarang muncul dua kali.

Secara default, PHP akan melayani ini sebagai Content-Type: text/html, jadi sintaks XML yang tidak valid seharusnya tidak menjadi masalah.

SVG / HTML, 463

Pengurai HTML tidak terlalu sibuk tentang sintaks yang benar, jadi kita dapat menghapus tanda kutip dalam parameter selama tidak mengandung spasi. Seharusnya dimungkinkan untuk menekan ini lebih jauh dengan sedikit Javascript.

<svg viewBox=0,0,72,48><defs><path d=M-25-6V6Zm3,0V6m3,0V-6M19-6V6Zm3,0V6m3,0V-6Z stroke=#000
stroke-width=2 id=p /></defs><g transform=translate(36,24)rotate(33.69)><circle r=12 fill=#c60c30
/><path d=M12,0A12,12,0,0,1-12,0A6,6,0,0,0,0,0A6,6,0,0,1,12,0Z fill=#003478 /><use xlink:href=#p
/><path d=M17,0h10z stroke=#fff stroke-width=1 /><g transform=rotate(112.62)><use xlink:href=#p
/><path d=M-27,0h4Zm6,0h4ZM20,0h4Z stroke=#fff stroke-width=1 /></g></g></svg>


44

Python + Pycairo, 371 370 366 byte

Bendera

from cairo import*
p=3.141593
c=Context(SVGSurface("F",12,8))
C=c.set_source_rgb;R=c.rectangle;T=c.rotate;F=c.fill
C(1,1,1);R(0,0,12,8);F()
c.translate(6,4);T(.588);b=3188
for o in[(0,.2,.47),(.77,.05,.19)]*2:C(*o);i=b/2%2;b+=1;c.arc(i,0,2-i,0,p+i*p);F();T(p)
C(0,0,0)
for x in(p,1.966)*2:
 for y in.5,0,1:
    for z in-1,1:R(3+y,-z,1./3,z*(2.75+b%2)/3);F()
    b/=2
 T(x)

Mengeluarkan file SVG kecil bernama F.


C(*[.77,0,.05,.2,.19,.47][i::2])lebih pendek dariC(*[(.77,.05,.19),(0,.2,.47)][i%2])
isaacg

Mengapa Anda menulis, s=SVGSurface("F",12,8);c=Context(s)bukan hanya c=Context(SVGSurface("F",12,8))?
Lily Chung

@IstvanChung Poin bagus.
Ell

32

HTML + CSS, 966 906 843 792 762 byte

Bukan pemenang kapan saja, tetapi banyak kesenangan menggambar di CSS. Ini bisa bermain golf banyak.

CSS, HTML :

*{position:fixed}a{background:linear-gradient(0deg,#003478 50%,#C60C30 50%);width:2in;height:2in;transform:rotate(.6rad);top:1in;left:2in}d,e{width:50%;height:50%;background:#C60C30;left:0;top:25%}a,d,e{border-radius:50%}d{background:#003478;left:50%}b,i{width:1in;height:26em;top:-1em;left:15em;transform:rotate(.98rad)}g,f,k,j{width:1in;height:17%;background:repeating-linear-gradient(0deg,#000,#000 1em,#fff 1em,#fff 1.5em);bottom:0;left:0}g,j,p{top:-.5em}b{transform:rotate(-.98rad)}c,p,v,x{height:2em;width:.5em;background:#fff;transform:rotate(.98rad)}p{top:2.8in;left:28em;transform:rotate(-.98rad) scale(1,4)}x{top:3.9em;left:28.4em}c,v{top:23.8em;transform:none}c{top:3.5em}body{height:4in;width:6in;border:1px solid
<a><d><e></a><b><f><g></b><i><j><k></i><p></p><x><v><c

;border:1px solidhanya untuk ditampilkan karena <body>tag memiliki batas yang jelas yang dapat diamati oleh Inspektur atau alat serupa, sebagaimana dinyatakan oleh OP

CATATAN Hanya berfungsi di Firefox (atau Chrome canary / dev) karena penggunaan transformasi dan gradien khusus non-vendor.

Lihat itu dalam aksi


Saya pikir Anda harus memasukkan tag <link> atau <style> dalam jumlah karakter Anda. Anda dapat menyimpan beberapa karakter: di CSS 0deg-> 0(dua kali) dan menghapus left:0dari a:before. Dalam HTML Anda bisa menggunakan <p><ul></ul>. ( <p>akan ditutup secara implisit sebelumnya <ul>)
gronostaj

1
Bekerja di Firefox 32. Gagal dengan spektakuler di Safari 7.1.
200_sukses

1
Gunakan KURANG atau SASS untuk CSS yang seharusnya memberi Anda cukup banyak pilihan untuk mempersingkatnya. Selain itu :before{content:''}dan :after{content:''}lebih lama dari sekedar menambahkan elemen lain (meskipun ini memang terlihat lebih baik).
David Mulder

@ Davidvidul Saya ingin faktor yang menyenangkan dalam kode ini daripada lebih pendek. Orang dapat berhubungan dengan CSS murni lebih mudah daripada KURANG atau SASS :)
Pengoptimal

Bekerja di Chrome terbaru juga. @ 200_success Anda harus bisa membuatnya bekerja di Safari dengan menambahkan -webkit-sebelum semua transform:, namun perlu untuk mengatakan bahwa akan membuatnya sedikit lebih lama!
Gagang Pintu

20

BBC Basic, 349 343 karakter ASCII, ukuran file 330

Unduh emulator di http://www.bbcbasic.co.uk/bbcwin/bbcwin.html

  p=1049q=25r=100VDU4118;275;-1,49,3076;19,7,-1;-1;531;255;7693;q;40;0;q,97,1200;800;29,640;400;
  FORa=38TO56STEP0.01x=r*COS(a)y=r*SIN(a)b=a*7DIV44/2IFb=3.5z=y<0ELSEz=x>0
  VDU18;1,p;-x;-y;q,153,r;0;18;2,p;x;y;q,153,r;0;18;0
  IFABS(y)DIV1=56VDUp;x*b+y;y*b-x;q;x/3;y/3;q,113,-2*y;2*x;18;7:b-=0.1VDUp;x*b+y/12;y*b-x/12;q;x/2;y/2;q,112-z,-y/6;x/6;
  NEXT

Menggunakan warna yang benar menambahkan banyak, tetapi mem-golf semua perintah grafis ke kode VDU mentah memberikan penghematan 6 karakter secara keseluruhan dibandingkan dengan posting asli saya. Semua grafik pada BBC mikro dilakukan melalui kode kontrol ASCII khusus mesin, jadi alih-alih menggunakan perintah grafis tingkat tinggi, Anda dapat mengumpan byte langsung ke pengontrol VDU (umumnya lebih pendek tetapi dengan biaya yang besar agar mudah dibaca). Nilai yang diakhiri dengan titik koma alih-alih koma adalah representasi little-endian 16-bit 2 byte.

Versi tidak disatukan

  MODE16
  VDU19,1,-1,49,4,12                :REM adjust shade of red 
  VDU19,7,-1,-1,-1,-1               :REM adjust shade of white to full brightness (63 is 2's complement representation of -1
  VDU19,4,-1,0,13,30                :REM adjust shade of blue
  RECTANGLEFILL40,0,1200,800        :REM plot background rectangle
  ORIGIN640,400
  FORa=38TO56STEP0.01
    x=COS(a)*100
    y=SIN(a)*100
    GCOL1:CIRCLEFILL-x,-y,100       :REM red
    GCOL4:CIRCLEFILLx,y,100         :REM blue
    GCOL0                           :REM black
    b=a*7DIV44/2                    :REM divide a by 2*(22/7) to get integer representation, then divide by 2 again.
    IFb=3.5THENz=y<0ELSEz=x>0       :REM decide whether to cut bar
    REM If the angle is correct (100*sin(a) = 56) draw bar. If required, cut out the middle of the bar.
    IFABS(INT(y))=56 MOVEx*b+y,y*b-x:MOVEBY x/3,y/3:PLOT113,-2*y,2*x:GCOL7:b-=0.1:MOVEx*b+y/12,y*b-x/12:MOVEBY x/2,y/2:IFz PLOT113,-y/6,x/6
  NEXT

Di awal program saya memindahkan asal ke tengah layar.

Saya tidak menggambar setengah lingkaran berwarna besar. Alih-alih, saya menjalankan lingkaran yang menarik lingkaran merah dan biru kecil, berputar ke arah yang berlawanan arah jarum jam. Saya melakukan hampir 3 revolusi lengkap (dimulai dengan biru di sebelah kanan) yang jelas lebih dari cukup untuk mengisi disk. Saya berhenti pada revolusi ke-3, tepat ketika biru di kanan bawah berada di posisi yang benar untuk sejajar dengan jeruji (yang harus diplot.)

Ketika sudutnya benar, saya menggambar salah satu palang. vektor x, y untuk menggambar lingkaran biru kecil saat ini berfungsi untuk menentukan ke arah mana bar seharusnya berada. Untuk masing-masing dari 3 putaran, nilai bilangan bulat a*7DIV44yang berbeda dihitung, yang menunjukkan apakah bilah pertama, kedua atau ketiga harus ditarik, dengan tepi bagian dalam 6 / 8,7 / 8 atau 8/8 unit dari pusat ( sesuai dengan unit yang digunakan dalam spec spec.) Karena unit program adalah 1/4 dari yang ada dalam spec, ini masih setengah unit, jadi kami membagi 2 lagi sebelum menyimpan ke variabel ´b 'untuk menghindari separuh berulang kemudian.

Bilah ditarik padat, maka bagian tengah dihapus jika perlu. Ini mencegah kinks bergabung setengah bar. Variabel z menunjukkan apakah bar harus dipotong. Yaitu, ketika y negatif untuk bar tengah dan ketika x positif untuk bar lainnya.

MOVEadalah langkah mutlak. MOVEBYadalah langkah relatif. PLOT133menganggap dua posisi kursor grafik terakhir, ditambah yang baru ditentukan (dalam koordinat relatif) sebagai tiga sudut jajaran genjang, dan plot jajaran genjang itu.

Output (& diskusi keterbatasan bahasa)

Saya memilih mode layar 1280x800 piksel logis = 640x400 piksel fisik, yang secara default memiliki latar belakang hitam. Untuk ini saya menggambar persegi panjang putih dari -600, -400 hingga 600.400 untuk bertindak sebagai "kanvas."

BBC Basic dapat menangani 16 warna sekaligus, dari palet yang dapat diprogram ulang. Tapi itu hanya mendukung warna 18-bit, sedangkan pertanyaannya menentukan warna sebagai 24-bit. Warna sedekat mungkin.

masukkan deskripsi gambar di sini


2
Saya telah menulis ulang spesifikasi mengenai batas sedikit. Cara Anda menanganinya cukup banyak seperti yang saya maksudkan.
Martin Ender

16

Penyu Python 3 ( 552 549 bytes)

Bendera

( Gambar ukuran penuh )

Sunting: Sekarang kita memiliki Stack Snippets, inilah tes Stack Snippet menggunakan Skulpt , dengan bantuan jawaban ArtOfCode di sini . Sayangnya, Skulpt belum sepenuhnya mengimplementasikan Python, jadi saya harus memutilasi setengah kode saya agar ini berfungsi. Dengan kata lain, cuplikan ini hanya dimaksudkan untuk menunjukkan cara kerja program saya (tanpa perlu menarik Python).

(Juga, saya menemukan bahwa ini mungkin tidak benar-benar berfungsi pada beberapa browser ...)

function out(a){var b=document.getElementById("output");b.innerHTML+=a}function builtinRead(a){if(void 0===Sk.builtinFiles||void 0===Sk.builtinFiles.files[a])throw"File not found: '"+a+"'";return Sk.builtinFiles.files[a]}
$(document).ready(function run(){Sk.canvas="canvas";Sk.configure({output:out,read:builtinRead});try{Sk.importMainWithBody("<stdin>",!1,'import turtle\nimport math\nt=turtle.Turtle()\nt.speed(9)\nR="#c60c30"\nr=56.3\nk=0.6\ns=60*k\noffsetx,offsety=-215,-145\nt.up()\nt.goto(offsetx,offsety)\nt.down()\ndef q():t.rt(90)\ndef Q():t.lt(90)\ndef K():t.color("black");t.begin_fill();q()\ndef A(g,G):t.fd(g);Q();t.fd(G);Q();t.fd(g);Q();t.fd(G);Q()\ndef E():t.up();t.fd(s);t.down();Q();t.end_fill();t.up();t.fd(30*k);t.down();\ndef i():K();t.up();t.bk(s);t.down();A(120*k,20*k);E()\ndef I():K();t.up();t.fd(5*k);t.down();A(55*k,20*k);t.up();t.bk(65*k);t.down();A(55*k,20*k);E()\ndef C():t.circle(120*k,180)\nA(720*k,480*k)\nt.seth(r)\nt.up()\nt.goto(459.8*k+offsetx,173.4*k+offsety)\nt.down()\nt.color(R)\nt.begin_fill()\nC()\nt.end_fill()\nt.begin_fill()\nt.color("#003478")\nC()\nt.circle(s)\nt.end_fill()\nt.color(R)\nC()\nt.begin_fill()\nt.circle(s)\nt.end_fill()\nq()\nt.up()\nt.fd(s)\nt.down()\ni()\ni()\ni()\nt.up()\nt.bk(530*k)\nt.down()\nI()\nI()\nI()\nt.up()\nt.fd(170*k)\nt.rt(2*r)\nt.fd(180*k)\nt.down()\nI()\ni()\nI()\nt.up()\nt.bk(530*k)\nt.down()\ni()\nI()\ni()\n')}catch(a){throw Error(a.toString());}})
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script><script src="http://www.skulpt.org/static/skulpt.min.js" type="text/javascript"></script><script src="http://www.skulpt.org/static/skulpt-stdlib.js" type="text/javascript"></script>
<canvas height="320" width="480" id="canvas" style="border:1px solid gray">Your browser does not support HTML5 Canvas!</canvas>


Kode aktual:

import turtle as t
b=t.begin_fill
c=t.circle
e=t.end_fill
f=t.fillcolor
R="#c60c30"
r=56.3
F=t.fd
B=t.bk
s=60
def q():t.rt(90)
def Q():t.lt(90)
def K():f(0,0,0);b();q()
def A(g,G):exec("F(g);Q();F(G);Q();"*2)
def E():F(s);Q();e();F(30)
def i():K();B(s);A(120,20);E()
def I():K();F(5);A(55,20);B(65);A(55,20);E()
def C():c(120,180)
A(720,480)
t.seth(r)
t.up()
t.goto(459.8,173.4)
f(R)
b()
C()
e()
b()
f("#003478")
C()
c(s)
e()
C()
f(R)
b()
c(s)
e()
q()
F(s)
i()
i()
i()
B(530)
I()
I()
I()
F(170)
t.rt(2*r)
F(180)
I()
i()
I()
B(530)
i()
I()
i()
t.ht()

Karena kura-kura itu lamban, jika Anda ingin hasil instan, Anda dapat menambahkan t.tracer(0)setelah baris pertama sebelum Anda menjalankan skrip.

Catatan: Entah mengapa kura-kura terus menggambar apa yang tampak seperti piksel hitam tambahan meskipun saya sudah menelepon up(), dan saya tidak tahu mengapa ...


Saya percaya seseorang menerapkan Python (dengan kura-kura!) Pada posting Stack Snippets; jika Anda ingin mengetahui caranya, Anda bisa menjadi yang pertama menggunakan fitur baru ini! ;)
Gagang Pintu

@ Doorknob saya harus menghancurkan setengah kode saya untuk membuatnya bahkan secara samar melakukan apa yang saya inginkan, tetapi setidaknya secara visual melakukan hal yang sama seperti di Python sekarang. (Tapi itu tidak berfungsi pada Chrome saya karena beberapa alasan ...)
Sp3000

2
Bekerja dengan baik di Chrome iOS. Senang melihat seseorang menemukan kegunaan untuk proyek saya :)
ArtOfCode

14

HTML + ES6, 388

<canvas id=D width=576 height=384><script>c=D.getContext('2d')
T=x=>c.translate(x*72,x*48)
R=(x,y)=>T(4)+c.rotate(x*.59)+T(-4)+eval('for(i=j=0;i*j<6;i+=(j^=1))c.fillRect(72+24*i+(i>2)*288,144+j*52,16,44+52*(y>>i&1-j))')
A=(w,x,y,z)=>(c.fillStyle=c.fill()+c.beginPath()||w)*c.arc(x*4,192-y,48*y,0,3.1,z)||A
R(-1,21)
R(2,7)
A(r='#C60C30',72,2,1)('#003478',72,2)(0,84,1,1)(r,60,1)()</script>

Jika browser Anda mendukung ES6, Anda dapat melihatnya di JSFiddle atau menjalankan cuplikan.

Ini membangun bendera dari beberapa bentuk dasar, memutar kanvas pertama untuk memperhitungkan sudut.


Hanya sebuah catatan bahwa ini tidak berfungsi di Chrome 39, berfungsi dengan baik di FF> 29.
JBCP

<canvas width=576 height=384 id=D><script>c=D.getContext('2d')kurang dari 9 byte. Juga, karena seluruh halaman berwarna putih, saya pikir Anda perlu menggambar perbatasan.
Pengoptimal

@Optimizer Terima kasih. Seperti yang saya pahami, perbatasan hanya diperlukan ketika Anda memiliki kanvas tanpa batas.
grc

5
Anda bisa mencoba ini dengan Stack Snippets!
Beta Decay

@ BetaDecay itu benar-benar berfungsi: o
grc

6

Mathematica 404 450

b=1&~Array~13;a=ReplacePart[b,7-> 0];d=Disk;r=RGBColor;
z@{q_,p_,s_}:=ArrayPlot[{q,q,{},p,p,{},s,s},Frame-> False,ImageSize-> 155];
m=r@@{0,.2,.5};
o=r@@{.8,0,.2};
t=-19.1;u=-12.75;v=-5;q=-3.33;
Graphics[{Line[{{-36,-24},{36,-24},{36,24},{-36,24},{-36,-24}}],
Inset[Rotate[z@#,#2 125 Degree],#3]&@@@{{{b,a,b},1,{t,u}},{{a,b,a},1,{-t,-u}},
{{a,a,a},-1,{-t,u}},{{b,b,b},-1,{t,-u}}},
{o,d[{0,0},12,{-.2 Pi,.8Pi}],m, d[{0,0},12,{.8Pi,1.8Pi}],o,d[{v,-q},6],m,d[{-v,q},6]}}]

bendera


3

C ++ TERLALU BESAR

Mencoba ini menggunakan perpustakaan menggambar PPM buatan saya . Secara teknis skalabel, tetapi saya dibatasi oleh fungsi pengisian rekursif saya karena tidak dapat diandalkan dan suka melakukan segfault, saya pikir itu menggunakan terlalu banyak memori, jadi saya tidak akan benar-benar membiarkan pengguna mengatur skala. Gambar tidak beraturan karena koordinat yang saya masukkan untuk setiap sudut bilah sedikit tidak aktif. masukkan deskripsi gambar di sini

Saya mengaturnya untuk memulai dengan latar belakang hitam, lalu letakkan lingkaran putih di tengah, lalu lingkaran merah dan biru di dalamnya. Isi isian rekursif digunakan untuk menambahkan sisa warna merah dan biru. Kemudian menggambar persegi panjang dengan garis-garis putih untuk menandai batang hitam. Bagi latar belakang hitam menjadi 4 bagian dengan garis putih dan gunakan 4 isian rekursif untuk membuat setiap bagian berwarna putih. Melakukannya dalam 1 pass akan menyebabkan segfault. Masih sangat lambat untuk ditampilkan.

Kode utama tidak digabungkan (bagian perpustakaan terlalu besar, bermain golf ini tidak masalah)

#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");

}

@SohamChowdhury Benar-benar tidak disengaja, SEXY adalah sudut Tenggara, Titik X, koordinat Y.
user137

3
Milik Anda adalah satu-satunya solusi di mana bendera melambai tertiup angin!
CJ Dennis

2

PostScript , 572 477 byte

Kode golf:

5 5 scale 36 24 translate /R{.75 .05 .19 setrgbcolor}def/B{0 .20 .47 setrgbcolor}def/a 2 3 atan def/b{0 setgray[18 -6 2 12 21 -6 2 12 24 -6 2 12]rectfill 1 setgray{[18 -.5 2 1 24 -.5 2 1]rectfill}if{21 -.5 2 1 rectfill}if}def a neg rotate R 0 0 12 0 180 arc closepath fill B 0 0 12 180 0 arc closepath fill R -6 0 6 0 360 arc closepath fill B 6 0 6 0 360 arc closepath fill true true b 2 a mul rotate false true b 180 rotate true false b -2 a mul rotate false false b
showpage

Kode tidak dikunci:

5 5 scale                                     % over-all scale
36 24 translate                               % over-all shift
/R {.75 .05 .19 setrgbcolor} def              % prodecure for setting red color
/B {0 .20 .47 setrgbcolor} def                % procedure for setting blue color
/a 2 3 atan def                               % calculate angle = arctan(2/3) = 33.7°
/b {                                          % procedure for drawing bars
 0 setgray                                    %   black
 [18 -6 2 12 21 -6 2 12 24 -6 2 12] rectfill  %   draw 3 bars
 1 setgray                                    %   white
 {[18 -.5 2 1 24 -.5 2 1] rectfill} if        %   conditionally draw gap in inner/outer bars 
 {21 -.5 2 1 rectfill} if                     %   conditionally draw gap in middle bar 
} def
a neg rotate                                  % rotate -33.7°
R 0 0 12 0 180 arc closepath fill             % big red half circle
B 0 0 12 180 0 arc closepath fill             % big blue half circle
R -6 0 6 0 360 arc closepath fill             % small red circle
B  6 0 6 0 360 arc closepath fill             % small blue circle
true true b                                   % draw bars (with gap in all bars)
2 a mul rotate                                % rotate 67.4°
false true b                                  % draw bars (with gap in inner/outer bars)
180 rotate                                    % rotate 180°
true false b                                  % draw bars (with gap in middle bar)
-2 a mul rotate                               % rotate -67.4°
false false b                                 % draw bars (without gaps)
showpage

Hasil:

hasil


1

Python 2, 483 byte

from math import*
w,k,r,b="255 "*3,"0 "*3,"198 12 48 ","0 52 120 "
print "P3 600 400 255 "
a=atan2(2,3)
c,s=cos(a),sin(a)
T=lambda x,y:(c*x-s*y,s*x+c*y)
S=lambda x,y:150<x<216.6and x%25<16.6and y*y<2500
C=lambda x,y,p=50:(x-p)**2+y*y<2500
for y in range(-200,200):
 for x in range(-300,300):X,Y=T(x,y);W,Z=T(-x,y);print [[w,k][(S(abs(X),Y)and(Y*Y>16or(166.6<X<191.4or-200>X or 0>X>-166.6)))or(S(abs(W),Z)and(W>0 or abs(Z)>4))],[b,r][(Z<0 or C(W,Z))and not C(W,Z,-50)]][W*W+Z*Z<10000]

Kemungkinan peningkatan:

  • hardcode cos, konstanta dosa
  • PPM biner
  • mentransformasikannya menjadi [3,2] bidang
  • mengoptimalkan pernyataan boolean

Output sebagai PPM teks, penggunaan:

python golf_korea.py > korea.ppm

masukkan deskripsi gambar di sini

versi beta tanpa lemak

from math import*
w,k,r,b="255 255 255 ", "0 0 0 ", "255 0 0 ", "0 0 255 "
g="0 255 0 "
print "P3 600 400 255 "
a=atan2(2,3)
c,s=cos(a),sin(a)
trans=lambda x,y:(c*x-s*y,s*x+c*y)
stripe=lambda x:150<x<216.6 and x%25<16.6
small=lambda x,y,p=50:(x-p)**2+y*y<2500
for y in range(-200,200):
 for x in range(-300,300):
  X,Y=trans(x,y)
  W,Z=trans(-x,y)
  if stripe(abs(X)) and Y*Y<2500:
   if abs(Y)>4:  
    print k
   else:
    if X>0:
     if 166.6<X<191.4:
      print k
     else:
      print w
    else:
     if -200<X<-166.6:
      print w
     else:
      print k
  elif stripe(abs(W)) and Z*Z<2500 and(W>0 or abs(Z)>4):
   print k
  elif W*W+Z*Z<100*100:
   if (Z<0 or small(W,Z)) and not small(W,Z,-50):
    print r
   else:
    print b
  else:
   print w
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.