from gym.envs.classic_control import rendering
import numpy as np
import time
def r(viewer,x,t):
t.set_translation(x,0)
#viewer.add_geom(a)
viewer = rendering.Viewer(680,680)
viewer.set_bounds(-1.2,2.2,-1.2,2.2)
a = viewer.draw_circle(1, 13, color = (1,1,0))
b = rendering.make_circle(0.2, 4)
bb = rendering.Transform()
bb.set_rotation(0.25*3.14)
b.add_attr(bb)
viewer.add_geom(b)
viewer.render(0)
x=0
while 1:
c = rendering.make_circle(0.02, 9)
cc = rendering.Transform()
cc.set_translation(x,0)
c.add_attr(cc)
viewer.add_geom(c)
viewer.draw_circle(0.01, 3, color = (0,1,0)).add_attr(bb)
viewer.render(0)
time.sleep(0.1)
x = x+0.1
r(viewer,x,bb)
viewer.draw_circle(0.05, 3, color = (0,1,0)).add_attr(bb)
viewer.render(0)
pass
三角形
from gym.envs.classic_control import rendering
import numpy as np
viewer = rendering.Viewer(600,600)
viewer.set_bounds(-2.2,2.2,-2.2,2.2)
a = rendering.make_circle(0.1, 3)
a.set_color(0,0,1)
aa = rendering.Transform()
aa.set_translation(-0.5,0)
a.add_attr(aa)
viewer.add_geom(a)
b = rendering.make_circle(0.2, 4)
bb = rendering.Transform()
bb.set_rotation(0.25*3.14)
b.add_attr(bb)
viewer.add_geom(b)
c = rendering.make_circle(0.3, 5)
cc = rendering.Transform()
cc.set_translation(0.5,0.3)
c.add_attr(cc)
viewer.add_geom(c)
viewer.render(0)
while 1:
pass