>>> from vimage import VImage >>> vi = VImage('scene 1') >>> vi.name 'scene 1' >>> len(vi) 0 >>> from circle import Circle >>> from point import Point >>> c = Circle(Point(0, 0), 1, (100, 200, 50)) >>> id = vi.add(c) >>> id 1 >>> isinstance(vi[id], Circle) True >>> len(vi) 1 >>> vi[1].radius 1 >>> from polygon import Polygon >>> pol = Polygon((200, 0, 200), []) >>> pol.add(Point(10, 10)) >>> pol.add(Point(15, 10)) >>> pol.add(Point(8, 15)) >>> id = vi.add(pol) >>> id 2 >>> len(vi[id]) 3 >>> len(vi) 2 >>> c2 = Circle(Point(-10, -10), 2, (200, 200, 0)) >>> vi.add(c2) 3 >>> 3 in vi True >>> 0 in vi False >>> vi.remove(3) >>> len(vi) 2 >>> str(vi) 'Vectorial image scene 1 of 2 figures' >>> d = vi.to_dict() >>> d == [{'type': 'circle', 'value': {'center': {'x': 0, 'y': 0}, 'radius': 1, 'color': [100, 200, 50]}}, {'type': 'polygon', 'value': {'color': [200, 0, 200], 'vertices': [{'x': 10, 'y': 10}, {'x': 15, 'y': 10}, {'x': 8, 'y': 15}]}}] True >>> vi2 = VImage.from_dict('test', d) >>> len(vi2) 2 >>> vi2.name 'test' >>> vi2[1].center.x 0 >>> vi2[1].center.y 0 >>> len(vi2[2]) 3 >>> vi2.to_json('xetedgdjd077.json') >>> vi3 = vi.from_json('xetedgdjd077.json') >>> vi3.name = 'test' >>> vi3 == vi2 True