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)
Ejemplo n.º 2
0
group=G()
drawpage.addElement(group)

turtle = VectorSet()
# Draw the edges
turtle.mark()
for edge in [ 0,1,2,3,5 ]:
    turtle.forward(100)
    turtle.mark()
    turtle.right(144)
    turtle.forward(100)
    turtle.mark()
    turtle.left(72)
turtle.firstmark()

# Draw a rectangle containing the blue background
group.addElement(Rect(height="120mm", width="180mm", x="0mm", y="0mm", stylename=backgroundstyle))

viewbox = ' '.join(map(str,turtle.getviewbox()))
points = turtle.getpoints()

# Go around in a circle in twelve steps
for deg in range(0,360,30):
    x = 83.3 + math.cos(math.radians(deg)) * 40
    y = 53.3 + math.sin(math.radians(deg)) * 40
    group.addElement(Polygon(points=points,
       stylename=starstyle, viewbox=viewbox, width="13.3mm", height="13.3mm", x="%0.2fmm" % x, y="%0.2fmm" % y))

# Save the work
doc.save("europeanflag", True)