本文整理汇总了Python中shape.Shape.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.getHeight方法的具体用法?Python Shape.getHeight怎么用?Python Shape.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.getHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _placeOutlineDimensions
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import getHeight [as 别名]
def _placeOutlineDimensions(self):
"""
Places outline dimension arrows
"""
def makeArrow(width, gap):
"""
Returns a path for an arrow of width 'width' with a center gap of
width 'gap'
"""
# Length of bar perpendicular to the arrow's shaft
base_length = 1.8
# Height of arrow's head
arrow_height = 2.5
# Width of arrow's head
arrow_base = 1.2
# Create path
path = "m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s" % (-gap/2,0, -width/2+gap/2,0, 0,base_length/2, 0,-base_length, arrow_height,(base_length-arrow_base)/2, -arrow_height,arrow_base/2, arrow_height,arrow_base/2, -arrow_height,-arrow_base/2, width/2,0, gap/2,0, width/2-gap/2,0, 0,base_length/2, 0,-base_length, -arrow_height,(base_length-arrow_base)/2, arrow_height,arrow_base/2, -arrow_height,arrow_base/2, arrow_height,-arrow_base/2,)
return path
# Create text shapes
shape_dict = {}
shape_dict['type'] = 'text'
style_dict = config.stl['layout']['dimensions'].get('text') or {}
shape_dict['font-family'] = style_dict.get('font-family') or "UbuntuMono-R-webfont"
shape_dict['font-size'] = style_dict.get('font-size') or "1.5mm"
shape_dict['line-height'] = style_dict.get('line-height') or "1mm"
shape_dict['letter-spacing'] = style_dict.get('letter-spacing') or "0mm"
# Locations
arrow_gap = 1.5
width_loc = [0, self._height/2+arrow_gap]
height_loc = [-(self._width/2+arrow_gap), 0]
# Width text
width_text_dict = shape_dict.copy()
width_text_dict['value'] = "%s mm" % round(self._width,2)
width_text_dict['location'] = width_loc
width_text = Shape(width_text_dict)
style = Style(width_text_dict, 'dimensions')
width_text.setStyle(style)
# Height text
height_text_dict = shape_dict.copy()
height_text_dict['value'] = "%s mm" % round(self._height,2)
height_text_dict['rotate'] = -90
height_text_dict['location'] = height_loc
height_text = Shape(height_text_dict)
style = Style(height_text_dict, 'dimensions')
height_text.setStyle(style)
# Width arrow
shape_dict = {}
shape_dict['type'] = 'path'
shape_dict['value'] = makeArrow(self._width, width_text.getWidth()*1.2)
shape_dict['location'] = width_loc
width_arrow = Shape(shape_dict)
style = Style(shape_dict, 'dimensions')
width_arrow.setStyle(style)
# Height arrow
shape_dict = {}
shape_dict['type'] = 'path'
shape_dict['value'] = makeArrow(self._height, height_text.getHeight()*1.2)
shape_dict['rotate'] = -90
shape_dict['location'] = height_loc
height_arrow = Shape(shape_dict)
style = Style(shape_dict, 'dimensions')
height_arrow.setStyle(style)
svg_layer = self._layers['dimensions']['layer']
group = et.SubElement(svg_layer, 'g')
group.set('{'+config.cfg['ns']['pcbmode']+'}type', 'module-shapes')
place.placeShape(width_text, group)
place.placeShape(height_text, group)
place.placeShape(width_arrow, group)
place.placeShape(height_arrow, group)