Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import *
- import math
- hexSize = 24
- hexWidth = hexSize * 2
- hexHeight = hexSize * (3 ** 0.5)
- def hex_corner(coord, i, xcoord):
- global hexSize
- angle_deg = 60 * i
- angle_rad = math.pi / 180 * angle_deg
- if xcoord == True:
- return coord + hexSize * math.cos(angle_rad)
- else:
- return coord + hexSize * math.sin(angle_rad)
- # Принимает координаты x и y гекса
- def hex(x, y):
- up()
- goto(x, y)
- fx = hex_corner(x, 0, True)
- fy = hex_corner(y, 0, False)
- goto(fx, fy)
- down()
- sx = hex_corner(x, 1, True)
- sy = hex_corner(y, 1, False)
- goto(sx, sy)
- tx = hex_corner(x, 2, True)
- ty = hex_corner(y, 2, False)
- goto(tx, ty)
- frx = hex_corner(x, 3, True)
- fry = hex_corner(y, 3, False)
- goto(frx, fry)
- fvx = hex_corner(x, 4, True)
- fvy = hex_corner(y, 4, False)
- goto(fvx, fvy)
- sxx = hex_corner(x, 5, True)
- sxy = hex_corner(y, 5, False)
- goto(sxx, sxy)
- goto(fx, fy)
- x = 0
- y = 0
- hex(x,y)
- x = hexWidth * 3 / 4
- y = -(hexHeight*0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y += (hexHeight * 0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y -= (hexHeight * 0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y += (hexHeight * 0.5)
- hex(x, y)
- x = 0
- y = -hexHeight
- hex(x, y)
- x += hexWidth * 3 / 4
- y -= (hexHeight * 0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y += (hexHeight * 0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y -= (hexHeight * 0.5)
- hex(x, y)
- x += hexWidth * 3 / 4
- y += (hexHeight * 0.5)
- hex(x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement