当前位置: 首页>>代码示例>>Python>>正文


Python PathPatch.set_transform方法代码示例

本文整理汇总了Python中matplotlib.patches.PathPatch.set_transform方法的典型用法代码示例。如果您正苦于以下问题:Python PathPatch.set_transform方法的具体用法?Python PathPatch.set_transform怎么用?Python PathPatch.set_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.patches.PathPatch的用法示例。


在下文中一共展示了PathPatch.set_transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addAndGetGliderIcon

# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_transform [as 别名]
def addAndGetGliderIcon(ax, x, y, heading, roll, scale):
	roll_scale = abs(roll)
	if roll_scale > 90:
		roll_scale = 90
	roll_scale = abs(roll_scale-90)/90.

	if roll < 0:
		roll_side = 1 #left roll
	else:
		roll_side = -1 #right roll

	trans_mat = Affine2D()
	trans_mat.rotate_deg(90+heading2XY(heading))
	trans_mat.scale(scale)
	trans_mat.translate(x,y)

	glider_body = np.matrix([[-0.4, -9],[0, -9.8],[0.4, -9],[1.2, -7.5],[1.2, -6],[1.2, 3],[1.2, 8],[0, 17],[-1.2, 8],[-1.2, 3],[-1.2, -6],[-1.2, -7.5],[-0.4, -9]])
	glider_body_codes = [1, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2]
	glider_body_path = Path(glider_body, glider_body_codes)
	glider_body_patch = PathPatch(glider_body_path, facecolor=(0.7, 0.7, 0.7), edgecolor=(0.2, 0.2, 0.45))
	glider_body_patch.set_transform(trans_mat + ax.transData)

	move = (1-roll_scale)*roll_side

	if roll_side < 0:
		leftw_bp = [roll_scale*27.2, -3+5*-move]
		leftw_fp1 = [roll_scale*26.2, -5+2*-move]
		leftw_fp2 = [roll_scale*27.2, -5+2*-move]
		color = (0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale))
	else:
		leftw_bp = [roll_scale*27.2, -3+1.5*move]
		leftw_fp1 = [roll_scale*26.2, -5+3*move]
		leftw_fp2 = [roll_scale*27.2, -5+3*move]
		color = (0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale))
	leftw_tran = [-1*(1-roll_scale), 0] 
	glider_leftw = np.matrix([[1.2, -3],[2.2, -3],leftw_fp1,leftw_fp2,leftw_bp,[3.2, 1],[2.2, 1],[1.2, 2],[1.2, -3]])
	glider_leftw[:,0] = glider_leftw[:,0] + leftw_tran[0]
	glider_leftw_codes = [1, 2, 2, 3, 2, 2, 3, 2, 2]
	glider_leftw_path = Path(glider_leftw, glider_leftw_codes)
	glider_leftw_patch = PathPatch(glider_leftw_path, facecolor=color, edgecolor=(0.2, 0.2, 0.45))
	glider_leftw_patch.set_transform(trans_mat + ax.transData)

	if roll_side > 0:
		rightw_bp = [roll_scale*-27.2, -3+5*move]
		rightw_fp1 = [roll_scale*-26.2, -5+2*move]
		rightw_fp2 = [roll_scale*-27.2, -5+2*move]
		color = (0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale))
	else:
		rightw_bp = [roll_scale*-27.2, -3+1.5*-move]
		rightw_fp1 = [roll_scale*-26.2, -5+3*-move]
		rightw_fp2 = [roll_scale*-27.2, -5+3*-move]
		color = (0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale))
	rightw_tran = [1*(1-roll_scale), 0] 
	glider_rightw = np.matrix([[-1.2, -3],[-2.2, -3],rightw_fp1,rightw_fp2,rightw_bp,[-3.2, 1],[-2.2, 1],[-1.2, 2],[-1.2, -3]])
	glider_rightw[:,0] = glider_rightw[:,0] + rightw_tran[0]
	glider_rightw_codes = [1, 2, 2, 3, 2, 2, 3, 2, 2]
	glider_rightw_path = Path(glider_rightw, glider_rightw_codes)
	glider_rightw_patch = PathPatch(glider_rightw_path, facecolor=color, edgecolor=(0.2, 0.2, 0.45))
	glider_rightw_patch.set_transform(trans_mat + ax.transData)

	if roll_side < 0:
		leftt_bp = [roll_scale*5, 14.5+4*-move]
		leftt_fp = [roll_scale*5, 13+2*-move]
		color = (0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale))
		leftt_tran = [-0.7*(1-roll_scale), 0] 
	else:
		leftt_bp = [roll_scale*5, 14.5+1.5*move]
		leftt_fp = [roll_scale*5, 13+2*move]
		color = (0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale))
		leftt_tran = [0.7*(1-roll_scale), 0] 
	glider_leftt = np.matrix([[0, 12],leftt_fp,leftt_bp,[0.5, 15],[0.5, 14],[0, 14],[0, 12]])
	glider_leftt[:,0] = glider_leftt[:,0] + leftt_tran[0]
	glider_leftt_codes = [1, 2, 2, 2, 3, 2, 2]
	glider_leftt_path = Path(glider_leftt, glider_leftt_codes)
	glider_leftt_patch = PathPatch(glider_leftt_path, facecolor=color, edgecolor=(0.2, 0.2, 0.45))
	glider_leftt_patch.set_transform(trans_mat + ax.transData)

	if roll_side > 0:
		rightt_bp = [roll_scale*-5, 14.5+4*move]
		rightt_fp = [roll_scale*-5, 13+2*move]
		color = (0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale), 0.7-0.3*(1-roll_scale))
		rightt_tran = [0.7*(1-roll_scale), 0] 
	else:
		rightt_bp = [roll_scale*-5, 14.5+1.5*-move]
		rightt_fp = [roll_scale*-5, 13+2*-move]
		color = (0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale), 0.7+0.3*(1-roll_scale))
		rightt_tran = [-0.7*(1-roll_scale), 0] 
	glider_rightt = np.matrix([[0, 12],rightt_fp,rightt_bp,[-0.5, 15],[-0.5, 14],[0, 14],[0, 12]])
	glider_rightt[:,0] = glider_rightt[:,0] + rightt_tran[0]
	glider_rightt_codes = [1, 2, 2, 2, 3, 2, 2]
	glider_rightt_path = Path(glider_rightt, glider_rightt_codes)
	glider_rightt_patch = PathPatch(glider_rightt_path, facecolor=color, edgecolor=(0.2, 0.2, 0.45))
	glider_rightt_patch.set_transform(trans_mat + ax.transData)

	if roll_side > 0:
		right_vpf = [-1.2*roll_scale, -6]
		right_vpb = [-1.2*roll_scale, -1.5]
		left_vpf = [1.2, -6]
		left_vpb = [1.2, -1.5]
	else:
#.........这里部分代码省略.........
开发者ID:dehann,项目名称:ThermalSoaring,代码行数:103,代码来源:glider_icon.py

示例2: generate_cell

# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_transform [as 别名]
  def generate_cell(self,x,y,tpts,template,halfAngle,r,ba):

    for k,v in enumerate(template):

      # even-even black cell
      vcp = copy.copy(v)
      if   (type(v)==Wedge):
        vcp.set_center((tpts[k][0]+x,tpts[k][1]+y))
      elif (type(v)==Rectangle):
        vcp.set_xy((tpts[k][0]+x,tpts[k][1]+y))

      self.ax.add_patch(vcp)
      vcp.set_transform(self.rotation)

      # do clipping
      if   (type(v)==Wedge):

        sin0 = math.sin(math.radians(halfAngle))
        cos0 = math.cos(math.radians(halfAngle))

        if ba[k]==0:
          w0 = r - r*cos0
          h0 = 2*r*sin0
          x0 = tpts[k][0] + r - w0
          y0 = tpts[k][1] - h0/2
        if ba[k]==180:
          w0 = r - r*cos0
          h0 = 2*r*sin0
          x0 = tpts[k][0] - r
          y0 = tpts[k][1] - h0/2
        if ba[k]==270:
          w0 = 2*r*sin0
          h0 = r - r*cos0
          x0 = tpts[k][0] - w0/2
          y0 = tpts[k][1] - r
        if ba[k]==90:
          w0 = 2*r*sin0
          h0 = r - r*cos0
          x0 = tpts[k][0] - w0/2
          y0 = tpts[k][1] + r - h0


        # correction, so the shadow line from Rectange is not seen
        if ba[k]==0:
          x0 -= w0
          w0 *= 2
        if ba[k]==180:
          w0 *= 2
        if ba[k]==270:
          h0 *= 2
        if ba[k]==90:
          y0 -= h0
          h0 *= 2

        cp = Rectangle((x0,y0),w0,h0,**self.opts_w, lw=0)
        vcp2 = copy.copy(cp)

        xy = vcp2.get_xy()
        vcp2.set_xy((xy[0]+x,xy[1]+y))
        path = vcp2.get_path()
        transform = vcp2.get_transform()
        path = transform.transform_path(path)
        vcp2 = PathPatch(path, fc='none', ec='none', lw=0)
        self.ax.add_patch(vcp2)
        # rotate here
        vcp2.set_transform(self.rotation)

        vcp.set_clip_path(vcp2)
开发者ID:Elphel,项目名称:imagej-elphel,代码行数:70,代码来源:escher_pattern_class.py


注:本文中的matplotlib.patches.PathPatch.set_transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。