# (C) Copyright ReportLab Inc. 1998-2000. from pingo import * def getDrawing3(): """This uses a named reference object. The house is a 'subroutine' the basic brick colored walls are defined, but the roof and window color are undefined and may be set by the container.""" D = Drawing(400, 200, fill=colors.bisque) House = Group( Rect(2,20,36,30, fill=colors.bisque), #walls Polygon([0,20,40,20,20,5]), #roof Rect(8, 38, 8, 12), #door Rect(25, 38, 8, 7), #window Rect(8, 25, 8, 7), #window Rect(25, 25, 8, 7) #window ) D.addDef('MyHouse', House) # one row all the same color D.add(String(20, 40, 'British Street...',fill=colors.black)) for i in range(6): x = i * 50 D.add(NamedReference('MyHouse', House, transform=translate(x, 40), fill = colors.brown ) ) # now do a row all different D.add(String(20, 120, 'Mediterranean Street...',fill=colors.black)) x = 0 for color in (colors.blue, colors.yellow, colors.orange, colors.red, colors.green, colors.chartreuse): D.add(NamedReference('MyHouse', House, transform=translate(x,120), fill = color, ) ) x = x + 50 #..by popular demand, the mayor gets a big one at the end D.add(NamedReference('MyHouse', House, transform=mmult(translate(x,110), scale(1.2,1.2)), fill = color, ) ) return D