render.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:iutils 作者: inconvergent 项目源码 文件源码
def sandstroke_non_linear(self,xys,grains=10,left=True):

    pix = self.pix
    rectangle = self.ctx.rectangle
    fill = self.ctx.fill

    dx = xys[:,2] - xys[:,0]
    dy = xys[:,3] - xys[:,1]

    aa = arctan2(dy,dx)
    directions = column_stack([cos(aa),sin(aa)])

    dd = sqrt(square(dx)+square(dy))

    for i,d in enumerate(dd):
      rnd = sqrt(random((grains,1)))
      if left:
        rnd = 1.0-rnd

      for x,y in xys[i,:2] + directions[i,:]*rnd*d:
        rectangle(x,y,pix,pix)
        fill()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号