[英]kinetic js, how can I improve resolution of elements
I am new to use kinetic js, and I think that it is so good library, the problem is the resolution of the elements, I know that kinetic js doesn't use svg, but the resolution is horrible, I am creating circles and sample shape with animations, but these look like poor images and I don't want that. 我是使用动力学js的新手,我认为它是如此出色的库,问题是元素的分辨率,我知道动力学js不使用svg,但是分辨率很糟糕,我正在创建圆圈和示例动画的形状,但是这些看起来像是差劲的图像,我不想要那样。 Somebody know a solution or definitely it is impossible to change the resolution ?
有人知道解决方案,或者绝对不可能更改分辨率?
For example I create the elements like this: 例如,我创建这样的元素:
var circle = new Kinetic.Circle({
x: this.stage.getWidth() / 2,
y: this.stage.getHeight() / 2 + 10,
radius: radius,
fill: 'red',
stroke: 'black',
strokeWidth: 2,
draggable: true
});
Can you post an example? 你能举个例子吗?
It's possible that your animation is trying to draw frames faster than they can be properly rendered--causing ghosts/blurs. 您的动画可能试图以比正确渲染更快的速度绘制帧-导致重影/模糊。 If you throttle down your framerate, is the "horribleness" reduced?
如果降低帧速率,“恐怖性”是否降低了?
These static shape results between KineticJS, native-Canvas and SVG look the same to me. KineticJS,native-Canvas和SVG之间的这些静态形状结果对我来说看起来是相同的。
Here's code and a Fiddle: http://jsfiddle.net/m1erickson/pgBv4/ 这是代码和小提琴: http : //jsfiddle.net/m1erickson/pgBv4/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prototype</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.5.1.min.js"></script>
<style>
#container{
border:solid 1px #ccc;
margin-top: 10px;
width:200px;
height:200px;
}
#canvas{ border:1px solid red; }
</style>
<script>
$(function(){
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
ctx.beginPath();
ctx.arc(100,100,75,0,Math.PI*2,false);
ctx.closePath();
ctx.fillStyle="red";
ctx.strokeStyle="black";
ctx.lineWidth=2;
ctx.fill();
ctx.stroke();
var stage = new Kinetic.Stage({
container: 'container',
width: 200,
height: 200
});
var layer = new Kinetic.Layer();
stage.add(layer);
var circle = new Kinetic.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2 + 10,
radius: 75,
fill: 'red',
stroke: 'black',
strokeWidth: 2,
draggable: true
});
layer.add(circle);
layer.draw();
}); // end $(function(){});
</script>
</head>
<body>
<div id="container"></div>
<canvas id="canvas" width=200 height=200></canvas>
<svg width="200" height="200">
<circle x="100" y="100" r="75" fill="red" stroke="black" stroke-width="2" />
</svg>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.