x 및 y 위치의 배열이 있습니다. 이 점들을 각 점마다 연속적으로 연결 한 다음 애니메이션을 만드는 것을 보여주고 싶습니다. 그것은 흔적이 선인 경로 추적과 같습니다. 나는 그것을 표시하려고 python-kivy를 사용하고 있습니다.애니메이션 캔버스 Line on Kivy
Google에서 도움을 찾을 수 없습니다.
이 애니메이션을 실행하는 버튼이 있습니다.
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics.vertex_instructions import Line
from kivy.graphics.context_instructions import Color
from time import sleep
x_moves = [250, 250.4305, 249.8804, 246.0923, 239.7496, 233.8188, 225.7797, 215.8385, 205.8413, 196.6497, 189.7026, 181.2445, 174.9816, 171.9882, 166.1171, 161.6505, 159.9929, 161.1338, 164.853, 168.2874, 170.768, 178.6918, 184.5233, 190.0262, 195.607, 202.0255, 210.5954, 216.1031, 219.6285, 224.9134, 230.2314, 237.7017, 243.7408, 250.5839, 256.2949]
y_moves = [250, 240.0093, 230.0244, 220.7697, 213.0386, 204.9872, 199.0396, 197.9567, 197.7209, 201.6598, 208.8527, 214.1875, 221.9834, 231.5249, 239.62, 248.567, 258.4287, 268.3634, 277.6461, 287.0379, 296.7253, 302.8256, 310.9492, 319.299, 327.5969, 335.2652, 340.4185, 348.7651, 358.1231, 366.6125, 375.0812, 381.7291, 389.6996, 396.9915, 405.2003]
class my_App(App):
def build(self):
self.widget = Widget()
self.widget.on_touch_down = self.touch
with self.widget.canvas:
Color(0, 1, 0, 1) #just initial config
Line(points = [0,0,500,0,500,500,0,500], close = True) #just initial config
return self.widget
def touch(self, touch): #executes the animation
pts = []
for i in range(len(x_moves)):
pts.append(x_moves[i])
pts.append(y_moves[i])
self.widget.canvas.add(Line(points = pts))
sleep(0.1)
if __name__ == '__main__':
obj = my_App()
obj.run()
이것은 작동하지 않는 코드입니다. 그러나 그것은 그 아이디어입니다.
오류 메시지를 추가 하시겠습니까? 정확히 무슨 코드가 작동하는지 정확히 모르겠다. – pianist1119
실제로 코드는 작동하지만이 방법으로는 애니메이션이 표시되지 않는다. 루프가 실행 된 후에 만 캔버스가 업데이트됩니다. –
thankyou :) 당신이 질문에 포함시켜야 할 종류의 thats – pianist1119