Created
February 1, 2019 15:50
-
-
Save 5agado/617c94753c2322f0f44c1444c31bf899 to your computer and use it in GitHub Desktop.
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
def draw_circle(gp_frame, center: tuple, radius: float, segments: int): | |
# Init new stroke | |
gp_stroke = gp_frame.strokes.new() | |
gp_stroke.display_mode = '3DSPACE' # allows for editing | |
gp_stroke.draw_cyclic = True # closes the stroke | |
# Define stroke geometry | |
angle = 2*math.pi/segments # angle in radians | |
gp_stroke.points.add(count=segments) | |
for i in range(segments): | |
x = center[0] + radius*math.cos(angle*i) | |
y = center[1] + radius*math.sin(angle*i) | |
z = center[2] | |
gp_stroke.points[i].co = (x, y, z) | |
return gp_stroke |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gp_stroke.draw_cyclic = True
shows error