Draft: moved getrgb to utils.py
This commit is contained in:
committed by
Yorik van Havre
parent
ccad0fed30
commit
3a44b4e2c0
@@ -146,6 +146,9 @@ from draftutils.utils import filterObjectsForModifiers
|
||||
from draftutils.utils import is_closed_edge
|
||||
from draftutils.utils import isClosedEdge
|
||||
|
||||
from draftutils.utils import get_rgb
|
||||
from draftutils.utils import getrgb
|
||||
|
||||
from draftutils.gui_utils import get3DView
|
||||
from draftutils.gui_utils import get_3d_view
|
||||
|
||||
@@ -485,20 +488,6 @@ def getDXF(obj,direction=None):
|
||||
return result
|
||||
|
||||
|
||||
def getrgb(color,testbw=True):
|
||||
"""getRGB(color,[testbw]): returns a rgb value #000000 from a freecad color
|
||||
if testwb = True (default), pure white will be converted into pure black"""
|
||||
r = str(hex(int(color[0]*255)))[2:].zfill(2)
|
||||
g = str(hex(int(color[1]*255)))[2:].zfill(2)
|
||||
b = str(hex(int(color[2]*255)))[2:].zfill(2)
|
||||
col = "#"+r+g+b
|
||||
if testbw:
|
||||
if col == "#ffffff":
|
||||
#print(getParam('SvgLinesBlack'))
|
||||
if getParam('SvgLinesBlack',True):
|
||||
col = "#000000"
|
||||
return col
|
||||
|
||||
|
||||
import getSVG as svg
|
||||
|
||||
|
||||
@@ -925,6 +925,31 @@ def svg_patterns():
|
||||
svgpatterns = svg_patterns
|
||||
|
||||
|
||||
def get_rgb(color, testbw=True):
|
||||
"""getRGB(color,[testbw])
|
||||
|
||||
Return a rgb value #000000 from a freecad color
|
||||
|
||||
Parameters
|
||||
----------
|
||||
testwb : bool (default = True)
|
||||
pure white will be converted into pure black
|
||||
"""
|
||||
r = str(hex(int(color[0]*255)))[2:].zfill(2)
|
||||
g = str(hex(int(color[1]*255)))[2:].zfill(2)
|
||||
b = str(hex(int(color[2]*255)))[2:].zfill(2)
|
||||
col = "#"+r+g+b
|
||||
if testbw:
|
||||
if col == "#ffffff":
|
||||
#print(getParam('SvgLinesBlack'))
|
||||
if getParam('SvgLinesBlack',True):
|
||||
col = "#000000"
|
||||
return col
|
||||
|
||||
|
||||
getrgb = get_rgb
|
||||
|
||||
|
||||
def get_movable_children(objectslist, recursive=True):
|
||||
"""Return a list of objects with child objects that move with a host.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user