本文整理汇总了Python中Geometry.delta_y方法的典型用法代码示例。如果您正苦于以下问题:Python Geometry.delta_y方法的具体用法?Python Geometry.delta_y怎么用?Python Geometry.delta_y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry.delta_y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import delta_y [as 别名]
def draw(self, Canvas, line):
c_w = 10 / Canvas.Scale
c_h_long = 10 /Canvas.Scale
c_h_short = 3 / Canvas.Scale
point = self.pos
leftPoint = (point[0]-c_w, point[1])
rightPoint = (point[0]+c_w, point[1])
def rightCompressor(l_point, r_point):
upLeftPoint = (l_point[0], l_point[1]+c_h_long)
downLeftPoint = (l_point[0], l_point[1]-c_h_long)
upRightPoint = (r_point[0], r_point[1]+c_h_short)
downRightPoint = (r_point[0], r_point[1]-c_h_short)
return [upLeftPoint, downLeftPoint, downRightPoint, upRightPoint]
def leftCompressor(l_point, r_point):
upLeftPoint = (l_point[0], l_point[1]+c_h_short)
downLeftPoint = (l_point[0], l_point[1]-c_h_short)
upRightPoint = (r_point[0], r_point[1]+c_h_long)
downRightPoint = (r_point[0], r_point[1]- c_h_long)
return [upLeftPoint, downLeftPoint, downRightPoint, upRightPoint]
## find the change in x on the line to determine the
## direction of the edge
delta_x = Geom.delta_x(*line)
## get the angle that the line makes with the x-axis
theta = Geom.angleFromXaxis(line)
## if it's negative the direction in the x is right justified
if delta_x < 0:
## so we construct a right justified shape
compressor = rightCompressor(leftPoint, rightPoint)
## if it's positive the direction in the x is left justified
elif delta_x > 0:
## so we construct a left justified shape
compressor = leftCompressor(leftPoint, rightPoint)
## Uh Oh Vertical lines, now we have to think about the change in y
elif delta_x == 0:
## the change in y
delta_y = Geom.delta_y(*line)
## if it's positive then the direction in the y is up
if delta_y < 0:
## since we will ultimately be rotating 90 degrees
## for a vertical line pointing up
## we want the shape to be right justified
## (think about it)
compressor = rightCompressor(leftPoint, rightPoint)
##if it's negative then the direction in the y is down
elif delta_y > 0:
## and we construct a left justified shape
compressor = leftCompressor(leftPoint, rightPoint)
## if the delta y is also zero then our line is two of
## the same point and we have some bad input
## since this code is just for prototyping and fast development
## we will make due with a descriptive warning message printed
## to the console, and we'll make compressor right justified
## don't worry if this happens it will be obvious
else:
compressor = rightCompressor(leftPoint, rightPoint)
## and then we rotate it acordingly
compressor = Geom.rotatePointList(compressor, theta, point)
## finally we draw this darned thing to the Canvas
Canvas.AddPolygon(
compressor,
LineWidth=1,
LineColor="BLUE",
FillColor="BLUE",
)