limit corner radius

This commit is contained in:
lavrton 2015-01-22 15:46:53 +07:00
parent eba941e1c3
commit 4dfc65dba4
5 changed files with 45 additions and 17 deletions

View File

@ -1,3 +1,10 @@
## 5.2.1
* Bug Fixes
* Enhancements
* `cornerRadius` of Rect is limited by `width/2` and `height/2`
## 5.2.0 2014-01-22 ## 5.2.0 2014-01-22
* Bug Fixes * Bug Fixes

View File

@ -1,10 +1,10 @@
{ {
"name": "KineticJS", "name": "KineticJS",
"version": "5.2.0", "version": "5.1.10",
"homepage": "http://kineticjs.com/",
"authors": [ "authors": [
"Eric Rowell", "Anton Lavrenov" "Eric Rowell", "Anton Lavrenov"
], ],
"homepage": "http://lavrton.github.io/KineticJS/",
"description": "KineticJS is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.", "description": "KineticJS is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.",
"keywords": [ "keywords": [
"canvas", "canvas",
@ -16,17 +16,14 @@
"ignore": [ "ignore": [
"**/.*", "**/.*",
"test", "test",
"tests", "resources",
"doc-includes",
"src", "src",
"*.yml", "*.yml",
".jshitrc", ".jshitrc",
".npmignore", ".npmignore",
".travis.yml",
".gitignore", ".gitignore",
"Gruntfile.js", "Gruntfile.js"
"bower-template.json",
"server.js",
"presentation-schedule.md"
], ],
"main": "kinetic.js" "main": "kinetic.min.js"
} }

View File

@ -1,10 +1,10 @@
{ {
"name": "KineticJS", "name": "KineticJS",
"version": "@@version", "version": "@@version",
"homepage": "http://kineticjs.com/",
"authors": [ "authors": [
"Eric Rowell", "Anton Lavrenov" "Eric Rowell", "Anton Lavrenov"
], ],
"homepage": "http://lavrton.github.io/KineticJS/",
"description": "KineticJS is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.", "description": "KineticJS is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.",
"keywords": [ "keywords": [
"canvas", "canvas",
@ -16,17 +16,14 @@
"ignore": [ "ignore": [
"**/.*", "**/.*",
"test", "test",
"tests", "resources",
"doc-includes",
"src", "src",
"*.yml", "*.yml",
".jshitrc", ".jshitrc",
".npmignore", ".npmignore",
".travis.yml",
".gitignore", ".gitignore",
"Gruntfile.js", "Gruntfile.js"
"bower-template.json",
"server.js",
"presentation-schedule.md"
], ],
"main": "kinetic.js" "main": "kinetic.min.js"
} }

View File

@ -41,6 +41,7 @@
} }
else { else {
// arcTo would be nicer, but browser support is patchy (Opera) // arcTo would be nicer, but browser support is patchy (Opera)
cornerRadius = Math.min(cornerRadius, width / 2, height / 2);
context.moveTo(cornerRadius, 0); context.moveTo(cornerRadius, 0);
context.lineTo(width - cornerRadius, 0); context.lineTo(width - cornerRadius, 0);
context.arc(width - cornerRadius, cornerRadius, cornerRadius, Math.PI * 3 / 2, 0, false); context.arc(width - cornerRadius, cornerRadius, cornerRadius, Math.PI * 3 / 2, 0, false);

View File

@ -178,4 +178,30 @@ suite('Rect', function(){
compareLayerAndCanvas(layer, canvas); compareLayerAndCanvas(layer, canvas);
}); });
// ======================================================
test('limit corner radius', function() {
var stage = addStage();
var layer = new Kinetic.Layer();
var rect = new Kinetic.Rect({
x: 50,
y: 50,
width: 100,
height: 100,
fill: 'black',
cornerRadius : 100
});
layer.add(rect);
stage.add(layer);
// as corner radius is much bigger we should have circe in the result
var canvas = createCanvas();
var context = canvas.getContext('2d');
context.beginPath();
context.arc(100, 100, 50, 0, Math.PI * 2);
context.fillStyle = 'black';
context.fill();
compareLayerAndCanvas(layer, canvas);
});
}); });