def set_color(self, cmap, color): self.tt.color = color self.picker = None self.save() tprop = self.actor.GetTextProperty() tprop.SetBackgroundColor(contrasting_color(*tprop.GetColor())) tprop.SetBackgroundOpacity(.85)
def __init__(self, interactor, label, dp, configurator): self.label = label self.display = dp super(LabelEditor, self).__init__(interactor, label, configurator) self.toolbar = vcs.vtk_ui.Toolbar( self.interactor, "%s Options" % label.member) template = vcs.gettemplate(dp.template) self.actor = get_actor(self.label, self.display) tprop = self.actor.GetTextProperty() self.real_bg = tprop.GetBackgroundColor() self.real_bg_opacity = tprop.GetBackgroundOpacity() tprop.SetBackgroundColor(contrasting_color(*tprop.GetColor())) tprop.SetBackgroundOpacity(.85) text_types_name = template.name + "_" + label.member try: self.tt = vcs.gettexttable(text_types_name) self.to = vcs.gettextorientation(text_types_name) except ValueError: self.tt = vcs.createtexttable(text_types_name, label.texttable) self.to = vcs.createtextorientation( text_types_name, label.textorientation) self.height_button = self.toolbar.add_slider_button( self.to.height, 1, 100, "Height", update=self.update_height) halign = self.toolbar.add_button( ["Left Align", "Center Align", "Right Align"], action=self.halign) valign = self.toolbar.add_button( ["Top Align", "Half Align", "Bottom Align"], action=self.valign) halign.set_state(self.to.halign) valign.set_state(__valign_map__[self.to.valign]) self.angle_button = self.toolbar.add_slider_button( self.to.angle, 0, 360, "Angle", update=self.update_angle) self.picker = None self.toolbar.add_button(["Change Color"], action=self.change_color) self.toolbar.show() self.label.texttable = self.tt.name self.label.textorientation = self.to.name
def __init__(self, interactor, label, dp, configurator): self.label = label self.display = dp super(LabelEditor, self).__init__(interactor, label, configurator) self.toolbar = vcs.vtk_ui.Toolbar(self.interactor, "%s Options" % label.member) template = vcs.gettemplate(dp.template) self.actor = get_actor(self.label, self.display) tprop = self.actor.GetTextProperty() self.real_bg = tprop.GetBackgroundColor() self.real_bg_opacity = tprop.GetBackgroundOpacity() tprop.SetBackgroundColor(contrasting_color(*tprop.GetColor())) tprop.SetBackgroundOpacity(.85) text_types_name = template.name + "_" + label.member try: self.tt = vcs.gettexttable(text_types_name) self.to = vcs.gettextorientation(text_types_name) except ValueError: self.tt = vcs.createtexttable(text_types_name, label.texttable) self.to = vcs.createtextorientation(text_types_name, label.textorientation) self.height_button = self.toolbar.add_slider_button( self.to.height, 1, 100, "Height", update=self.update_height) halign = self.toolbar.add_button( ["Left Align", "Center Align", "Right Align"], action=self.halign) valign = self.toolbar.add_button( ["Top Align", "Half Align", "Bottom Align"], action=self.valign) halign.set_state(self.to.halign) valign.set_state(__valign_map__[self.to.valign]) self.angle_button = self.toolbar.add_slider_button( self.to.angle, 0, 360, "Angle", update=self.update_angle) self.picker = None self.toolbar.add_button(["Change Color"], action=self.change_color) # Adds itself to self.toolbar automatically FontEditor(self.toolbar, self.set_font, current_font=vcs.getfontname(self.tt.font)) self.toolbar.show() self.label.texttable = self.tt.name self.label.textorientation = self.to.name
def test(fg): bg = contrasting_color(*fg) print "\tTesting", fg, "vs", bg return passes_w3c_contrast_ratio(fg, bg)