mirror of
https://github.com/jdegenstein/jmwright-CQ-Editor.git
synced 2025-12-20 14:37:04 +01:00
add rand_color
This commit is contained in:
@@ -13,6 +13,7 @@ from logbook import info
|
||||
from path import Path
|
||||
from pyqtgraph.parametertree import Parameter
|
||||
from spyder.utils.icon_manager import icon
|
||||
from random import randrange as rrr, seed
|
||||
|
||||
from ..cq_utils import find_cq_objects, reload_cq
|
||||
from ..mixins import ComponentMixin
|
||||
@@ -207,8 +208,28 @@ class Debugger(QObject,ComponentMixin):
|
||||
|
||||
_show_object(obj,name,options=dict(color='red',alpha=0.2))
|
||||
|
||||
def _rand_color(alpha = 0., cfloat=False):
|
||||
#helper function to generate a random color dict
|
||||
#for CQ-editor's show_object function
|
||||
lower = 10
|
||||
upper = 100 #not too high to keep color brightness in check
|
||||
if cfloat: #for two output types depending on need
|
||||
return (
|
||||
(rrr(lower,upper)/255),
|
||||
(rrr(lower,upper)/255),
|
||||
(rrr(lower,upper)/255),
|
||||
alpha,
|
||||
)
|
||||
return {"alpha": alpha,
|
||||
"color": (
|
||||
rrr(lower,upper),
|
||||
rrr(lower,upper),
|
||||
rrr(lower,upper),
|
||||
)}
|
||||
|
||||
module.__dict__['show_object'] = _show_object
|
||||
module.__dict__['debug'] = _debug
|
||||
module.__dict__['rand_color'] = _rand_color
|
||||
module.__dict__['log'] = lambda x: info(str(x))
|
||||
module.__dict__['cq'] = cq
|
||||
|
||||
@@ -220,7 +241,7 @@ class Debugger(QObject,ComponentMixin):
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def render(self):
|
||||
|
||||
seed(371353) #reset the seed every time render is called (preserves colors run to run)
|
||||
if self.preferences['Reload CQ']:
|
||||
reload_cq()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user