I made phyllotaxis effect.
It works like this:
- Cycle through whole loop (i.e 15000 iterations).
- Do the calculations.
- get the values X and Y.
- Print all points (ellipses) with values calculated in step 1.
What I want to achieve.
- One cycle through loop.
- do the calculations for point 1.
- get the values X and Y.
- Print point with values X and Y from one iteration.
N step. N'th cycle through loop.
N+1 step. do the calculations for point N.
N+2 step. get the values X and Y.
N+3 step. Print point with values X and Y from one iteration.
Here is my code:
from kivy.graphics import *
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty, ObjectProperty
from kivy.graphics.vertex_instructions import (Rectangle, Ellipse, Line
import math
n = 0
c = 5
class PhyllotaxiswApp(App):
def build(self):
return boxOustide()
class boxOustide(BoxLayout):
def __init__(self):
super(boxOustide, self).__init__()
with self.canvas:
global n
global c
window_center_x = self.get_center_x() * 8
window_center_y = self.get_center_y() * 6
post = c * 3500
for i in range(15200):
a = n * 137.3
r = c * math.sqrt(n)
x = r * math.cos(a) + window_center_x
y = r * math.sin(a) + window_center_y
Color(n % .999, .999, .999, mode='hsv')
Ellipse(pos=(x, y), size=(5, 5))
n += 1
if __name__ == "__main__":
PhyllotaxiswApp().run()
EDIT 1
Ok so there is huge window opened now for me, after I discovered this:
Clock.schedule_interval(class.function,1 / 60)
have you tried implementing it with the Clock object found in kivy.?