本文整理匯總了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