本文整理汇总了Python中util.Util.scalePoints方法的典型用法代码示例。如果您正苦于以下问题:Python Util.scalePoints方法的具体用法?Python Util.scalePoints怎么用?Python Util.scalePoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.scalePoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initShape
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import scalePoints [as 别名]
def initShape(self):
# Made using BeTravis's excellent path-to-polygon tool
# http://betravis.github.io/shape-tools/path-to-polygon/
shapeString = '47.875 10.129, 47.091 10.429, 50.038 13.703, 51.508 16.329, 50.622 17.315, 35.019 21.192, 31.619 22.820, 26.750 27.628, 9.999 16.438, 3.670 14.198, 5.491 18.014, 7.677 19.216, 9.654 23.058, 8.750 34.379, 9.609 43.981, 8.486 49.628, 4.375 54.754, 3.142 55.663, 3.120 55.721, 3.204 55.742, 6.110 55.203, 12.442 51.855, 28.750 40.171, 31.258 42.745, 35.508 45.604, 46.636 52.190, 59.583 55.003, 70.905 54.847, 86.508 50.575, 94.915 47.442, 96.631 45.867, 95.752 45.172, 96.072 43.403, 95.389 38.601, 92.417 42.275, 91.407 42.932, 82.636 40.559, 74.775 34.371, 71.972 29.398, 84.053 31.841, 91.164 30.089, 91.912 32.935, 92.397 32.478, 93.725 30.148, 95.227 29.860, 95.796 29.545, 91.717 24.247, 89.413 23.425, 89.065 22.176, 87.670 21.576, 76.305 19.670, 74.395 18.987, 62.815 12.896, 53.604 10.500, 47.875 10.129, 47.875 10.129'
baseShape = Util.shapeFromString(shapeString)
maxX = max(baseShape, key= lambda d: d.x).x
maxY = max(baseShape, key= lambda d: d.y).y
minX = min(baseShape, key= lambda d: d.x).x
minY = min(baseShape, key= lambda d: d.y).y
w = maxX - minX
h = maxY - minY
aspect = h/w
desiredWidth = 3
desiredHeight = aspect * desiredWidth
# Reset to zero
Util.translatePoints(baseShape, x=-minX, y = -minY)
# Scale to height/width
Util.scalePoints(baseShape, x = desiredWidth/w, y = desiredHeight/h)
# Set center point to mid-head
Util.translatePoints(baseShape, x=desiredWidth * -0.9, y=-desiredHeight/2)
self.baseFishShape = baseShape
示例2: initShape
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import scalePoints [as 别名]
def initShape(self):
# Made the string using BeTravis's excellent path-to-polygon tool
# http://betravis.github.io/shape-tools/path-to-polygon/
simplifiedStr = '60.893 10.414, 24.234 27.027, 0.500 1.280, 0.500 71.728, 23.768 46.486, 60.893 63.900, 88.899 56.066, 100.500 37.159, 88.898 18.250, 60.893 10.414, 60.893 10.414'
baseShape = Util.shapeFromString(simplifiedStr)
maxX = max(baseShape, key= lambda d: d.x).x
maxY = max(baseShape, key= lambda d: d.y).y
minX = min(baseShape, key= lambda d: d.x).x
minY = min(baseShape, key= lambda d: d.y).y
w = maxX - minX
h = maxY - minY
desiredWidth = 3
desiredHeight = 2
# Reset to zero
Util.translatePoints(baseShape, x=-minX, y = -minY)
# Scale to height/width
Util.scalePoints(baseShape, x = desiredWidth/w, y = desiredHeight/h)
# Set center point to mid-taixl
# Util.translatePoints(baseShape, x=desiredWidth * -0.6, y=-desiredHeight/2)
# Set center point to mid-head
Util.translatePoints(baseShape, x=desiredWidth * -0.8, y=-desiredHeight/2)
self.baseFishShape = baseShape
示例3: fishShapeForScale
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import scalePoints [as 别名]
def fishShapeForScale(self, scale = 1):
baseShape = deepcopy(self.baseFishShape)
points = Util.scalePoints(baseShape, scale, scale)
return points