def make_document():
    # Create the document
    doc = OpenDocumentDrawing()

    # Create the drawing page
    dpstyle = Style(family="drawing-page", name="DP1")
    dpstyle.addElement(DrawingPageProperties(backgroundsize="border",
                                             fill="none"))
    doc.automaticstyles.addElement(dpstyle)

    # Create page layout specifying dimensions
    plstyle = PageLayout(name="PM1")
    plstyle.addElement(PageLayoutProperties(margin="1in", pageheight="8.5in", pagewidth="11in", printorientation="landscape"))
    doc.automaticstyles.addElement(plstyle)

    # Create a master page
    masterpage = MasterPage(stylename=dpstyle, name="Default", pagelayoutname=plstyle)
    doc.masterstyles.addElement(masterpage)

    # Create a page to contain the drawing
    drawpage = Page(masterpagename=masterpage, name="page1", stylename=dpstyle)
    doc.drawing.addElement(drawpage)

    # Create a style for the circles
    circlestyle = Style(family="graphic", name="solid")
    circlestyle.addElement(
        GraphicProperties(fill="none", stroke="#000000", strokewidth="0.01in"))
    doc.automaticstyles.addElement(circlestyle)

    group=G()
    drawpage.addElement(group)

    circlePlotter = CirclePlotter(circlestyle)
    
    #nestedTriangle = NestedTriangle(group, circlePlotter, 0.25, 0.5, 0.5)
    #nestedTriangle = NestedTriangle(group, circlePlotter, 0.125, 0.75, 0.5)
    nestedTriangle = NestedTriangle(group, circlePlotter, 0.19, 0.625, 0.39)
    nestedTriangle.draw(5.5, 4.25, 3.5, 6)


    # Save the work
    doc.save(DRAWING_FILE, True)
Esempio n. 2
0
        return ' '.join(strpairs)

    def getviewbox(self):
        ''' The value of the viewBox attribute is a list of four numbers
            <min-x>, <min-y>, <width> and <height>'''
        xvals = [ item[0] for item in self.polygon]
        maxx = int(reduce(max,xvals)) + 1
        minx = int(reduce(min,xvals))
        yvals = [ item[1] for item in self.polygon]
        maxy = int(reduce(max,yvals)) + 1
        miny = int(reduce(min,yvals))
        return minx, miny, maxx-minx, maxy-miny


# Create the document
doc = OpenDocumentDrawing()

# Create the drawing page
dpstyle = Style(family="drawing-page",name="DP1")
dpstyle.addElement(DrawingPageProperties(backgroundsize="border", fill="none"))
doc.automaticstyles.addElement(dpstyle)

# The blue background style of the flag
backgroundstyle = Style(family="graphic", name="blueback")
backgroundstyle.addElement(GraphicProperties(fill="solid", fillcolor="#003399", stroke="none"))
doc.automaticstyles.addElement(backgroundstyle)

# The style for the stars
starstyle = Style(family="graphic", name="starstyle")
starstyle.addElement(GraphicProperties(fill="solid", fillcolor="#ffcc00", stroke="none"))
doc.automaticstyles.addElement(starstyle)