rna attribute consistency edits, use common prefix for booleans.
This commit is contained in:
@@ -59,24 +59,24 @@ class ScalarBlendModifier(StrokeShader):
|
||||
def blend(self, v1, v2):
|
||||
fac = self.__influence
|
||||
facm = 1.0 - fac
|
||||
if self.__blend == "MIX":
|
||||
if self.__blend == 'MIX':
|
||||
v1 = facm * v1 + fac * v2
|
||||
elif self.__blend == "ADD":
|
||||
elif self.__blend == 'ADD':
|
||||
v1 += fac * v2
|
||||
elif self.__blend == "MULTIPLY":
|
||||
elif self.__blend == 'MULTIPLY':
|
||||
v1 *= facm + fac * v2;
|
||||
elif self.__blend == "SUBTRACT":
|
||||
elif self.__blend == 'SUBTRACT':
|
||||
v1 -= fac * v2
|
||||
elif self.__blend == "DIVIDE":
|
||||
elif self.__blend == 'DIVIDE':
|
||||
if v2 != 0.0:
|
||||
v1 = facm * v1 + fac * v1 / v2
|
||||
elif self.__blend == "DIFFERENCE":
|
||||
elif self.__blend == 'DIFFERENCE':
|
||||
v1 = facm * v1 + fac * abs(v1 - v2)
|
||||
elif self.__blend == "MININUM":
|
||||
elif self.__blend == 'MININUM':
|
||||
tmp = fac * v1
|
||||
if v1 > tmp:
|
||||
v1 = tmp
|
||||
elif self.__blend == "MAXIMUM":
|
||||
elif self.__blend == 'MAXIMUM':
|
||||
tmp = fac * v1
|
||||
if v1 < tmp:
|
||||
v1 = tmp
|
||||
@@ -87,7 +87,7 @@ class ScalarBlendModifier(StrokeShader):
|
||||
class CurveMappingModifier(ScalarBlendModifier):
|
||||
def __init__(self, blend, influence, mapping, invert, curve):
|
||||
ScalarBlendModifier.__init__(self, blend, influence)
|
||||
assert mapping in ("LINEAR", "CURVE")
|
||||
assert mapping in {'LINEAR', 'CURVE'}
|
||||
self.__mapping = getattr(self, mapping)
|
||||
self.__invert = invert
|
||||
self.__curve = curve
|
||||
@@ -103,7 +103,7 @@ class CurveMappingModifier(ScalarBlendModifier):
|
||||
class ThicknessModifierMixIn:
|
||||
def __init__(self):
|
||||
scene = freestyle.getCurrentScene()
|
||||
self.__persp_camera = (scene.camera.data.type == "PERSP")
|
||||
self.__persp_camera = (scene.camera.data.type == 'PERSP')
|
||||
def set_thickness(self, sv, outer, inner):
|
||||
fe = sv.first_svertex.get_fedge(sv.second_svertex)
|
||||
nature = fe.nature
|
||||
@@ -129,16 +129,16 @@ class ThicknessBlenderMixIn(ThicknessModifierMixIn):
|
||||
self.__position = position
|
||||
self.__ratio = ratio
|
||||
def blend_thickness(self, outer, inner, v):
|
||||
if self.__position == "CENTER":
|
||||
if self.__position == 'CENTER':
|
||||
outer = self.blend(outer, v / 2)
|
||||
inner = self.blend(inner, v / 2)
|
||||
elif self.__position == "INSIDE":
|
||||
elif self.__position == 'INSIDE':
|
||||
outer = self.blend(outer, 0)
|
||||
inner = self.blend(inner, v)
|
||||
elif self.__position == "OUTSIDE":
|
||||
elif self.__position == 'OUTSIDE':
|
||||
outer = self.blend(outer, v)
|
||||
inner = self.blend(inner, 0)
|
||||
elif self.__position == "RELATIVE":
|
||||
elif self.__position == 'RELATIVE':
|
||||
outer = self.blend(outer, v * self.__ratio)
|
||||
inner = self.blend(inner, v * (1 - self.__ratio))
|
||||
else:
|
||||
@@ -152,16 +152,16 @@ class BaseThicknessShader(StrokeShader, ThicknessModifierMixIn):
|
||||
def __init__(self, thickness, position, ratio):
|
||||
StrokeShader.__init__(self)
|
||||
ThicknessModifierMixIn.__init__(self)
|
||||
if position == "CENTER":
|
||||
if position == 'CENTER':
|
||||
self.__outer = thickness / 2
|
||||
self.__inner = thickness / 2
|
||||
elif position == "INSIDE":
|
||||
elif position == 'INSIDE':
|
||||
self.__outer = 0
|
||||
self.__inner = thickness
|
||||
elif position == "OUTSIDE":
|
||||
elif position == 'OUTSIDE':
|
||||
self.__outer = thickness
|
||||
self.__inner = 0
|
||||
elif position == "RELATIVE":
|
||||
elif position == 'RELATIVE':
|
||||
self.__outer = thickness * ratio
|
||||
self.__inner = thickness * (1 - ratio)
|
||||
else:
|
||||
@@ -350,84 +350,76 @@ class ThicknessDistanceFromObjectShader(ThicknessBlenderMixIn, CurveMappingModif
|
||||
|
||||
# Material modifiers
|
||||
|
||||
def iter_material_color(stroke, material_attr):
|
||||
def iter_material_color(stroke, material_attribute):
|
||||
func = CurveMaterialF0D()
|
||||
it = stroke.stroke_vertices_begin()
|
||||
while not it.is_end:
|
||||
material = func(Interface0DIterator(it))
|
||||
if material_attr == "DIFF":
|
||||
color = (material.diffuse[0],
|
||||
material.diffuse[1],
|
||||
material.diffuse[2])
|
||||
elif material_attr == "SPEC":
|
||||
color = (material.specular[0],
|
||||
material.specular[1],
|
||||
material.specular[2])
|
||||
if material_attribute == 'DIFF':
|
||||
color = material.diffuse[:]
|
||||
elif material_attribute == 'SPEC':
|
||||
color = material.specular[:]
|
||||
else:
|
||||
raise ValueError("unexpected material attribute: " + material_attr)
|
||||
raise ValueError("unexpected material attribute: " + material_attribute)
|
||||
yield it, color
|
||||
it.increment()
|
||||
|
||||
def iter_material_value(stroke, material_attr):
|
||||
def iter_material_value(stroke, material_attribute):
|
||||
func = CurveMaterialF0D()
|
||||
it = stroke.stroke_vertices_begin()
|
||||
while not it.is_end:
|
||||
material = func(Interface0DIterator(it))
|
||||
if material_attr == "DIFF":
|
||||
r = material.diffuse[0]
|
||||
g = material.diffuse[1]
|
||||
b = material.diffuse[2]
|
||||
if material_attribute == 'DIFF':
|
||||
r, g, b = material.diffuse
|
||||
t = 0.35 * r + 0.45 * r + 0.2 * b
|
||||
elif material_attr == "DIFF_R":
|
||||
elif material_attribute == 'DIFF_R':
|
||||
t = material.diffuse[0]
|
||||
elif material_attr == "DIFF_G":
|
||||
elif material_attribute == 'DIFF_G':
|
||||
t = material.diffuse[1]
|
||||
elif material_attr == "DIFF_B":
|
||||
elif material_attribute == 'DIFF_B':
|
||||
t = material.diffuse[2]
|
||||
elif material_attr == "SPEC":
|
||||
r = material.specular[0]
|
||||
g = material.specular[1]
|
||||
b = material.specular[2]
|
||||
elif material_attribute == 'SPEC':
|
||||
r, g, b = material.specular
|
||||
t = 0.35 * r + 0.45 * r + 0.2 * b
|
||||
elif material_attr == "SPEC_R":
|
||||
elif material_attribute == 'SPEC_R':
|
||||
t = material.specular[0]
|
||||
elif material_attr == "SPEC_G":
|
||||
elif material_attribute == 'SPEC_G':
|
||||
t = material.specular[1]
|
||||
elif material_attr == "SPEC_B":
|
||||
elif material_attribute == 'SPEC_B':
|
||||
t = material.specular[2]
|
||||
elif material_attr == "SPEC_HARDNESS":
|
||||
elif material_attribute == 'SPEC_HARDNESS':
|
||||
t = material.shininess
|
||||
elif material_attr == "ALPHA":
|
||||
elif material_attribute == 'ALPHA':
|
||||
t = material.diffuse[3]
|
||||
else:
|
||||
raise ValueError("unexpected material attribute: " + material_attr)
|
||||
raise ValueError("unexpected material attribute: " + material_attribute)
|
||||
yield it, t
|
||||
it.increment()
|
||||
|
||||
class ColorMaterialShader(ColorRampModifier):
|
||||
def __init__(self, blend, influence, ramp, material_attr, use_ramp):
|
||||
def __init__(self, blend, influence, ramp, material_attribute, use_ramp):
|
||||
ColorRampModifier.__init__(self, blend, influence, ramp)
|
||||
self.__material_attr = material_attr
|
||||
self.__material_attribute = material_attribute
|
||||
self.__use_ramp = use_ramp
|
||||
def shade(self, stroke):
|
||||
if self.__material_attr in ["DIFF", "SPEC"] and not self.__use_ramp:
|
||||
for it, b in iter_material_color(stroke, self.__material_attr):
|
||||
if self.__material_attribute in {'DIFF', 'SPEC'} and not self.__use_ramp:
|
||||
for it, b in iter_material_color(stroke, self.__material_attribute):
|
||||
sv = it.object
|
||||
a = sv.attribute.color
|
||||
sv.attribute.color = self.blend_ramp(a, b)
|
||||
else:
|
||||
for it, t in iter_material_value(stroke, self.__material_attr):
|
||||
for it, t in iter_material_value(stroke, self.__material_attribute):
|
||||
sv = it.object
|
||||
a = sv.attribute.color
|
||||
b = self.evaluate(t)
|
||||
sv.attribute.color = self.blend_ramp(a, b)
|
||||
|
||||
class AlphaMaterialShader(CurveMappingModifier):
|
||||
def __init__(self, blend, influence, mapping, invert, curve, material_attr):
|
||||
def __init__(self, blend, influence, mapping, invert, curve, material_attribute):
|
||||
CurveMappingModifier.__init__(self, blend, influence, mapping, invert, curve)
|
||||
self.__material_attr = material_attr
|
||||
self.__material_attribute = material_attribute
|
||||
def shade(self, stroke):
|
||||
for it, t in iter_material_value(stroke, self.__material_attr):
|
||||
for it, t in iter_material_value(stroke, self.__material_attribute):
|
||||
sv = it.object
|
||||
a = sv.attribute.alpha
|
||||
b = self.evaluate(t)
|
||||
@@ -435,14 +427,14 @@ class AlphaMaterialShader(CurveMappingModifier):
|
||||
|
||||
class ThicknessMaterialShader(ThicknessBlenderMixIn, CurveMappingModifier):
|
||||
def __init__(self, thickness_position, thickness_ratio,
|
||||
blend, influence, mapping, invert, curve, material_attr, value_min, value_max):
|
||||
blend, influence, mapping, invert, curve, material_attribute, value_min, value_max):
|
||||
ThicknessBlenderMixIn.__init__(self, thickness_position, thickness_ratio)
|
||||
CurveMappingModifier.__init__(self, blend, influence, mapping, invert, curve)
|
||||
self.__material_attr = material_attr
|
||||
self.__material_attribute = material_attribute
|
||||
self.__value_min = value_min
|
||||
self.__value_max = value_max
|
||||
def shade(self, stroke):
|
||||
for it, t in iter_material_value(stroke, self.__material_attr):
|
||||
for it, t in iter_material_value(stroke, self.__material_attribute):
|
||||
sv = it.object
|
||||
a = sv.attribute.thickness
|
||||
b = self.__value_min + self.evaluate(t) * (self.__value_max - self.__value_min)
|
||||
@@ -453,12 +445,12 @@ class ThicknessMaterialShader(ThicknessBlenderMixIn, CurveMappingModifier):
|
||||
|
||||
class CalligraphicThicknessShader(ThicknessBlenderMixIn, ScalarBlendModifier):
|
||||
def __init__(self, thickness_position, thickness_ratio,
|
||||
blend, influence, orientation, min_thickness, max_thickness):
|
||||
blend, influence, orientation, thickness_min, thickness_max):
|
||||
ThicknessBlenderMixIn.__init__(self, thickness_position, thickness_ratio)
|
||||
ScalarBlendModifier.__init__(self, blend, influence)
|
||||
self.__orientation = mathutils.Vector((math.cos(orientation), math.sin(orientation)))
|
||||
self.__min_thickness = min_thickness
|
||||
self.__max_thickness = max_thickness
|
||||
self.__thickness_min = thickness_min
|
||||
self.__thickness_max = thickness_max
|
||||
def shade(self, stroke):
|
||||
func = VertexOrientation2DF0D()
|
||||
it = stroke.stroke_vertices_begin()
|
||||
@@ -469,7 +461,7 @@ class CalligraphicThicknessShader(ThicknessBlenderMixIn, ScalarBlendModifier):
|
||||
fac = abs(orthDir * self.__orientation)
|
||||
sv = it.object
|
||||
a = sv.attribute.thickness
|
||||
b = self.__min_thickness + fac * (self.__max_thickness - self.__min_thickness)
|
||||
b = self.__thickness_min + fac * (self.__thickness_max - self.__thickness_min)
|
||||
b = max(b, 0.0)
|
||||
c = self.blend_thickness(a[0], a[1], b)
|
||||
self.set_thickness(sv, c[0], c[1])
|
||||
@@ -570,14 +562,14 @@ class Transform2DShader(StrokeShader):
|
||||
self.__pivot_y = pivot_y
|
||||
def shade(self, stroke):
|
||||
# determine the pivot of scaling and rotation operations
|
||||
if self.__pivot == "START":
|
||||
if self.__pivot == 'START':
|
||||
it = stroke.stroke_vertices_begin()
|
||||
pivot = it.object.point
|
||||
elif self.__pivot == "END":
|
||||
elif self.__pivot == 'END':
|
||||
it = stroke.stroke_vertices_end()
|
||||
it.decrement()
|
||||
pivot = it.object.point
|
||||
elif self.__pivot == "PARAM":
|
||||
elif self.__pivot == 'PARAM':
|
||||
p = None
|
||||
it = stroke.stroke_vertices_begin()
|
||||
while not it.is_end:
|
||||
@@ -593,7 +585,7 @@ class Transform2DShader(StrokeShader):
|
||||
else:
|
||||
delta = u - self.__pivot_u
|
||||
pivot = p + delta * (prev - p)
|
||||
elif self.__pivot == "CENTER":
|
||||
elif self.__pivot == 'CENTER':
|
||||
pivot = mathutils.Vector([0.0, 0.0])
|
||||
n = 0
|
||||
it = stroke.stroke_vertices_begin()
|
||||
@@ -604,7 +596,7 @@ class Transform2DShader(StrokeShader):
|
||||
it.increment()
|
||||
pivot.x = pivot.x / n
|
||||
pivot.y = pivot.y / n
|
||||
elif self.__pivot == "ABSOLUTE":
|
||||
elif self.__pivot == 'ABSOLUTE':
|
||||
pivot = mathutils.Vector([self.__pivot_x, self.__pivot_y])
|
||||
# apply scaling and rotation operations
|
||||
cos_theta = math.cos(self.__angle)
|
||||
@@ -874,15 +866,15 @@ class AndBP1D(BinaryPredicate1D):
|
||||
# predicates for selection
|
||||
|
||||
class LengthThresholdUP1D(UnaryPredicate1D):
|
||||
def __init__(self, min_length=None, max_length=None):
|
||||
def __init__(self, length_min=None, length_max=None):
|
||||
UnaryPredicate1D.__init__(self)
|
||||
self._min_length = min_length
|
||||
self._max_length = max_length
|
||||
self._length_min = length_min
|
||||
self._length_max = length_max
|
||||
def __call__(self, inter):
|
||||
length = inter.length_2d
|
||||
if self._min_length is not None and length < self._min_length:
|
||||
if self._length_min is not None and length < self._length_min:
|
||||
return False
|
||||
if self._max_length is not None and length > self._max_length:
|
||||
if self._length_max is not None and length > self._length_max:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -931,16 +923,16 @@ class MaterialBoundaryUP0D(UnaryPredicate0D):
|
||||
return idx1 != idx2
|
||||
|
||||
class Curvature2DAngleThresholdUP0D(UnaryPredicate0D):
|
||||
def __init__(self, min_angle=None, max_angle=None):
|
||||
def __init__(self, angle_min=None, angle_max=None):
|
||||
UnaryPredicate0D.__init__(self)
|
||||
self._min_angle = min_angle
|
||||
self._max_angle = max_angle
|
||||
self._angle_min = angle_min
|
||||
self._angle_max = angle_max
|
||||
self._func = Curvature2DAngleF0D()
|
||||
def __call__(self, inter):
|
||||
angle = math.pi - self._func(inter)
|
||||
if self._min_angle is not None and angle < self._min_angle:
|
||||
if self._angle_min is not None and angle < self._angle_min:
|
||||
return True
|
||||
if self._max_angle is not None and angle > self._max_angle:
|
||||
if self._angle_max is not None and angle > self._angle_max:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -984,13 +976,13 @@ def process(layer_name, lineset_name):
|
||||
selection_criteria = []
|
||||
# prepare selection criteria by visibility
|
||||
if lineset.select_by_visibility:
|
||||
if lineset.visibility == "VISIBLE":
|
||||
if lineset.visibility == 'VISIBLE':
|
||||
selection_criteria.append(
|
||||
QuantitativeInvisibilityUP1D(0))
|
||||
elif lineset.visibility == "HIDDEN":
|
||||
elif lineset.visibility == 'HIDDEN':
|
||||
selection_criteria.append(
|
||||
NotUP1D(QuantitativeInvisibilityUP1D(0)))
|
||||
elif lineset.visibility == "RANGE":
|
||||
elif lineset.visibility == 'RANGE':
|
||||
selection_criteria.append(
|
||||
QuantitativeInvisibilityRangeUP1D(lineset.qi_start, lineset.qi_end))
|
||||
# prepare selection criteria by edge types
|
||||
@@ -1023,21 +1015,21 @@ def process(layer_name, lineset_name):
|
||||
if lineset.select_external_contour:
|
||||
upred = ExternalContourUP1D()
|
||||
edge_type_criteria.append(NotUP1D(upred) if lineset.exclude_external_contour else upred)
|
||||
if lineset.edge_type_combination == "OR":
|
||||
if lineset.edge_type_combination == 'OR':
|
||||
upred = join_unary_predicates(edge_type_criteria, OrUP1D)
|
||||
else:
|
||||
upred = join_unary_predicates(edge_type_criteria, AndUP1D)
|
||||
if upred is not None:
|
||||
if lineset.edge_type_negation == "EXCLUSIVE":
|
||||
if lineset.edge_type_negation == 'EXCLUSIVE':
|
||||
upred = NotUP1D(upred)
|
||||
selection_criteria.append(upred)
|
||||
# prepare selection criteria by face marks
|
||||
if lineset.select_by_face_marks:
|
||||
if lineset.face_mark_condition == "BOTH":
|
||||
if lineset.face_mark_condition == 'BOTH':
|
||||
upred = FaceMarkBothUP1D()
|
||||
else:
|
||||
upred = FaceMarkOneUP1D()
|
||||
if lineset.face_mark_negation == "EXCLUSIVE":
|
||||
if lineset.face_mark_negation == 'EXCLUSIVE':
|
||||
upred = NotUP1D(upred)
|
||||
selection_criteria.append(upred)
|
||||
# prepare selection criteria by group of objects
|
||||
@@ -1068,13 +1060,13 @@ def process(layer_name, lineset_name):
|
||||
Operators.select(upred)
|
||||
# join feature edges to form chains
|
||||
if linestyle.use_chaining:
|
||||
if linestyle.chaining == "PLAIN":
|
||||
if linestyle.same_object:
|
||||
if linestyle.chaining == 'PLAIN':
|
||||
if linestyle.use_same_object:
|
||||
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
|
||||
else:
|
||||
Operators.bidirectional_chain(ChainPredicateIterator(upred, TrueBP1D()), NotUP1D(upred))
|
||||
elif linestyle.chaining == "SKETCHY":
|
||||
if linestyle.same_object:
|
||||
elif linestyle.chaining == 'SKETCHY':
|
||||
if linestyle.use_same_object:
|
||||
Operators.bidirectional_chain(pySketchyChainSilhouetteIterator(linestyle.rounds))
|
||||
else:
|
||||
Operators.bidirectional_chain(pySketchyChainingIterator(linestyle.rounds))
|
||||
@@ -1083,10 +1075,10 @@ def process(layer_name, lineset_name):
|
||||
# split chains
|
||||
if linestyle.material_boundary:
|
||||
Operators.sequential_split(MaterialBoundaryUP0D())
|
||||
if linestyle.use_min_angle or linestyle.use_max_angle:
|
||||
min_angle = linestyle.min_angle if linestyle.use_min_angle else None
|
||||
max_angle = linestyle.max_angle if linestyle.use_max_angle else None
|
||||
Operators.sequential_split(Curvature2DAngleThresholdUP0D(min_angle, max_angle))
|
||||
if linestyle.use_angle_min or linestyle.use_angle_max:
|
||||
angle_min = linestyle.angle_min if linestyle.use_angle_min else None
|
||||
angle_max = linestyle.angle_max if linestyle.use_angle_max else None
|
||||
Operators.sequential_split(Curvature2DAngleThresholdUP0D(angle_min, angle_max))
|
||||
if linestyle.use_split_length:
|
||||
Operators.sequential_split(Length2DThresholdUP0D(linestyle.split_length), 1.0)
|
||||
if linestyle.use_split_pattern:
|
||||
@@ -1107,140 +1099,140 @@ def process(layer_name, lineset_name):
|
||||
SplitPatternStoppingUP0D(controller),
|
||||
sampling)
|
||||
# select chains
|
||||
if linestyle.use_min_length or linestyle.use_max_length:
|
||||
min_length = linestyle.min_length if linestyle.use_min_length else None
|
||||
max_length = linestyle.max_length if linestyle.use_max_length else None
|
||||
Operators.select(LengthThresholdUP1D(min_length, max_length))
|
||||
if linestyle.use_length_min or linestyle.use_length_max:
|
||||
length_min = linestyle.length_min if linestyle.use_length_min else None
|
||||
length_max = linestyle.length_max if linestyle.use_length_max else None
|
||||
Operators.select(LengthThresholdUP1D(length_min, length_max))
|
||||
# prepare a list of stroke shaders
|
||||
shaders_list = []
|
||||
for m in linestyle.geometry_modifiers:
|
||||
if not m.use:
|
||||
continue
|
||||
if m.type == "SAMPLING":
|
||||
if m.type == 'SAMPLING':
|
||||
shaders_list.append(SamplingShader(
|
||||
m.sampling))
|
||||
elif m.type == "BEZIER_CURVE":
|
||||
elif m.type == 'BEZIER_CURVE':
|
||||
shaders_list.append(BezierCurveShader(
|
||||
m.error))
|
||||
elif m.type == "SINUS_DISPLACEMENT":
|
||||
elif m.type == 'SINUS_DISPLACEMENT':
|
||||
shaders_list.append(SinusDisplacementShader(
|
||||
m.wavelength, m.amplitude, m.phase))
|
||||
elif m.type == "SPATIAL_NOISE":
|
||||
elif m.type == 'SPATIAL_NOISE':
|
||||
shaders_list.append(SpatialNoiseShader(
|
||||
m.amplitude, m.scale, m.octaves, m.smooth, m.pure_random))
|
||||
elif m.type == "PERLIN_NOISE_1D":
|
||||
m.amplitude, m.scale, m.octaves, m.smooth, m.use_pure_random))
|
||||
elif m.type == 'PERLIN_NOISE_1D':
|
||||
shaders_list.append(PerlinNoise1DShader(
|
||||
m.frequency, m.amplitude, m.octaves, m.angle, _seed.get(m.seed)))
|
||||
elif m.type == "PERLIN_NOISE_2D":
|
||||
elif m.type == 'PERLIN_NOISE_2D':
|
||||
shaders_list.append(PerlinNoise2DShader(
|
||||
m.frequency, m.amplitude, m.octaves, m.angle, _seed.get(m.seed)))
|
||||
elif m.type == "BACKBONE_STRETCHER":
|
||||
elif m.type == 'BACKBONE_STRETCHER':
|
||||
shaders_list.append(BackboneStretcherShader(
|
||||
m.backbone_length))
|
||||
elif m.type == "TIP_REMOVER":
|
||||
elif m.type == 'TIP_REMOVER':
|
||||
shaders_list.append(TipRemoverShader(
|
||||
m.tip_length))
|
||||
elif m.type == "POLYGONIZATION":
|
||||
elif m.type == 'POLYGONIZATION':
|
||||
shaders_list.append(PolygonalizationShader(
|
||||
m.error))
|
||||
elif m.type == "GUIDING_LINES":
|
||||
elif m.type == 'GUIDING_LINES':
|
||||
shaders_list.append(GuidingLinesShader(
|
||||
m.offset))
|
||||
elif m.type == "BLUEPRINT":
|
||||
if m.shape == "CIRCLES":
|
||||
elif m.type == 'BLUEPRINT':
|
||||
if m.shape == 'CIRCLES':
|
||||
shaders_list.append(pyBluePrintCirclesShader(
|
||||
m.rounds, m.random_radius, m.random_center))
|
||||
elif m.shape == "ELLIPSES":
|
||||
elif m.shape == 'ELLIPSES':
|
||||
shaders_list.append(pyBluePrintEllipsesShader(
|
||||
m.rounds, m.random_radius, m.random_center))
|
||||
elif m.shape == "SQUARES":
|
||||
elif m.shape == 'SQUARES':
|
||||
shaders_list.append(pyBluePrintSquaresShader(
|
||||
m.rounds, m.backbone_length, m.random_backbone))
|
||||
elif m.type == "2D_OFFSET":
|
||||
elif m.type == '2D_OFFSET':
|
||||
shaders_list.append(Offset2DShader(
|
||||
m.start, m.end, m.x, m.y))
|
||||
elif m.type == "2D_TRANSFORM":
|
||||
elif m.type == '2D_TRANSFORM':
|
||||
shaders_list.append(Transform2DShader(
|
||||
m.pivot, m.scale_x, m.scale_y, m.angle, m.pivot_u, m.pivot_x, m.pivot_y))
|
||||
color = linestyle.color
|
||||
if (not linestyle.use_chaining) or (linestyle.chaining == "PLAIN" and linestyle.same_object):
|
||||
if (not linestyle.use_chaining) or (linestyle.chaining == 'PLAIN' and linestyle.use_same_object):
|
||||
thickness_position = linestyle.thickness_position
|
||||
else:
|
||||
thickness_position = "CENTER"
|
||||
thickness_position = 'CENTER'
|
||||
import bpy
|
||||
if bpy.app.debug_freestyle:
|
||||
print("Warning: Thickness position options are applied when chaining is disabled")
|
||||
print(" or the Plain chaining is used with the Same Object option enabled.")
|
||||
print("Warning: Thickness position options are applied when chaining is disabled\n"
|
||||
" or the Plain chaining is used with the Same Object option enabled.")
|
||||
shaders_list.append(BaseColorShader(color.r, color.g, color.b, linestyle.alpha))
|
||||
shaders_list.append(BaseThicknessShader(linestyle.thickness, thickness_position,
|
||||
linestyle.thickness_ratio))
|
||||
for m in linestyle.color_modifiers:
|
||||
if not m.use:
|
||||
continue
|
||||
if m.type == "ALONG_STROKE":
|
||||
if m.type == 'ALONG_STROKE':
|
||||
shaders_list.append(ColorAlongStrokeShader(
|
||||
m.blend, m.influence, m.color_ramp))
|
||||
elif m.type == "DISTANCE_FROM_CAMERA":
|
||||
elif m.type == 'DISTANCE_FROM_CAMERA':
|
||||
shaders_list.append(ColorDistanceFromCameraShader(
|
||||
m.blend, m.influence, m.color_ramp,
|
||||
m.range_min, m.range_max))
|
||||
elif m.type == "DISTANCE_FROM_OBJECT":
|
||||
elif m.type == 'DISTANCE_FROM_OBJECT':
|
||||
shaders_list.append(ColorDistanceFromObjectShader(
|
||||
m.blend, m.influence, m.color_ramp, m.target,
|
||||
m.range_min, m.range_max))
|
||||
elif m.type == "MATERIAL":
|
||||
elif m.type == 'MATERIAL':
|
||||
shaders_list.append(ColorMaterialShader(
|
||||
m.blend, m.influence, m.color_ramp, m.material_attr,
|
||||
m.blend, m.influence, m.color_ramp, m.material_attribute,
|
||||
m.use_ramp))
|
||||
for m in linestyle.alpha_modifiers:
|
||||
if not m.use:
|
||||
continue
|
||||
if m.type == "ALONG_STROKE":
|
||||
if m.type == 'ALONG_STROKE':
|
||||
shaders_list.append(AlphaAlongStrokeShader(
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve))
|
||||
elif m.type == "DISTANCE_FROM_CAMERA":
|
||||
elif m.type == 'DISTANCE_FROM_CAMERA':
|
||||
shaders_list.append(AlphaDistanceFromCameraShader(
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve,
|
||||
m.range_min, m.range_max))
|
||||
elif m.type == "DISTANCE_FROM_OBJECT":
|
||||
elif m.type == 'DISTANCE_FROM_OBJECT':
|
||||
shaders_list.append(AlphaDistanceFromObjectShader(
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve, m.target,
|
||||
m.range_min, m.range_max))
|
||||
elif m.type == "MATERIAL":
|
||||
elif m.type == 'MATERIAL':
|
||||
shaders_list.append(AlphaMaterialShader(
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve,
|
||||
m.material_attr))
|
||||
m.material_attribute))
|
||||
for m in linestyle.thickness_modifiers:
|
||||
if not m.use:
|
||||
continue
|
||||
if m.type == "ALONG_STROKE":
|
||||
if m.type == 'ALONG_STROKE':
|
||||
shaders_list.append(ThicknessAlongStrokeShader(
|
||||
thickness_position, linestyle.thickness_ratio,
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve,
|
||||
m.value_min, m.value_max))
|
||||
elif m.type == "DISTANCE_FROM_CAMERA":
|
||||
elif m.type == 'DISTANCE_FROM_CAMERA':
|
||||
shaders_list.append(ThicknessDistanceFromCameraShader(
|
||||
thickness_position, linestyle.thickness_ratio,
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve,
|
||||
m.range_min, m.range_max, m.value_min, m.value_max))
|
||||
elif m.type == "DISTANCE_FROM_OBJECT":
|
||||
elif m.type == 'DISTANCE_FROM_OBJECT':
|
||||
shaders_list.append(ThicknessDistanceFromObjectShader(
|
||||
thickness_position, linestyle.thickness_ratio,
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve, m.target,
|
||||
m.range_min, m.range_max, m.value_min, m.value_max))
|
||||
elif m.type == "MATERIAL":
|
||||
elif m.type == 'MATERIAL':
|
||||
shaders_list.append(ThicknessMaterialShader(
|
||||
thickness_position, linestyle.thickness_ratio,
|
||||
m.blend, m.influence, m.mapping, m.invert, m.curve,
|
||||
m.material_attr, m.value_min, m.value_max))
|
||||
elif m.type == "CALLIGRAPHY":
|
||||
m.material_attribute, m.value_min, m.value_max))
|
||||
elif m.type == 'CALLIGRAPHY':
|
||||
shaders_list.append(CalligraphicThicknessShader(
|
||||
thickness_position, linestyle.thickness_ratio,
|
||||
m.blend, m.influence,
|
||||
m.orientation, m.min_thickness, m.max_thickness))
|
||||
if linestyle.caps == "ROUND":
|
||||
m.orientation, m.thickness_min, m.thickness_max))
|
||||
if linestyle.caps == 'ROUND':
|
||||
shaders_list.append(RoundCapShader())
|
||||
elif linestyle.caps == "SQUARE":
|
||||
elif linestyle.caps == 'SQUARE':
|
||||
shaders_list.append(SquareCapShader())
|
||||
if linestyle.use_dashed_line:
|
||||
pattern = []
|
||||
|
Reference in New Issue
Block a user