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:
Michael Hadley 2017-12-01 18:05:39 -06:00
parent 195ea19ea7
commit 806c9d3237
2 changed files with 11 additions and 7 deletions

View file

@ -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);
}, },

View file

@ -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;
}; };