<button id="test" onclick="setMode('test')"><img src="http://
ajaxanimator.googlecode.com/svn/trunk/ajaxanimator/img/icon/line.gif"
title="Test"</button>
in the mousedown event function of editor.js
}else if(this.mode == "test"){
shape = this.draw.rect(x, y, 0, 0);
// in the mouseMove() function:
// ===============================
if(this.selected[0].type == "test"){
this.resize(this.selected[0], x - this.onGrabXY[0], y -
this.onGrabXY[1], this.onGrabXY[0], this.onGrabXY[1])
// in the mouseUp() function
//===================================
}else if(this.mode == "test"){
this.unselect()
Sadly, nothing happens when I try out the custom button, can someone
tell me what I am doing wrong?
Thanks
-Noah
Index: editor.js
===================================================================
--- editor.js (revision 201)
+++ editor.js (working copy)
@@ -270,6 +270,18 @@
shape = this.draw.ellipse(x, y, 0, 0);
}else if(this.mode == "path"){
shape = this.draw.path("M{0},{1}",x,y)
+ }else if(this.mode == "demo"){
+ //this is a tad bit awkward because resizing path type objects
is significantly different from normal rectangle/ellipse type objects
+
+ shape = this.draw.path("M{0},{1}
1l-5.55944,11.26437l-10.8042,0.22989l9.33566,7.47126l-5.45454,11.03448l10.90909,-9.42529l7.76225,9.1954l-2.72728,-11.26437l10.17483,-6.66666l-10.8042,-0.68966l-2.83216,-11.14942",x,y)
+ shape.polypoints = [[x,y]]
+ shape.subtype = "demo"
+ this.onGrabXY = [
+ shape.getBBox().x,
+ shape.getBBox().y,
+ shape.getBBox().width,
+ shape.getBBox().height
+ ]
}else if(this.mode == "line"){
shape = this.draw.path("M{0},{1}",x,y)
shape.subtype = "line"
@@ -385,6 +397,10 @@
this.resize(this.selected[0], x - this.onHitXY[0], y -
this.onHitXY[1], this.onHitXY[0], this.onHitXY[1])
}else if(this.mode == "ellipse"){
this.resize(this.selected[0], x - this.onHitXY[0], y -
this.onHitXY[1], this.onHitXY[0], this.onHitXY[1])
+ }else if(this.mode == "demo"){
+ if(x - this.onGrabXY[0] > this.onGrabXY[2] && y -
this.onGrabXY[1] > this.onGrabXY[3]){
+ this.selected[0].scale((x - this.onGrabXY[0])/
this.onGrabXY[2], (y - this.onGrabXY[1])/this.onGrabXY[3],
this.onGrabXY[0], this.onGrabXY[1])
+ }
}else if(this.mode == "text"){
this.resize(this.selected[0], x - this.onHitXY[0], y -
this.onHitXY[1], this.onHitXY[0], this.onHitXY[1])
}else if(this.mode == "path"){
@@ -507,6 +523,8 @@
this.unselect()
}else if(this.mode == "line"){
this.unselect()
+ }else if(this.mode == "demo"){
+ this.unselect()
}else if(this.mode == "image"){
this.unselect()
}else if(this.mode == "text"){
Index: index.html
===================================================================
--- index.html (revision 201)
+++ index.html (working copy)
@@ -49,6 +49,7 @@
<button id="open" onclick="opendialog()"><img src="
http://ajaxanimator.googlecode.com/svn/trunk/ajaxanimator/img/silk/folder_go.png"
title="Open"></button>
+ <button onclick="setMode('demo')" style="width:60px">Star</
button>
<br>