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

背景设置为透明时会有重影,请问怎么解决? #4

Open
daidi opened this issue Jul 24, 2018 · 3 comments
Open

背景设置为透明时会有重影,请问怎么解决? #4

daidi opened this issue Jul 24, 2018 · 3 comments

Comments

@daidi
Copy link

daidi commented Jul 24, 2018

bgColor设置为透明,拖动图片时会重影

@xiaosu95
Copy link
Owner

我不知道你为什么设置设置透明,如果你只是想输出的时候背景透明的话,在输出那里的bgColor设置透明就好了,在把输出类型设置为png,就可以输出透明背景了。至于你想在拖拽的时候设置透明这是不合理的,因为你设置透明了,怎么去重绘canvas呢。

@daidi
Copy link
Author

daidi commented Jul 25, 2018

留个联系方式交流可以么
我们想做的有个麻烦的地方,是哪个可拖动的图片只允许在背景图中的一个指定区域内的部分才展示,这种要怎么实现?谢谢

@xiaosu95
Copy link
Owner

xiaosu95 commented Jul 25, 2018

你可以利用canvas渲染图片的切片https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/drawImage。
根据你限制的位置计算图片裁剪的范围再渲染进去,就可以达到你要的效果了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants