def create_canvas(c=None): if not c: c = Canvas() b=MyBox() b.min_width = 20 b.min_height = 30 print 'box', b b.matrix=(1.0, 0.0, 0.0, 1, 20,20) b.width = b.height = 40 c.add(b) bb=Box() print 'box', bb bb.matrix=(1.0, 0.0, 0.0, 1, 10,10) c.add(bb, parent=b) fl = FatLine() fl.height = 50 fl.matrix.translate(100, 100) c.add(fl) circle = Circle() h1, h2 = circle.handles() circle.radius = 20 circle.matrix.translate(50, 100) c.add(circle) # AJM: extra boxes: bb = Box() print 'box', bb bb.matrix.rotate(math.pi/4.) c.add(bb, parent=b) # for i in xrange(10): # bb=Box() # print 'box', bb # bb.matrix.rotate(math.pi/4.0 * i / 10.0) # c.add(bb, parent=b) b = PortoBox(60, 60) b.min_width = 40 b.min_height = 50 b.matrix.translate(55, 55) c.add(b) t = UnderlineText() t.matrix.translate(70,30) c.add(t) t = MyText('Single line') t.matrix.translate(70,70) c.add(t) l = MyLine() c.add(l) l.handles()[1].pos = (30, 30) segment = Segment(l, view=None) segment.split_segment(0, 3) l.matrix.translate(30, 60) l.orthogonal = True off_y = 0 for align_x in (-1, 0, 1): for align_y in (-1, 0, 1): t=MyText('Aligned text %d/%d' % (align_x, align_y), align_x=align_x, align_y=align_y) t.matrix.translate(120, 200 + off_y) off_y += 30 c.add(t) t=MyText('Multiple\nlines', multiline = True) t.matrix.translate(70,100) c.add(t) return c
def create_canvas(c=None): if not c: c = Canvas() b = MyBox() b.min_width = 20 b.min_height = 30 b.matrix = (1.0, 0.0, 0.0, 1, 20, 20) b.width = b.height = 40 c.add(b) bb = Box() bb.matrix = (1.0, 0.0, 0.0, 1, 10, 10) c.add(bb, parent=b) fl = FatLine() fl.height = 50 fl.matrix.translate(100, 100) c.add(fl) circle = Circle() h1, h2 = circle.handles() circle.radius = 20 circle.matrix.translate(50, 100) c.add(circle) # AJM: extra boxes: bb = Box() bb.matrix.rotate(math.pi / 1.567) c.add(bb, parent=b) # for i in xrange(10): # bb = Box() # print('box', bb) # bb.matrix.rotate(math.pi/4.0 * i / 10.0) # c.add(bb, parent=b) b = PortoBox(60, 60) b.min_width = 40 b.min_height = 50 b.matrix.translate(55, 55) c.add(b) t = UnderlineText() t.matrix.translate(70, 30) c.add(t) t = MyText("Single line") t.matrix.translate(70, 70) c.add(t) l = MyLine() c.add(l) l.handles()[1].pos = (30, 30) segment = Segment(l, view=None) segment.split_segment(0, 3) l.matrix.translate(30, 60) l.orthogonal = True off_y = 0 for align_x in (-1, 0, 1): for align_y in (-1, 0, 1): t = MyText( f"Aligned text {align_x:d}/{align_y:d}", align_x=align_x, align_y=align_y, ) t.matrix.translate(120, 200 + off_y) off_y += 30 c.add(t) t = MyText("Multiple\nlines", multiline=True) t.matrix.translate(70, 100) c.add(t) return c
def create_canvas(c=None): if not c: c = Canvas() b = MyBox(c.connections) b.min_width = 20 b.min_height = 30 b.matrix.translate(20, 20) b.width = b.height = 40 c.add(b) bb = Box(c.connections) bb.matrix.translate(10, 10) c.add(bb, parent=b) bb = Box(c.connections) bb.matrix.rotate(math.pi / 1.567) c.add(bb, parent=b) circle = Circle() h1, h2 = circle.handles() circle.radius = 20 circle.matrix.translate(50, 160) c.add(circle) pb = Box(c.connections, 60, 60) pb.min_width = 40 pb.min_height = 50 pb.matrix.translate(100, 20) c.add(pb) ut = UnderlineText() ut.matrix.translate(100, 130) c.add(ut) t = MyText("Single line") t.matrix.translate(100, 170) c.add(t) line = MyLine(c.connections) c.add(line) line.handles()[1].pos = (30, 30) segment = Segment(line, c) segment.split_segment(0, 3) line.matrix.translate(30, 80) line.orthogonal = True return c