Drawing Rectangles

You use the rect method of the LzDrawView class to draw rectangles. The LZX application in Listing 10.2 draws three rectangles. The first rectangle’s top-left corner is at (10, 10), the second’s at (10, 50), and the third’s at (10, 90). All rectangles have a width of 100 pixels and a height of 30 pixels. What differentiates them are the radii of the corners.

Listing 10.2. Drawing rectangles
<canvas height="200">
    <drawview height="200" width="200">
        <method event="oninit">
            this.rect(10, 10, 100, 30);
            this.rect(10, 50, 100, 30, 5);
            this.rect(10, 90, 100, 30, 15);
            this.stroke();
        </method>
    </drawview>
</canvas>

You can test and run the code in Listing 10.2 by using this URL:

http://localhost:8080/lps-4.0.x/app10/rectTest1.lzx

Figure 10.2 shows the rectangles.

Figure 10.2. Drawing rectangles


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset