Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
3 changed files with 15 additions and 2 deletions
Showing only changes of commit 4be0ba5750 - Show all commits

View File

@ -130,7 +130,10 @@ def set_brush_style(self, value):
addon_prefs = bpy.context.preferences.addons[__package__].preferences
ng_name = f'BSBST-brushstroke.{value}'
ng = utils.ensure_node_group(ng_name, [bs for bs in addon_prefs.brush_styles if bs.name==value][0].filepath)
#if ng.preview:
# utils.set_preview(ng.preview.image_pixels_float)
self.node_tree.nodes['Brush Style'].node_tree = ng
self["brush_style"] = value

View File

@ -1,7 +1,7 @@
import os, ast
import bpy
from bpy.app.handlers import persistent
import math, shutil, errno
import math, shutil, errno, numpy
from bpy.app.handlers import persistent
addon_version = (0,0,0)
@ -528,6 +528,16 @@ def round_n(val, n):
"""
return round(val, n-int(math.floor(math.log10(abs(val))))-1)
def set_preview(pixels):
if not pixels:
return
preview_name = '.BSBST-preview'
preview_img = bpy.data.images.get(preview_name)
if not preview_img:
preview_img = bpy.data.images.new(preview_name, width=256, height=256, float_buffer=True, is_data=True)
preview_img.pixels.foreach_set(pixels)
def register():
bpy.app.handlers.depsgraph_update_post.append(refresh_preset)