Created
January 2, 2012 12:03
-
-
Save tamask/1550438 to your computer and use it in GitHub Desktop.
Adjust Vertex Colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
bl_info = { | |
'name': 'Adjust Vertex Colors', | |
'author': 'Tamas Kemenczy', | |
'version': (0, 1), | |
'blender': (2, 6, 1), | |
'location': 'View3D > Specials > Adjust Vertex Colors', | |
'description': 'HSV vertex color adjustment of the selected faces', | |
'category': 'Mesh' | |
} | |
def adjust_vertex_colors(obj, h, s, v): | |
for index, face in enumerate(obj.data.vertex_colors.active.data): | |
if obj.data.faces[index].select: | |
face.color1.h += h | |
face.color1.s += s | |
face.color1.v += v | |
face.color2.h += h | |
face.color2.s += s | |
face.color2.v += v | |
face.color3.h += h | |
face.color3.s += s | |
face.color3.v += v | |
face.color4.h += h | |
face.color4.s += s | |
face.color4.v += v | |
class AdjustVertexColors(bpy.types.Operator): | |
bl_idname = 'mesh.adjust_vertex_colors' | |
bl_label = 'Adjust Vertex Colors' | |
bl_options = {'REGISTER', 'UNDO'} | |
h = bpy.props.FloatProperty(name='Hue', min=-1, max=1, step=1) | |
s = bpy.props.FloatProperty(name='Saturation', min=-1, max=1, step=1) | |
v = bpy.props.FloatProperty(name='Value', min=-1, max=1, step=1) | |
@classmethod | |
def poll(cls, context): | |
obj = context.active_object | |
return (obj and obj.type == 'MESH') | |
def execute(self, context): | |
adjust_vertex_colors(context.active_object, self.h, self.s, self.v) | |
return {'FINISHED'} | |
def menu_func(self, context): | |
self.layout.operator(AdjustVertexColors.bl_idname, text='Adjust Vertex Colors') | |
def register(): | |
bpy.utils.register_module(__name__) | |
bpy.types.VIEW3D_MT_object_specials.append(menu_func) | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
bpy.types.VIEW3D_MT_object_specials.remove(menu_func) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment