Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在安卓手机:小米 5s,系统 MIUI 9.6 | 稳定版,微信版本 6.6.6,Sprite 设置 borderRadius 属性,界面裁剪错 #9

Open
520ph opened this issue Sep 12, 2018 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@520ph
Copy link

520ph commented Sep 12, 2018

我使用网络图片,本地图片。或者 bgcolor 属性设置 Sprite。加上 borderRadius 就会裁剪错。在模拟器上没问题,暂时只在小米5s上遇到了。

21391536726070_ pic
21381536725945_ pic
21371536725943_ pic
21401536727915_ pic
21411536728643_ pic

测试代码

<template>
  <view>
    <canvas class="myCanvas" canvas-id="myCanvas" />
  </view>
</template>
<script>
import wepy from 'wepy';
const spritejs = require('../../utils/sprite-wxapp');
export default class GenerateImage extends wepy.page {
  config = {
    navigationBarTitleText: '一起燃烧卡路里',
    navigationBarBackgroundColor: '#FA4676'
  };
  data = {
    avatarUrl: 'https://wx.qlogo.cn/mmopen/vi_32/ZrA7SPMNXYibCdRlsTH0oYnfkv0fKx2FVxHfO7MsiaUubIHRtCTp0Ej2f98lvcWVh9wUXuaHAyepWCTYb2HIy8Ug/132'
  };
  methods = {};
  async onLoad() {
    let scene = new spritejs.Scene(0);
    let layer = scene.layer('myCanvas');
    let avatarUrl = await wepy.downloadFile({
      url: this.avatarUrl
    });
    // let avatar = new spritejs.Sprite(avatarUrl.tempFilePath);
    let avatar = new spritejs.Sprite();
    avatar.attr({
      anchor: [0],
      pos: [50, 100],
      size: [72, 72],
      bgcolor: 'red',
      borderRadius: 10
    });
    layer.append(avatar);
  }
}
</script>
<style lang="less">
page{
  background: #000;
}
.myCanvas {
  position: fixed;
  left: 0;
  top: 0;
  height: 1242px;
  width: 750px;
}
</style>
@akira-cn akira-cn added the help wanted Extra attention is needed label Sep 12, 2018
@akira-cn
Copy link
Contributor

某些版本下小程序canvas本身的bug,我现在没有机器测试。

https://github.com/spritejs/sprite-core/blob/master/src/helpers/render.js

这里的 drawRadiusBox

export function drawRadiusBox(context, {x, y, w, h, r}) {
  context.beginPath();
  context.moveTo(x + r, y);
  context.arcTo(x + w, y, x + w, y + h, r);
  context.arcTo(x + w, y + h, x, y + h, r);
  context.arcTo(x, y + h, x, y, r);
  context.arcTo(x, y, x + w, y, r);
  context.closePath();
}

可能最终显示出来的有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants