Skip to content

Commit 55bfc9a

Browse files
committed
Ellipse x/y is now its center and the bounds properties adjust position, not dimension
1 parent 84c86e2 commit 55bfc9a

1 file changed

Lines changed: 9 additions & 39 deletions

File tree

v3/src/geom/ellipse/Ellipse.js

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var Ellipse = new Class({
88

99
initialize:
1010

11+
// x/y = center of the ellipse
1112
function Ellipse (x, y, width, height)
1213
{
1314
if (x === undefined) { x = 0; }
@@ -100,21 +101,12 @@ var Ellipse = new Class({
100101

101102
get: function ()
102103
{
103-
return this.x;
104+
return this.x - (this.width / 2);
104105
},
105106

106107
set: function (value)
107108
{
108-
if (value >= this.right)
109-
{
110-
this.width = 0;
111-
}
112-
else
113-
{
114-
this.width = this.right - value;
115-
}
116-
117-
this.x = value;
109+
this.x = value + (this.width / 2);
118110
}
119111

120112
},
@@ -123,19 +115,12 @@ var Ellipse = new Class({
123115

124116
get: function ()
125117
{
126-
return this.x + this.width;
118+
return this.x + (this.width / 2);
127119
},
128120

129121
set: function (value)
130122
{
131-
if (value <= this.x)
132-
{
133-
this.width = 0;
134-
}
135-
else
136-
{
137-
this.width = value - this.x;
138-
}
123+
this.x = value - (this.width / 2);
139124
}
140125

141126
},
@@ -144,20 +129,12 @@ var Ellipse = new Class({
144129

145130
get: function ()
146131
{
147-
return this.y;
132+
return this.y - (this.height / 2);
148133
},
149134

150135
set: function (value)
151136
{
152-
if (value >= this.bottom)
153-
{
154-
this.height = 0;
155-
this.y = value;
156-
}
157-
else
158-
{
159-
this.height = (this.bottom - value);
160-
}
137+
this.y = value + (this.height / 2);
161138
}
162139

163140
},
@@ -166,19 +143,12 @@ var Ellipse = new Class({
166143

167144
get: function ()
168145
{
169-
return this.y + this.height;
146+
return this.y + (this.height / 2);
170147
},
171148

172149
set: function (value)
173150
{
174-
if (value <= this.y)
175-
{
176-
this.height = 0;
177-
}
178-
else
179-
{
180-
this.height = value - this.y;
181-
}
151+
this.y = value - (this.height / 2);
182152
}
183153

184154
}

0 commit comments

Comments
 (0)