text stringlengths 1 93.6k |
|---|
img = bpy.data.images.load(str(texture_path), check_existing=True)
|
icons[image] = gpu.texture.from_image(img)
|
batch = batch_for_shader(
|
shader_2d_image_color, 'TRI_FAN',
|
{
|
"pos": vertices,
|
"texCoord": ((0, 0), (1, 0), (1, 1), (0, 1)),
|
},
|
)
|
shader_2d_image_color.bind()
|
shader_2d_image_color.uniform_float("Color", color)
|
shader_2d_image_color.uniform_float("Color_bg", color_bg)
|
shader_2d_image_color.uniform_float("Fade", fade)
|
shader_2d_image_color.uniform_sampler("Image", icons[image])
|
batch.draw(shader_2d_image_color)
|
gpu.state.blend_set(previous_blend_state)
|
def draw_line_2d(source_x, source_y, target_x, target_y, color=(1, 1, 0, 1), line_width=1):
|
"""
|
Draw a 2d line in the viewport.
|
"""
|
if line_width != 1:
|
gpu.state.line_width_set(line_width)
|
gpu.state.blend_set("ALPHA")
|
vertices = (
|
(source_x, source_y),
|
(target_x, target_y))
|
batch = batch_for_shader(shader_2d_uniform_color, 'LINES', {"pos": vertices})
|
shader_2d_uniform_color.bind()
|
shader_2d_uniform_color.uniform_float("color", color)
|
batch.draw(shader_2d_uniform_color)
|
if line_width != 1:
|
gpu.state.line_width_set(1)
|
gpu.state.blend_set("NONE")
|
def draw_line_3d(source, target, color=(1, 1, 0, 1), line_width=1, depth_test=False):
|
"""
|
Draw a 3d line in the viewport.
|
"""
|
if line_width != 1:
|
gpu.state.line_width_set(line_width)
|
gpu.state.blend_set("ALPHA")
|
if depth_test:
|
gpu.state.depth_test_set("LESS")
|
vertices = (
|
(source[0], source[1], source[2]),
|
(target[0], target[1], target[2]))
|
batch = batch_for_shader(shader_3d_uniform_color, 'LINES', {"pos": vertices})
|
shader_3d_uniform_color.bind()
|
shader_3d_uniform_color.uniform_float("color", color)
|
batch.draw(shader_3d_uniform_color)
|
if line_width != 1:
|
gpu.state.line_width_set(1)
|
gpu.state.blend_set("NONE")
|
if depth_test:
|
gpu.state.depth_test_set("NONE")
|
def draw_line_3d_smooth_blend(source, target, color_a=(1, 0, 0, 1), color_b=(0, 1, 0, 1), line_width=1,
|
depth_test=False):
|
"""
|
Draw a smooth blend line in the viewport.
|
"""
|
if bpy.app.version >= (3, 4, 0):
|
gpu.state.blend_set("ALPHA")
|
if depth_test:
|
gpu.state.depth_test_set("LESS")
|
vertices = (
|
(source[0], source[1], source[2]),
|
(target[0], target[1], target[2]))
|
color_fade = (color_a, color_b)
|
batch = batch_for_shader(shader_3d_polyline_smooth_color, 'LINES', {"pos": vertices, "color": color_fade})
|
shader_3d_polyline_smooth_color.uniform_float("lineWidth", line_width)
|
shader_3d_polyline_smooth_color.bind()
|
batch.draw(shader_3d_polyline_smooth_color)
|
gpu.state.blend_set("NONE")
|
if depth_test:
|
gpu.state.depth_test_set("NONE")
|
else:
|
if line_width != 1:
|
bgl.glLineWidth(line_width)
|
bgl.glEnable(bgl.GL_BLEND)
|
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
if depth_test:
|
bgl.glEnable(bgl.GL_DEPTH_TEST)
|
vertices = (
|
(source[0], source[1], source[2]),
|
(target[0], target[1], target[2]))
|
color_fade = (color_a, color_b)
|
batch = batch_for_shader(shader_3d_smooth_color, 'LINES', {"pos": vertices, "color": color_fade})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.