You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
<?xml version="1.0" standalone="no"?>
|
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010719//EN"
|
|
"http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
|
|
<svg width="6cm" height="5cm" viewBox="0 0 600 500">
|
|
<desc>Example script01 - invoke an ECMAScript function from an onclick event
|
|
</desc>
|
|
<!-- ECMAScript to change the radius with each click -->
|
|
<script type="text/ecmascript"> <![CDATA[
|
|
function circle_click(evt) {
|
|
var circle = evt.target;
|
|
var currentRadius = circle.r.baseVal.value;
|
|
if (currentRadius == 100)
|
|
circle.r.baseVal.value = currentRadius*2;
|
|
else
|
|
circle.r.baseVal.value = currentRadius*0.5;
|
|
}
|
|
]]> </script>
|
|
|
|
<!-- Outline the drawing area with a blue line -->
|
|
<rect x="1" y="1" width="598" height="498" fill="none" stroke="blue"/>
|
|
|
|
<!-- Act on each click event -->
|
|
<circle onclick="circle_click(evt)" cx="300" cy="225" r="100"
|
|
fill="red"/>
|
|
|
|
<text x="300" y="480"
|
|
font-family="Verdana" font-size="35" text-anchor="middle">
|
|
Click on circle to change its size
|
|
</text>
|
|
</svg>
|