diff --git a/casual.bat b/casual.bat index 659232f..99db041 100644 --- a/casual.bat +++ b/casual.bat @@ -1 +1,2 @@ -java -jar e:/dev/js/compiler.jar --js_output_file js/casual-0.1.3.min.js --js src/core/base.js --js src/geom/Matrix.js --js src/geom/Rectangle.js --js src/utils/NameUtil.js --js src/event/EventBase.js --js src/event/StageEvent.js --js src/event/EventManager.js --js src/event/EventDispatcher.js --js src/display/DisplayObject.js --js src/display/DisplayObjectContainer.js --js src/display/Stage.js --js src/display/Bitmap.js --js src/display/Sprite.js --js src/display/Frame.js --js src/display/MovieClip.js --js src/display/Graphics.js --js src/display/Shape.js --js src/display/Text.js --js src/display/Button.js --js src/casual.js \ No newline at end of file +java -jar ./compiler.jar --js_output_file js/casual-0.1.3.min.js --js src/core/base.js --js src/geom/Matrix.js --js src/geom/Rectangle.js --js src/utils/NameUtil.js --js src/event/EventBase.js --js src/event/StageEvent.js --js src/event/EventManager.js --js src/event/EventDispatcher.js --js src/display/DisplayObject.js --js src/display/DisplayObjectContainer.js --js src/display/Stage.js --js src/display/Bitmap.js --js src/display/Sprite.js --js src/display/Frame.js --js src/display/MovieClip.js --js src/display/Graphics.js --js src/display/Shape.js --js src/display/Text.js --js src/display/Button.js --js src/casual.js +exit \ No newline at end of file diff --git a/compiler.jar b/compiler.jar new file mode 100644 index 0000000..8e52ef0 Binary files /dev/null and b/compiler.jar differ diff --git a/examples/Text.html b/examples/Text.html new file mode 100644 index 0000000..8b81783 --- /dev/null +++ b/examples/Text.html @@ -0,0 +1,83 @@ + + + + + + + + MovieClip Demo - CasualJS Framework + + + + + + + + +
+
+ Sorry, your browser doesn't support Canvas. +
+
+ + +

Causal Text

+
+ Constructor:
+ +function(text, color, font) +

+ + For example:
+ + var text = new Text("中国", "#ff1635","50px Arial");
+ stage.addChild(text);
+
+
+
+ + + + + diff --git a/js/casual-0.1.3.min.js b/js/casual-0.1.3.min.js new file mode 100644 index 0000000..64ea94e --- /dev/null +++ b/js/casual-0.1.3.min.js @@ -0,0 +1,42 @@ +var casual={version:"0.1.3",trace:function(){for(var a=[],b=0;b=d&&(b+="_");return b+a.getUID()};a.displayObjectToString=function(b){for(var d;null!=b;b=b.parent){var a=null!=b.id?b.id:b.name;d=null==d?a:a+"."+d;if(b==b.parent||b.parent instanceof Stage)break}return d}})();(function(){var a=function(b,d,a){this.type=b;this.params=this.currentTarget=this.target=null;this.bubbles=void 0!=d?d:!1;this.cancelable=void 0!=a?a:!1};casual.EventBase=a;a.prototype.stopPropagation=function(){};a.prototype.preventDefault=function(){};a.prototype.clone=function(){return casual.copy(this)};a.prototype.dispose=function(){delete this.type;delete this.target;delete this.currentTarget;delete this.params};a.prototype.toString=function(){return"[EventBase type="+this.type+"]"}})();(function(){var a=function(b,d,a){casual.EventBase.call(this,b,d,a);this.mouseY=this.mouseX=0};casual.inherit(a,casual.EventBase);casual.StageEvent=a;a.ENTER_FRAME="enterframe";a.MOUSE_DOWN="mousedown";a.MOUSE_UP="mouseup";a.MOUSE_MOVE="mousemove";a.MOUSE_OVER="mouseover";a.MOUSE_OUT="mouseout";a.supportTouch=function(){return"ontouchstart"in document};a.prototype.toString=function(){return"[StageEvent type="+this.type+", mouseX="+this.mouseX+", mouseY="+this.mouseY+"]"}})();(function(){function a(b,d){var a=!1,c;for(c in d.map)if("src"!=c){a=!0;break}return a?!1:(b.splice(d.index,1),!0)}function b(b,d,a){for(var c=0;c=this.alpha||(b.save(),a||this._transform(b,e),this.render(b),b.restore())};a.prototype.render=function(b){};a.prototype.hitTestPoint=function(b,c,e, +f){if(!e)return f=this.globalToLocal(b,c),0<=f.x&&f.x<=this.getCurrentWidth()&&0<=f.y&&f.y<=this.getCurrentHeight();e=a.__hitTestContext;e.setTransform(1,0,0,1,-b,-c);this._render(e,!1,!0);f=f||a.__hitTestTolerance;b=!1;try{e.getImageData(0,0,1,1).data[3]>=f&&(b=!0)}catch(g){trace("hitTestPoint:",this,g)}e.canvas.width=0;e.canvas.width=1;return b};a.prototype.hitTestObject=function(b,c,e){var f=this.getRect(this.getStage()),g=b.getRect(this.getStage());if(!c)return f.intersects(g);f=f.intersection(g); +e=e||a.__hitTestTolerance;if(f&&0=e)&&(0=e)){c=!0;break}b+= +4}}catch(m){}k.canvas.width=0;k.canvas.width=k.canvas.height=1;return c}return!1};a.prototype.getRect=function(b){b=this.localToTarget(0,0,b);return new Rectangle(b.x,b.y,this.getCurrentWidth(),this.getCurrentHeight())};a.prototype.onMouseEvent=null;a.prototype.toString=function(){return NameUtil.displayObjectToString(this)}})();(function(){var a=function(){casual.DisplayObject.call(this);this.children=[];this.mouseChildren=!0};casual.inherit(a,casual.DisplayObject);casual.DisplayObjectContainer=a;a.prototype.addChildAt=function(b,a){0>a?a=0:a>this.children.length&&(a=this.children.length);var c=this.getChildIndex(b);if(-1!=c){if(c==a)return b;this.children.splice(c,1)}else b.parent&&b.parent.removeChild(b);this.children.splice(a,0,b);b.parent=this;return b};a.prototype.addChild=function(b){return this.addChildAt(b,this.children.length)}; +a.prototype.removeChildAt=function(b){if(0>b||b>=this.children.length)return!1;var a=this.children[b];null!=a&&(a.parent=null,a.stage=null);this.children.splice(b,1);return!0};a.prototype.removeChild=function(b){return this.removeChildAt(this.children.indexOf(b))};a.prototype.removeChildByName=function(b){for(var a=0,c=this.children.length;ab||b>=this.children.length?null:this.children[b]};a.prototype.getChildIndex=function(b){return this.children.indexOf(b)};a.prototype.setChildIndex=function(b,a){if(b.parent==this){var c=this.children.indexOf(b);a!=c&&(this.children.splice(c,1),this.children.splice(a,0,b))}};a.prototype.contains=function(b){return-1!= +this.getChildIndex(b)};a.prototype.getNumChildren=function(){return this.children.length};a.prototype.getObjectUnderPoint=function(b,d,c,e,f){if(f)var g=[];for(var k=this.children.length-1;0<=k;k--){var h=this.children[k];if(null!=h&&h.mouseEnabled&&h.visible&&!(0>=h.alpha))if(h instanceof a&&h.mouseChildren&&0=this._frameRate&&(clearInterval(this.__intervalID),this.__intervalID=null)};a.prototype.render=function(b,d){b||(b=this.context);d?this.clear(d.x, +d.y,d.width,d.height):this.clear();this.dragTarget&&(this.dragTarget.x=this.mouseX-this._dragMouseX,this.dragTarget.y=this.mouseY-this._dragMouseY);a.superClass.render.call(this,b);this._pauseInNextFrame&&(this._paused=!0,this._pauseInNextFrame=!1)};a.prototype.startDrag=function(b,a){this.dragTarget=b;var c=this.dragTarget.globalToLocal(this.mouseX,this.mouseY);this._dragMouseX=c.x;this._dragMouseY=c.y};a.prototype.stopDrag=function(){this.dragTarget=null};a.prototype.setCursor=function(b){this.canvas.style.cursor= +b};a.prototype.clear=function(b,a,c,e){4<=arguments.length?this.context.clearRect(b,a,c,e):this.context.clearRect(0,0,this.canvas.width,this.canvas.height)};a.prototype.getStageWidth=function(){return this.canvas.width};a.prototype.getStageHeight=function(){return this.canvas.height}})();(function(){var a=function(b,a){casual.DisplayObject.call(this);this.name=NameUtil.createUniqueName("Bitmap");this.mouseEnabled=!1;this.image=b;this.frame=a?a:[0,0,b.width,b.height];this.width=this.frame[2];this.height=this.frame[3];this.regX=this.frame[4]||0;this.regY=this.frame[5]||0};casual.inherit(a,casual.DisplayObject);casual.Bitmap=a;a.prototype.render=function(b){b.drawImage(this.image,this.frame[0],this.frame[1],this.frame[2],this.frame[3],0,0,this.width,this.height)}})();(function(){var a=function(){casual.DisplayObjectContainer.call(this);this.name=NameUtil.createUniqueName("Sprite")};casual.inherit(a,casual.DisplayObjectContainer);casual.Sprite=a})();(function(){var a=function(b,a,c,e,f){this.disObj=b;this.label=a||null;this.gotoFrame=c||0;this.pauseFrames=e||0;this.stop=f||!1};casual.Frame=a;a.prototype.render=function(b,a,c){void 0!=a&&(this.disObj.x=a);void 0!=c&&(this.disObj.y=c);this.disObj._render(b,!1,!1)}})();(function(){var a=function(b){casual.Sprite.call(this);this.name=NameUtil.createUniqueName("MovieClip");this._frameLables={};this._frames=[];b&&this.addFrame(b);this.currentFrame=1;this._frameDisObj=null;this._pauseFrames=0;this._paused=!1};casual.inherit(a,casual.Sprite);casual.MovieClip=a;a.prototype.addFrame=function(b){if(b[0]instanceof casual.Frame||b[0]instanceof Array)for(var a in b)this.addFrame(b[a]);else this.setFrame(this._frames.length+1,b);return this};a.prototype.addFrameAt=function(b, +a){this._frames.splice(a,0,null);this.setFrame(a+1,b)};a.prototype.setFrame=function(b,a){var c;c=a instanceof casual.Frame?a:new casual.Frame(a);this._frames[b-1]=c;c.label&&(this._frameLables[c.label]=c);1==b&&(this._frameDisObj=c.disObj,this.width=Math.max(this.width,this._frameDisObj.width),this.height=Math.max(this.height,this._frameDisObj.height))};a.prototype.getFrameNumber=function(b){if("number"==typeof b)return b;var a=b;"string"==typeof a&&(a=this._frameLables[b]);for(b=0;bthis._pauseFrames?this._pauseFrames++:this._pauseFrames= +0);return!b.gotoFrame||0!=this._pauseFrames&&b.pauseFrames?b.pauseFrames&&0=this._frames.length?this.currentFrame=1:++this.currentFrame:this.currentFrame=this.getFrameNumber(b.gotoFrame)};a.prototype.play=function(){this._paused=!1};a.prototype.stop=function(){this._paused=!0};a.prototype.gotoAndStop=function(b){this.currentFrame=this.getFrameNumber(b);this._paused=!0};a.prototype.gotoAndPlay=function(b){this.currentFrame=this.getFrameNumber(b); +this._paused=!1};a.prototype.render=function(b){var d=this.getFrame(this.currentFrame);this._frameDisObj&&this._frameDisObj!=d.disObj&&this.removeChild(this._frameDisObj);this.addChildAt(d.disObj,0);this._frameDisObj=d.disObj;this.width=Math.max(this.width,this._frameDisObj.width);this.height=Math.max(this.height,this._frameDisObj.height);d.stop&&this.stop();a.superClass.render.call(this,b);this._paused||b!=this.getStage().context||this.nextFrame()}})();(function(){var a=function(){this.name=NameUtil.createUniqueName("Graphics");var b=document.createElement("canvas");b.width=1E3;b.height=1E3;this._context=b.getContext("2d");a._init(this,this._context)};casual.Graphics=a;a.prototype._proxy=function(b,a,c){this[a]=function(){return b[a].apply(b,arguments)||this};c&&(this[c]=this[a])};a._init=function(b,a){b._proxy(a,"beginPath");b._proxy(a,"closePath");b._proxy(a,"stroke");b._proxy(a,"fill");b._proxy(a,"moveTo");b._proxy(a,"lineTo");b._proxy(a,"arcTo"); +b._proxy(a,"arc");b._proxy(a,"quadraticCurveTo","curveTo");b._proxy(a,"bezierCurveTo");b._proxy(a,"rect");b._proxy(a,"createLinearGradient");b._proxy(a,"createRadialGradient");b._proxy(a,"createPattern");b.fillStyle=null;b.strokeStyle=null;b.fillAlpha=1;b.lineAlpha=1;b.lineWidth=1};a.prototype.lineStyle=function(b,a,c,e,f,g){this.lineWidth=this._context.lineWidth=b||1;this.strokeStyle=this._context.strokeStyle=a||"0";this.lineAlpha=c||1;void 0!=e&&(this._context.lineCap=e);void 0!=f&&(this._context.lineJoin= +f);void 0!=g&&(this._context.miterLimit=g);return this};a.prototype.beginLinearGradientFill=function(b,a,c,e,f,g){b=this.createLinearGradient(b,a,c,e);a=0;for(c=f.length;a