如何在 Squish 中使用鼠标按下和鼠标释放或鼠标拖动来绘制矩形、椭圆、圆形和多边形。
问问题
118 次
1 回答
1
您可以使用函数 和 来做到mousePress
这mouseMove
一点mouseRelease
。
您可以将所有这些形状描述为一系列点,例如顺时针。因此,位置 150/200 的 300 像素宽和 100 像素高的矩形可以描述为
rectangle = [(150,200), (450,200), (450,300), (150, 300)]
然后,您可以将此点列表提供给绘制形状的通用函数“drawShape”左右,就像这样(在 Python 中,但同样的事情可以在 Squish 支持的任何其他脚本语言中完成):
def drawShape(shape):
firstPoint = shape[0]
# Press mouse button at first position
mousePress(firstPoint[0], firstPoint[1], MouseButton.PrimaryButton)
# Call mouseMove repeatedly for all subsequent positions
for x in range(1, len(shape)):
mouseMove(shape[x][0], shape[x][1])
# Close the shape by connecting last with the first position
mouseMove(firstPoint[0], firstPoint[1])
# Release mouse button to finish drawing
mouseRelease()
于 2016-07-18T13:02:40.533 回答