Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2018-11-12 19:54:20 +0300
committerJacques Lucke <mail@jlucke.com>2018-11-12 19:54:51 +0300
commitbb39e33d2537befd54d8ddda54669749855ba7a3 (patch)
treee7eb18e8797c6e1dbcb7aa3fe54abe78b1865d8c /release/scripts/modules/gpu_extras
parent15a5cc6ca0b93a923e1bfd25850d3d645aaa43b5 (diff)
Fix: draw_circle_2d not using the segment count from parameter list
Diffstat (limited to 'release/scripts/modules/gpu_extras')
-rw-r--r--release/scripts/modules/gpu_extras/presets.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/release/scripts/modules/gpu_extras/presets.py b/release/scripts/modules/gpu_extras/presets.py
index ad623c456e0..46c79c61d4d 100644
--- a/release/scripts/modules/gpu_extras/presets.py
+++ b/release/scripts/modules/gpu_extras/presets.py
@@ -16,7 +16,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-def draw_circle_2d(position, color, radius, segments):
+def draw_circle_2d(position, color, radius, segments = 32):
from math import sin, cos, pi
import gpu
from gpu.types import (
@@ -25,12 +25,14 @@ def draw_circle_2d(position, color, radius, segments):
GPUVertFormat,
)
+ if segments <= 0:
+ raise ValueError("Amount of segments must be greater than 0.")
+
with gpu.matrix.push_pop():
gpu.matrix.translate(position)
gpu.matrix.scale_uniform(radius)
- seg = 32
- mul = (1.0 / (seg - 1)) * (pi * 2)
- verts = [(sin(i * mul), cos(i * mul)) for i in range(seg)]
+ mul = (1.0 / (segments - 1)) * (pi * 2)
+ verts = [(sin(i * mul), cos(i * mul)) for i in range(segments)]
fmt = GPUVertFormat()
pos_id = fmt.attr_add(id="pos", comp_type='F32', len=2, fetch_mode='FLOAT')
vbo = GPUVertBuf(len=len(verts), format=fmt)