项目中需要实现一条线条的滑动效果,发现弧线滑动时锯齿太严重。在PixiJS有自带的抗锯齿的参数,但是在使用时感觉效果并不是很好。参照http://pixijs.download/release/docs/PIXI.Application.html
html
<canvas width="300" height="300"></canvas>
js
var c = document.getElementsByTagName('canvas')[0]
var width = c.width
var height = c.height
var devicePixelRatio = 1
if (window.devicePixelRatio) {
devicePixelRatio = window.devicePixelRatio
c.style.width = width + 'px'
c.style.height = height + 'px'
c.width = width * window.devicePixelRatio
c.height = height * window.devicePixelRatio
}
var app = new PIXI.Application({width: width * devicePixelRatio, height: height * devicePixelRatio, transparent : true,resolution: 1, view: c})
document.body.appendChild(app.view)
var circle = new PIXI.Graphics()
circle.beginFill(0xFFFF0B, 0.5)
circle.drawCircle(150, 150, 60) //绘制圆
circle.endFill()
circle.scale = {
x: devicePixelRatio,
y: devicePixelRatio
}
app.stage.addChild(circle)
本文探讨了在PixiJS项目中遇到的弧线滑动锯齿严重的问题。文章提到,虽然PixiJS提供了内置的抗锯齿选项,但在实际应用中效果不尽如人意。作者通过研究PixiJS的文档,分享了解决这个问题的方法和经验。
963

被折叠的 条评论
为什么被折叠?



