Posts tonen met het label corner. Alle posts tonen
Posts tonen met het label corner. Alle posts tonen

zaterdag 26 december 2015

Stencyl : Drawing an ellipse / circle inside a Rectangle

Graphics : Drawing an Ellipse inside a rectangle

Using Extension for Drawing Utilities in Stencyl: http://community.stencyl.com/index.php?topic=35352.0

Source: Download for 3.2+ Made by ETH 




The ellipse / circle is being drawn using cosinus and sinus in a 360 loop.

The corners of the ellipse can be found by using this code:

var a=_Counter; 
var i=180; // i=90 quarter, i=180 HalfWay etc..

var w=64;
var h=100;
var x=128;
var y=128;
var tempx = w * Math.cos(i * Utils.RAD);
var tempy = h * Math.sin(i * Utils.RAD);
var templ = Utils.distance(0, 0, tempx, tempy);
var tempa = a + Utils.angle(0, 0, tempx, tempy);
tempx = x + (templ * Math.cos(tempa * Utils.RAD));
tempy = y + (templ * Math.sin(tempa * Utils.RAD));
g.fillRect(tempx, tempy, 10, 10); // Mark the side with a rectangle