本文整理汇总了Python中control.Control.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Control.draw方法的具体用法?Python Control.draw怎么用?Python Control.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类control.Control
的用法示例。
在下文中一共展示了Control.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from control import Control [as 别名]
# 或者: from control.Control import draw [as 别名]
class Handler:
"""This class represents a rectangular control points handler"""
def __init__(self):
self.control = list()
self.can_pivot = True
self.center_pivot = False
self.pivot = Control()
self.pivot.pivot = True
self.line = False
self.is_testing = False
index = 0
while index < ANONIMOUS:
control = Control()
self.control.append(control)
index += 1
def draw_handler(self, context):
if not self.line:
context.set_antialias(cairo.ANTIALIAS_NONE)
context.set_line_width(1.0 / context.get_matrix()[0])
context.set_source_rgb(0.5, 0.5, 1.0)
dash = []
context.set_dash(dash)
context.rectangle(self.x, self.y, self.width, self.height)
context.stroke()
context.set_antialias(cairo.ANTIALIAS_DEFAULT)
def draw_controls(self, context):
for control in self.control:
control.draw(context)
def draw_pivot(self, context):
self.pivot.draw(context)
def draw(self, context):
self.draw_handler(context)
self.draw_controls(context)
if self.can_pivot:
self.draw_pivot(context)
def at_position(self, x, y):
return self.get_direction(x, y) is not NONE
def get_direction(self, x, y):
for direction, control in enumerate(self.control):
if control.at_position(x, y):
return direction
return NONE