Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Ellipse origin (SOLVED)
-
Is there a way to change the origin of an ellipse to be in the center of the ellipse?
I'll put a little example under that demonstrates why this would be convenient in some cases.<PRE>
from scene import *
class MyScene(Scene):
def setup(self):
self.pos = (self.bounds.center())
self.w = self.h = 100
self.p = Point(self.pos.x+self.h/2, self.pos.y+self.w/2)
self.colour = Color(1.00, 1.00, 1.00)def draw(self): background(0,0,0) fill(*self.colour) ellipse(self.pos.x, self.pos.y, self.w, self.h) for t in self.touches.values(): #p = t.location.distance(self.pos) p = t.location.distance(self.p) text(str(p), x=100, y=100, font_size=24) if p < self.w/2: self.colour = Color(1.00, 0.00, 0.00) else: self.colour = Color(1.00, 1.00, 1.00)
run(MyScene())
</PRE> -
Try this:
<pre>
def centered_ellipse(x, y, width, height):
return ellipse(x - width/2, y - height/2, width, height)
</pre> -
Nice! I didn't think of that. That's exactly what I need! Thanks@C0deH4cker :D
-
Glad to help :)