本文整理匯總了Python中FlagPainter.FlagPainter.draw_polygon方法的典型用法代碼示例。如果您正苦於以下問題:Python FlagPainter.draw_polygon方法的具體用法?Python FlagPainter.draw_polygon怎麽用?Python FlagPainter.draw_polygon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FlagPainter.FlagPainter
的用法示例。
在下文中一共展示了FlagPainter.draw_polygon方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: paint_flag_czech_republic
# 需要導入模塊: from FlagPainter import FlagPainter [as 別名]
# 或者: from FlagPainter.FlagPainter import draw_polygon [as 別名]
def paint_flag_czech_republic():
f = FlagPainter(2 / 3)
colors = [(255, 255, 255), (224, 0, 54)]
blue = (23, 77, 148)
ratios = [1, 1]
f.stripes(colors, ratios, StripeDirection.horizontal)
points = [(0, 0), (1 / 2, 1 / 2), (0, 1)]
f.draw_polygon(points, blue)
f.save('czech_republic')
示例2: paint_flag_bosnia_herzegovina
# 需要導入模塊: from FlagPainter import FlagPainter [as 別名]
# 或者: from FlagPainter.FlagPainter import draw_polygon [as 別名]
def paint_flag_bosnia_herzegovina():
"""http://www.vexilla-mundi.com/bosnia_and_herzegovina_flag.html"""
f = FlagPainter(1 / 2)
background_color = (14, 19, 150)
triangle_color = (251, 207, 0)
star_color = (255, 255, 255)
f.background(background_color)
points = [(106 / 400, 0), (306 / 400, 0), (306 / 400, 1)]
f.draw_polygon(points, triangle_color)
x_start = 60 / 400
x_end = 260 / 400
y_start = -5 / 200
y_end = 195 / 200
nr_stars = 9
for i in range(nr_stars):
X = x_start + (i / (nr_stars - 1)) * (x_end - x_start)
Y = y_start + (i / (nr_stars - 1)) * (y_end - y_start)
f.draw_star(center=(X, Y), radius_inner=7 / 400, radius_outer=19 / 400,
nr_points=5, starting_alpha=-math.pi / 2, color=star_color)
f.save('bosnia_herzegovina')
示例3: paint_flag_united_kingdom
# 需要導入模塊: from FlagPainter import FlagPainter [as 別名]
# 或者: from FlagPainter.FlagPainter import draw_polygon [as 別名]
def paint_flag_united_kingdom():
"""http://www.vexilla-mundi.com/united_kingdom_flag.html"""
f = FlagPainter(1 / 2)
colors = [(0, 36, 125), (207, 20, 43), (255, 255, 255)]
# Background color
f.background(colors[0])
# White diagonal stripes
X = (1 / math.cos(math.pi / 3)) / 60
Y = (1 / math.cos(math.pi / 6)) / 30
points = [(0, 0), (0, 3 * Y), (1 - 3 * X, 1), (1, 1), (1, 1 - 3 * Y), (3 * X, 0)]
f.draw_polygon(points, colors[2])
points = [(1, 0), (1 - 3 * X, 0), (0, 1 - 3 * Y), (0, 1), (3 * X, 1), (1, 3 * Y)]
f.draw_polygon(points, colors[2])
# Red diagonal stripes
points = [(0, 0), (0, 2 * Y), ((20 / 60) - 2 * X, 10 / 30), (20 / 60, 10 / 30)]
f.draw_polygon(points, colors[1])
points = [(1, 0), (1 - 2 * X, 0), (1 - (20 / 60) - 2 * X, 10 / 30), (1 - (20 / 60), 10 / 30)]
f.draw_polygon(points, colors[1])
points = [(1, 1), (1, 1 - 2 * Y), (1 - (20 / 60) + 2 * X, 1 - (10 / 30)),
(1 - (20 / 60), 1 - (10 / 30))]
f.draw_polygon(points, colors[1])
points = [(0, 1), (2 * X, 1), (20 / 60 + 2 * X, 1 - (10 / 30)), (20 / 60, 1 - (10 / 30))]
f.draw_polygon(points, colors[1])
# Horizontal and vertical stripes
f.draw_horizontal_band((10 / 30, 20 / 30), colors[2])
f.draw_vertical_band((25 / 60, 35 / 60), colors[2])
f.draw_horizontal_band((12 / 30, 18 / 30), colors[1])
f.draw_vertical_band((27 / 60, 33 / 60), colors[1])
f.save('united_kingdom')
示例4: paint_flag_macedonia
# 需要導入模塊: from FlagPainter import FlagPainter [as 別名]
# 或者: from FlagPainter.FlagPainter import draw_polygon [as 別名]
def paint_flag_macedonia():
"""
http://www.vexilla-mundi.com/macedonia_flag.html
https://en.wikipedia.org/wiki/Flag_of_the_Republic_of_Macedonia#Design
"""
f = FlagPainter(1 / 2)
colors = [(190, 0, 36), (254, 203, 15)]
f.background(colors[0])
f.draw_polygon(points=[(0, 0), (42 / 280, 0), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(1, 0), (1 - 42 / 280, 0), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(0, 1), (42 / 280, 1), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(1, 1), (1 - 42 / 280, 1), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(126 / 280, 0), (1 - 126 / 280, 0), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(126 / 280, 1), (1 - 126 / 280, 1), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(0, 56 / 140), (0, 1 - 56 / 140), (1 / 2, 1 / 2)], color=colors[1])
f.draw_polygon(points=[(1, 56 / 140), (1, 1 - 56 / 140), (1 / 2, 1 / 2)], color=colors[1])
f.draw_circle(center=(1 / 2, 1 / 2), radius=25 / 280, color=colors[0])
f.draw_circle(center=(1 / 2, 1 / 2), radius=20 / 280, color=colors[1])
f.save('macedonia')