from turtle import * 건 = [True, True, True] 곤 = [False, False, False] 리 = [True, False, True] 감 = [False, True, False] def draw_trigram(pattern, width): """Draws a trigram from the Korean flag. The starting and ending point is the center of the bottom of the trigram, with the turtle facing up. The pattern should be a list of True/False values, indicating whether each bar should be solid, starting from the top. """ unit = width/12 for bar_type in pattern: draw_trigram_bar(bar_type, width) fly(unit * 3) fly(unit*-9) def draw_trigram_bar(is_solid, width): """Draws a single bar from a trigram, starting and ending at the center of the bottom of the bar. """ unit = width/12 right(90) fly(unit*-6) if is_solid: draw_black_rectangle(unit*12, unit*2) fly(width/2) else: draw_black_rectangle(unit*5.5, unit*2) fly(unit*6.5) draw_black_rectangle(unit*5.5, unit*2) fly(unit*-0.5) left(90) def draw_black_rectangle(width, height): """Draws a filled black rectangle, starting and ending at the bottom left corner and turning to the left. """ color('black') fillcolor('black') begin_fill() for half in range(2): forward(width) left(90) forward(height) left(90) end_fill() def fly(steps): "Move without drawing" penup() forward(steps) pendown()