mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +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 MATH_CONST = require('../../math/const');
|
||||
var Render = require('./GraphicsRender');
|
||||
var Ellipse = require('../../geom/ellipse/');
|
||||
|
||||
var Graphics = new Class({
|
||||
|
||||
|
@ -375,6 +376,9 @@ var Graphics = new Class({
|
|||
|
||||
var points = ellipse.getPoints(smoothness);
|
||||
|
||||
// Duplicate the first point to "close" the ellipse stroke
|
||||
points.push(points[0]);
|
||||
|
||||
return this.strokePoints(points);
|
||||
},
|
||||
|
||||
|
@ -457,9 +461,9 @@ var Graphics = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// If key is a string it'll generate a new texture using it and add it into the
|
||||
// If key is a string it'll generate a new texture using it and add it into the
|
||||
// Texture Manager (assuming no key conflict happens).
|
||||
//
|
||||
//
|
||||
// If key is a Canvas it will draw the texture to that canvas context. Note that it will NOT
|
||||
// automatically upload it to the GPU in WebGL mode.
|
||||
|
||||
|
@ -469,7 +473,7 @@ var Graphics = new Class({
|
|||
|
||||
if (width === undefined) { width = sys.game.config.width; }
|
||||
if (height === undefined) { height = sys.game.config.height; }
|
||||
|
||||
|
||||
Graphics.TargetCamera.setViewport(0, 0, width, height);
|
||||
Graphics.TargetCamera.scrollX = this.x;
|
||||
Graphics.TargetCamera.scrollY = this.y;
|
||||
|
|
|
@ -17,11 +17,11 @@ var CircumferencePoint = function (ellipse, angle, out)
|
|||
{
|
||||
if (out === undefined) { out = new Point(); }
|
||||
|
||||
var a = ellipse.width / 2;
|
||||
var b = ellipse.height / 2;
|
||||
var halfWidth = ellipse.width / 2;
|
||||
var halfHeight = ellipse.height / 2;
|
||||
|
||||
out.x = ellipse.x + a * Math.cos(angle);
|
||||
out.y = ellipse.y + b * Math.sin(angle);
|
||||
out.x = ellipse.x + halfWidth + halfWidth * Math.cos(angle);
|
||||
out.y = ellipse.y + halfHeight + halfHeight * Math.sin(angle);
|
||||
|
||||
return out;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue