[Laszlo-user] Laszlo wrong Coordinate system

Muthu Veerappan muthu at periyakaruppan.com
Wed Apr 18 04:50:21 PDT 2007


Hi All, 

Below is the example of drawing a box and circle. Can anyone please help me find out why the circle drawing does not match with the co-ordinate system ?

1) I draw a box with width 30

2) I draw some circles and the last circle was at 30th pixel but its drawn on 60th pixel 

Can anyone help me understand any wrong i did ?

<?xml version="1.0" encoding="UTF-8" ?>
<canvas width="800" height="800" debug="true" >	
    <class name="circle" extends="drawview" >
        <attribute name="circlecolor" value="white"/>
        <attribute name="r" value="100"/>
        <handler name="oninit">
          this.redraw();
        </handler>
        <handler name="onr">
          this.redraw();
        </handler>
        <method name="redraw" ><![CDATA[
            this.clear();
            this.beginPath();
            this.moveTo(x+r, y);
            var a = Math.tan(22.5 * Math.PI/180);
            for (var angle = 45; angle<=360; angle += 45) {
                // endpoint:
                var endx = r*Math.cos(angle*Math.PI/180);
                var endy = r*Math.sin(angle*Math.PI/180);
                // control:
                // (angle-90 is used to give the correct sign)
                var cx =endx + r*a*Math.cos((angle-90)*Math.PI/180);
                var cy =endy + r*a*Math.sin((angle-90)*Math.PI/180);
                this.quadraticCurveTo(cx+x, cy+y, endx+x, endy+y);
            }
          
            var g = this.createLinearGradient(0, 0, 8, x+r, y+r, 0)
            this.globalAlpha = 1;
            g.addColorStop(0, 0xffffff);
            this.globalAlpha = 0;
            g.addColorStop(1, this.circlecolor);
            this.fillStyle = g;
            this.fill()
            this.globalAlpha = 1;
            this.linewidth= 5;
            this.stroke();
        ]]>
        </method>
    </class>
	<class name="box" extends="drawview">
	<animator name="myAnimator" attribute="opacity"  to="1" duration="1000" start="true"/>
		<handler name="oninit">
			
		</handler>
		<method name="setNewHeight" ><![CDATA[
		]]>
		</method>
	</class>    
    
	<box x="0" y="0" width="30" height="10" bgcolor="blue" opacity=".5" name="b1"/> 
	<circle r="1" x="0" y="0" circlecolor="blue"/>
	<circle r="1" x="10" y="0" circlecolor="blue"/>
	<circle r="1" x="20" y="0" circlecolor="blue"/>
	<circle r="1" x="30" y="0" circlecolor="blue"/> 

</canvas>

-----------------

thanks & regards,
muthu veerappan




More information about the Laszlo-user mailing list