本文整理匯總了Python中radialnet.core.Coordinate.PolarCoordinate.to_cartesian方法的典型用法代碼示例。如果您正苦於以下問題:Python PolarCoordinate.to_cartesian方法的具體用法?Python PolarCoordinate.to_cartesian怎麽用?Python PolarCoordinate.to_cartesian使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類radialnet.core.Coordinate.PolarCoordinate
的用法示例。
在下文中一共展示了PolarCoordinate.to_cartesian方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __move_is_clicked
# 需要導入模塊: from radialnet.core.Coordinate import PolarCoordinate [as 別名]
# 或者: from radialnet.core.Coordinate.PolarCoordinate import to_cartesian [as 別名]
def __move_is_clicked(self, pointer):
"""
"""
xc, yc = self.__center_of_widget
pc = PolarCoordinate()
for i in range(8):
pc.set_coordinate(23, 45 * i)
x, y = pc.to_cartesian()
center = (xc + x, yc - y)
if geometry.is_in_circle(pointer, self.__move_radius, center):
return i
return None
示例2: __draw_move_control
# 需要導入模塊: from radialnet.core.Coordinate import PolarCoordinate [as 別名]
# 或者: from radialnet.core.Coordinate.PolarCoordinate import to_cartesian [as 別名]
def __draw_move_control(self):
"""
"""
xc, yc = self.__center_of_widget
pc = PolarCoordinate()
self.context.set_dash([1, 1])
self.context.arc(xc, yc, 23, 0, 2 * math.pi)
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
self.context.stroke()
for i in range(8):
pc.set_coordinate(23, 45 * i)
x, y = pc.to_cartesian()
self.context.set_dash([1, 1])
self.context.move_to(xc, yc)
self.context.line_to(xc + x, yc - y)
self.context.stroke()
self.context.set_dash([1, 0])
self.context.arc(
xc + x, yc - y, self.__move_radius, 0, 2 * math.pi)
if i == self.__moving:
self.context.set_source_rgb(0.0, 0.0, 0.0)
else:
self.context.set_source_rgb(1.0, 1.0, 1.0)
self.context.fill_preserve()
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
self.context.stroke()
self.context.arc(xc, yc, 6, 0, 2 * math.pi)
if self.__centering:
self.context.set_source_rgb(0.0, 0.0, 0.0)
else:
self.context.set_source_rgb(1.0, 1.0, 1.0)
self.context.fill_preserve()
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
self.context.stroke()
return False
示例3: ControlNavigation
# 需要導入模塊: from radialnet.core.Coordinate import PolarCoordinate [as 別名]
# 或者: from radialnet.core.Coordinate.PolarCoordinate import to_cartesian [as 別名]
#.........這裏部分代碼省略.........
if t < 0:
t = 360 + t
self.radialnet.set_rotation(t)
self.__rotate_node.set_coordinate(r, t)
self.queue_draw()
return False
def expose(self, widget, event):
"""
Drawing callback
@type widget: GtkWidget
@param widget: Gtk widget superclass
@type event: GtkEvent
@param event: Gtk event of widget
@rtype: boolean
@return: Indicator of the event propagation
"""
self.set_size_request(120, 130)
self.context = widget.window.cairo_create()
self.__draw()
return False
def __draw_rotate_control(self):
"""
"""
xc, yc = self.__center_of_widget
r, t = self.__rotate_node.get_coordinate()
x, y = self.__rotate_node.to_cartesian()
# draw text
self.context.set_font_size(10)
self.context.move_to(xc - 49, yc - 48)
self.context.show_text(_("Navigation"))
width = self.context.text_extents(str(int(t)))[2]
self.context.move_to(xc + 49 - width - 2, yc - 48)
self.context.show_text(str(round(t, 1)))
self.context.set_line_width(1)
self.context.stroke()
# draw arc
self.context.set_dash([1, 2])
self.context.arc(xc, yc, 40, 0, 2 * math.pi)
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
self.context.stroke()
# draw node
self.context.set_dash([1, 0])
self.context.arc(xc + x, yc - y, self.__rotate_radius, 0, 2 * math.pi)
if self.__rotating:
self.context.set_source_rgb(0.0, 0.0, 0.0)
else:
self.context.set_source_rgb(1.0, 1.0, 1.0)
self.context.fill_preserve()
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)