Created
February 13, 2026 10:04
-
-
Save santhoshtr/ca3d47f8b4105eedeea0f17419b48076 to your computer and use it in GitHub Desktop.
korean_flag #metapost-sandbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| beginfig(1); | |
| u := 1mm; | |
| radius := 50u; % 태극의 반지름 (R) | |
| diameter := 2radius; % 태극의 지름 (D = 100u) | |
| height := 200u; | |
| width := 300u; | |
| pair O; O := (width/2, height/2); % 국기 중심 | |
| % 1. 표준 비율 설정 (대한민국 국기법 규정) | |
| numeric bw, bh, bg, kg, bfh; | |
| bw := diameter / 3; % 괘의 너비 | |
| bh := diameter / 12; % 효의 두께 | |
| bg := diameter / 24; % 효 사이의 간격 및 끊어진 틈새 | |
| bfh := 3*bh + 2*bg; % 괘의 전체 높이 (D/2) | |
| kg := diameter / 4; % 태극과 괘 사이의 이격 거리 | |
| % 대각선 각도 (3:2 비율) | |
| numeric ang; ang := angle(3, 2); | |
| % 2. 태극 배경 및 문양 | |
| fill (0,0)--(width,0)--(width,height)--(0,height)--cycle withcolor white; | |
| % 태극 중심점 계산 (대각선 방향 정렬) | |
| pair redO, blueO; | |
| redO := O + (radius/2) * dir(180-ang); | |
| blueO := O + (radius/2) * dir(-ang); | |
| % 큰 반원 (대각선 기준으로 회전하여 자름) | |
| fill subpath (4,8) of fullcircle -- cycle rotated (180-ang) scaled diameter shifted O withcolor (0.8, 0, 0); % 규정 홍색 가깝게 | |
| fill subpath (0,4) of fullcircle -- cycle rotated (180-ang) scaled diameter shifted O withcolor (0, 0, 0.6); % 규정 청색 가깝게 | |
| % 작은 원으로 곡선 완성 | |
| fill fullcircle scaled radius shifted redO withcolor (0.8, 0, 0); | |
| fill fullcircle scaled radius shifted blueO withcolor (0, 0, 0.6); | |
| % 3. 괘 생성 함수 | |
| def draw_kwae(expr sa, sb, sc, angle_deg) = | |
| save s, i, cur_p, bar_w; | |
| numeric s[]; numeric i, bar_w; pair cur_p; | |
| s[0]:=sa; s[1]:=sb; s[2]:=sc; | |
| % 괘의 중심 거리: 반지름 + 이격거리 + 괘높이절반 | |
| numeric d_center; d_center := radius + kg + (bfh/2); | |
| pair kwae_center; kwae_center := O + d_center * dir(angle_deg); | |
| for i=0 upto 2: | |
| % i=0이 태극쪽, i=2가 바깥쪽 | |
| cur_p := kwae_center + ( (i-1)*(bh+bg) ) * dir(angle_deg); | |
| if s[i] = 1: % 이효 (Broken) | |
| bar_w := (bw - bg) / 2; | |
| fill (unitsquare xscaled bar_w yscaled bh shifted (-bw/2, -bh/2)) | |
| rotated (angle_deg-90) shifted cur_p withcolor black; | |
| fill (unitsquare xscaled bar_w yscaled bh shifted (bg/2, -bh/2)) | |
| rotated (angle_deg-90) shifted cur_p withcolor black; | |
| else: % 일효 (Solid) | |
| fill (unitsquare xscaled bw yscaled bh shifted (-bw/2, -bh/2)) | |
| rotated (angle_deg-90) shifted cur_p withcolor black; | |
| fi | |
| endfor | |
| enddef; | |
| % 4. 괘 배치 | |
| draw_kwae(0, 0, 0, 180-ang); % 건 (좌상) | |
| draw_kwae(1, 1, 1, -ang); % 곤 (우하) | |
| draw_kwae(1, 0, 1, ang); % 감 (우상) | |
| draw_kwae(0, 1, 0, 180+ang); % 리 (좌하) | |
| % 5. 검증용 가이드라인 (확인 후 삭제 가능) | |
| %draw (0,0)--(width,height) withcolor 0.7white dashed evenly; | |
| draw (0,height)--(width,0) withcolor 0.7white dashed evenly; | |
| %draw fullcircle scaled (diameter + 2kg) shifted O withcolor blue dashed evenly; | |
| % 작은 원 중심점 가이드 (까만 점) | |
| pickup pencircle scaled 3pt; | |
| draw redO withcolor black; | |
| draw blueO withcolor black; | |
| endfig; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment