mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 16:39:34 +00:00
Stroke ellipse fixes
- Circumference points should calculate point based on top left of ellipse - Graphics missing Ellipse class - Ellipse stroke not "closed"
This commit is contained in:
parent
195ea19ea7
commit
806c9d3237
2 changed files with 11 additions and 7 deletions
|
@ -7,6 +7,7 @@ var GameObject = require('../GameObject');
|
||||||
var GetValue = require('../../utils/object/GetValue');
|
var GetValue = require('../../utils/object/GetValue');
|
||||||
var MATH_CONST = require('../../math/const');
|
var MATH_CONST = require('../../math/const');
|
||||||
var Render = require('./GraphicsRender');
|
var Render = require('./GraphicsRender');
|
||||||
|
var Ellipse = require('../../geom/ellipse/');
|
||||||
|
|
||||||
var Graphics = new Class({
|
var Graphics = new Class({
|
||||||
|
|
||||||
|
@ -375,6 +376,9 @@ var Graphics = new Class({
|
||||||
|
|
||||||
var points = ellipse.getPoints(smoothness);
|
var points = ellipse.getPoints(smoothness);
|
||||||
|
|
||||||
|
// Duplicate the first point to "close" the ellipse stroke
|
||||||
|
points.push(points[0]);
|
||||||
|
|
||||||
return this.strokePoints(points);
|
return this.strokePoints(points);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ var CircumferencePoint = function (ellipse, angle, out)
|
||||||
{
|
{
|
||||||
if (out === undefined) { out = new Point(); }
|
if (out === undefined) { out = new Point(); }
|
||||||
|
|
||||||
var a = ellipse.width / 2;
|
var halfWidth = ellipse.width / 2;
|
||||||
var b = ellipse.height / 2;
|
var halfHeight = ellipse.height / 2;
|
||||||
|
|
||||||
out.x = ellipse.x + a * Math.cos(angle);
|
out.x = ellipse.x + halfWidth + halfWidth * Math.cos(angle);
|
||||||
out.y = ellipse.y + b * Math.sin(angle);
|
out.y = ellipse.y + halfHeight + halfHeight * Math.sin(angle);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue