本文整理汇总了Python中mathutils.Color方法的典型用法代码示例。如果您正苦于以下问题:Python mathutils.Color方法的具体用法?Python mathutils.Color怎么用?Python mathutils.Color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils
的用法示例。
在下文中一共展示了mathutils.Color方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_buttons
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def draw_buttons(self, context, layout):
col = layout.column()
col.label(text="Color Correction")
flow = col.column_flow(align=True)
flow.prop(self, "gamma")
flow.prop(self, "hue_shift")
flow.prop(self, "saturation")
flow.prop(self, "contrast")
flow.prop(self, "contrast_pivot")
flow.prop(self, "exposure")
flow.prop(self, "multiply")
flow.prop(self, "add")
flow.prop(self, "invert")
col.label(text="")
col = layout.column()
col.label(text="Alpha")
flow = col.column_flow(align=True)
flow.prop(self, "is_luminance")
flow.prop(self, "multiply_alpha")
flow.prop(self, "add_alpha")
flow.prop(self, "invert_alpha")
col.label(text="")
示例2: get_image_average_color
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def get_image_average_color(img, sample_count=10):
if not len(img.pixels): return mathutils.Color([0, 0, 0])
pixel_count = img.size[0] * img.size[1]
channels = img.channels
max_s = 0.0
max_s_color, average_color = mathutils.Color([0, 0, 0]), mathutils.Color([0, 0, 0])
seek_interval = pixel_count / sample_count
for sample_index in range(sample_count):
index = int(seek_interval * sample_index) * channels
color = mathutils.Color(img.pixels[index:index+3])
average_color += color
if max_s < color.s:
max_s_color, max_s = color, color.s
average_color /= sample_count
output_color = (average_color + max_s_color) / 2
output_color.s *= 1.5
return max_s_color
# 画像のおおよその平均色を取得 (UV版)
示例3: light
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def light(self, en, scene, name):
"""
en: dxf entity
name: ignored; exists to make separate and merged objects methods universally callable from _call_types()
Creates, links and returns a new light object depending on the type and color of the dxf entity.
"""
# light_type : distant = 1; point = 2; spot = 3
if self.import_light:
type_map = ["NONE", "SUN", "POINT", "SPOT"]
layer = self.dwg.layers[en.layer]
lamp = bpy.data.lamps.new(en.name, type_map[en.light_type])
if en.color != 256:
aci = en.color
else:
aci = layer.color
c = dxfgrabber.aci_to_true_color(aci)
lamp.color = Color(c.rgb())
if en.light_type == 3:
lamp.spot_size = en.hotspot_angle
o = bpy.data.objects.new(en.name, lamp)
o.location = self.proj(en.position)
dir = self.proj(en.target) - self.proj(en.position)
o.rotation_quaternion = dir.rotation_difference(Vector((0, 0, -1)))
scene.objects.link(o)
return o
示例4: DrawCenterText
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def DrawCenterText(text, xt, yt, Size, Color, self):
font_id = 0
# Decalage Ombre
Sshadow_x = 2
Sshadow_y = -2
blf.size(font_id, Size, 72)
blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0] / 2, yt + Sshadow_y, 0)
bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
blf.draw(font_id, text)
blf.position(font_id, xt - blf.dimensions(font_id, text)[0] / 2, yt, 0)
if Color is not None:
mColor = mathutils.Color((Color[0], Color[1], Color[2]))
bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0)
else:
bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
blf.draw(font_id, text)
# Draw text (Left position)
示例5: DrawLeftText
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def DrawLeftText(text, xt, yt, Size, Color, self):
font_id = 0
# Decalage Ombre
Sshadow_x = 2
Sshadow_y = -2
blf.size(font_id, Size, 72)
blf.position(font_id, xt + Sshadow_x, yt + Sshadow_y, 0)
bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
blf.draw(font_id, text)
blf.position(font_id, xt, yt, 0)
if Color is not None:
mColor = mathutils.Color((Color[0], Color[1], Color[2]))
bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0)
else:
bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
blf.draw(font_id, text)
# Draw text (Right position)
示例6: DrawRightText
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def DrawRightText(text, xt, yt, Size, Color, self):
font_id = 0
# Decalage Ombre
Sshadow_x = 2
Sshadow_y = -2
blf.size(font_id, Size, 72)
blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0], yt + Sshadow_y, 0)
bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
blf.draw(font_id, text)
blf.position(font_id, xt - blf.dimensions(font_id, text)[0], yt, 0)
if Color is not None:
mColor = mathutils.Color((Color[0], Color[1], Color[2]))
bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0)
else:
bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
blf.draw(font_id, text)
# Opengl draws
示例7: set_global_settings
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def set_global_settings(self, context):
c = Color()
for i in range(0,5):
if self.history_count == 0:
exec("c.r = PaletteHistory[1"+str(i)+"].r")
exec("c.g = PaletteHistory[1"+str(i)+"].g")
exec("c.b = PaletteHistory[1"+str(i)+"].b")
elif self.history_count == 1:
exec("c.r = PaletteHistory["+str(i+5)+"].r")
exec("c.g = PaletteHistory["+str(i+5)+"].g")
exec("c.b = PaletteHistory["+str(i+5)+"].b")
elif self.history_count == 2:
exec("c.r = PaletteHistory["+str(i)+"].r")
exec("c.g = PaletteHistory["+str(i)+"].g")
exec("c.b = PaletteHistory["+str(i)+"].b")
c.v = c.v+self.value_slider
c.s = c.s+self.saturation_slider
# Hue correction, as it is a single sphere without a bound
val = c.h+self.hue_slider
c.h = val if val < 1 else val - 1
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
示例8: gamma_correct
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def gamma_correct(color):
"""Apply sRGB color space gamma correction to the given color"""
if isinstance(color, float):
# seperate color channel
return color ** (1 / 2.2)
# mathutils.Color does not support alpha yet, so just use RGB
# see: https://developer.blender.org/T53540
color = color[0:3]
# note that here use a widely mentioned sRGB approximation gamma = 2.2
# it is good enough, the exact gamma of sRGB can be find at
# https://en.wikipedia.org/wiki/SRGB
if len(color) > 3:
color = color[:3]
return mathutils.Color(tuple([x ** (1 / 2.2) for x in color]))
# ------------------ Implicit Conversions of Blender Types --------------------
示例9: __init__
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def __init__(self, scene):
self.autoClear = True
world = scene.world
if world:
self.ambient_color = world.ambient_color
self.clear_color = world.horizon_color
else:
self.ambient_color = mathutils.Color((0.2, 0.2, 0.3))
self.clear_color = mathutils.Color((0.0, 0.0, 0.0))
self.gravity = scene.gravity
if world and world.mist_settings.use_mist:
self.fogMode = FOGMODE_LINEAR
self.fogColor = world.horizon_color
self.fogStart = world.mist_settings.start
self.fogEnd = world.mist_settings.depth
self.fogDensity = 0.1
Main.log('Python World class constructor completed')
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
示例10: __init__
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def __init__(self, bpyNode, socketName):
super().__init__(bpyNode, socketName)
input = self.findInput('Color')
defaultColor = self.findTexture(input, SPECULAR_TEX)
if defaultColor is not None:
self.specularColor = Color((defaultColor[0], defaultColor[1], defaultColor[2]))
self.mustBakeSpecular = input.mustBake if isinstance(input, AbstractBJSNode) else False
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
input = self.findInput('Roughness')
defaultRoughness = self.findTexture(input, ROUGHNESS_TEX)
if defaultRoughness is not None:
self.roughness = defaultRoughness
self.mustBakeRoughness = input.mustBake if isinstance(input, AbstractBJSNode) else False
示例11: set_samples
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def set_samples(self):
samples = self.settings.samples
if self.settings.individual_samples and not self.settings.use_autodetect:
bakelist = bpy.context.scene.principled_baker_bakelist
if self.job_name in bakelist.keys():
samples = bakelist[self.job_name].samples
else:
if self.job_name == "Diffuse":
samples = self.settings.samples_diffuse
elif self.job_name == "Bump":
samples = self.settings.samples_bump
elif self.job_name == "Vertex Color":
samples = self.settings.samples_vertex_color
elif self.job_name == "Material ID":
samples = self.settings.samples_material_id
elif self.job_name == "Wireframe":
samples = self.settings.samples_wireframe
bpy.context.scene.cycles.samples = samples
示例12: guess_colors
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def guess_colors(self, obj):
for mat_slot in obj.material_slots:
if mat_slot.material:
mat = mat_slot.material
if MATERIAL_TAG not in mat.keys():
mat_out = get_active_output(mat_slot.material)
if self.job_name == 'Emission':
node_types = 'EMISSION'
elif self.job_name == 'Alpha':
node_types = 'BSDF_TRANSPARENT'
else:
node_types = ALPHA_NODES[self.job_name]
color_list = get_value_list_from_node_types(
mat_out, 'Color', node_types)
if len(color_list) >= 1:
self.new_node_colors[self.job_name] = color_list[0]
示例13: set_awhite_flavor
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def set_awhite_flavor(node_tree, switch_on):
"""Set alpha white flavor to this shader.
:param node_tree: node tree of current shader
:type node_tree: bpy.types.NodeTree
:param switch_on: flag indication if alpha white flavor should be switched on or off
:type switch_on: bool
"""
if switch_on:
out_shader_node = node_tree.nodes[UnlitVcolTex.OUT_SHADER_NODE]
from_mix_factor = node_tree.nodes[UnlitVcolTex.OPACITY_NODE].outputs[0]
from_color_socket = node_tree.nodes[UnlitVcolTex.TEX_MULT_NODE].outputs[0]
# remove link to transparency as awhite sets alpha to 1
if out_shader_node.inputs['Transparency'].links:
node_tree.links.remove(out_shader_node.inputs['Transparency'].links[0])
location = (out_shader_node.location.x - 185, out_shader_node.location.y)
awhite.init(node_tree, location, from_mix_factor, from_color_socket, out_shader_node.inputs['Emissive Color'])
else:
awhite.delete(node_tree)
示例14: set_paint_flavor
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def set_paint_flavor(node_tree, switch_on):
"""Set paint flavor to this shader.
:param node_tree: node tree of current shader
:type node_tree: bpy.types.NodeTree
:param switch_on: flag indication if flavor should be switched on or off
:type switch_on: bool
"""
diff_col_n = node_tree.nodes[UnlitVcolTex.DIFF_COL_NODE]
diff_mult_n = node_tree.nodes[UnlitVcolTex.DIFF_MULT_NODE]
if switch_on:
for node in node_tree.nodes:
if node.location.x > diff_col_n.location.x:
node.location.x += 185
location = (diff_mult_n.location.x - 185 * 2, diff_mult_n.location.y + 50)
paint.init(node_tree, location, diff_col_n.outputs["Color"], diff_mult_n.inputs[0])
else:
paint.delete(node_tree)
示例15: set_paint_flavor
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Color [as 别名]
def set_paint_flavor(node_tree, switch_on):
"""Set paint flavor to this shader.
:param node_tree: node tree of current shader
:type node_tree: bpy.types.NodeTree
:param switch_on: flag indication if flavor should be switched on or off
:type switch_on: bool
"""
diff_col_n = node_tree.nodes[UnlitTex.DIFF_COL_NODE]
diff_mult_n = node_tree.nodes[UnlitTex.TEX_MULT_NODE]
if switch_on:
for node in node_tree.nodes:
if node.location.x > diff_col_n.location.x:
node.location.x += 185
location = (diff_mult_n.location.x - 185, diff_mult_n.location.y + 50)
paint.init(node_tree, location, diff_col_n.outputs["Color"], diff_mult_n.inputs[0])
else:
paint.delete(node_tree)