diff onlypaths/js/format_mini.js @ 46:26c2b3ad21c7 laserkard

[svn r47] saving progresswww.cinemassacre.com/new/?page_id=30
author rlm
date Sun, 31 Jan 2010 12:33:33 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/onlypaths/js/format_mini.js	Sun Jan 31 12:33:33 2010 -0500
     1.3 @@ -0,0 +1,305 @@
     1.4 +/*
     1.5 +JSON Richdraw Abstraction Layer
     1.6 +
     1.7 +---------------------
     1.8 +Also,
     1.9 +
    1.10 +JSON Rich Draw Format
    1.11 +
    1.12 +---------------------
    1.13 +
    1.14 +
    1.15 +What data is not stored (yet)
    1.16 +-Transforms
    1.17 +
    1.18 +*/
    1.19 +
    1.20 +
    1.21 +
    1.22 +function canvas(richdraw,format){
    1.23 +  var rawshapes = richdraw.getshapes()
    1.24 +  var newshapes = [];
    1.25 +  for(var i = 0; i < rawshapes.length; i++){
    1.26 +    newshapes.push(richdraw.renderer.info(rawshapes[i]));
    1.27 +  }
    1.28 +    return newshapes;
    1.29 +}
    1.30 +
    1.31 +
    1.32 +var fullscreen=false;
    1.33 +function load(code,draw)
    1.34 +{
    1.35 +
    1.36 + var noattachlistener=false;
    1.37 + var renderdoc=false;  
    1.38 + var renderinfo=false
    1.39 + for(var i = 0; i < code.length; i++)
    1.40 +  {
    1.41 +   var rendering=true;  
    1.42 +
    1.43 +   if(code[i].type == "info")
    1.44 +    {
    1.45 +     rendering=false; 
    1.46 +     renderinfo=true;
    1.47 +     if(code[i].loop!=null)
    1.48 +      {
    1.49 +       timerNext=code[i].loop;
    1.50 +      }else{
    1.51 +       timerNext=0;
    1.52 +      }            
    1.53 +    } 
    1.54 +    
    1.55 +   if(code[i].type == "doc")
    1.56 +    { 
    1.57 +     rendering=false; 
    1.58 +     renderdoc=true;
    1.59 +     if(fullscreen==false)
    1.60 +      {
    1.61 +       draw.renderer.view(
    1.62 +       code[i].left,
    1.63 +       code[i].top,
    1.64 +       code[i].width,
    1.65 +       code[i].height,
    1.66 +       code[i].viewBox,
    1.67 +       (code[i].bgcolor!=null)?code[i].fillColor:"" 
    1.68 +       ); 
    1.69 +      }
    1.70 +       else
    1.71 +      {
    1.72 +       draw.renderer.view(
    1.73 +        0,
    1.74 +        0,
    1.75 +        screenW,
    1.76 +        screenH,
    1.77 +        code[i].viewBox,
    1.78 +        ''
    1.79 +        ); 
    1.80 +      }  
    1.81 +    }
    1.82 +   
    1.83 +   if( rendering==true)
    1.84 +    {
    1.85 +     var co  = draw.renderer.create(code[i].type, 
    1.86 +     (code[i].fillColor!=null)?code[i].fillColor:"", 
    1.87 +     (code[i].lineColor)?code[i].lineColor:"", 
    1.88 +     (code[i].fillOpac)?code[i].fillOpac:"", 
    1.89 +     (code[i].lineOpac)?code[i].lineOpac:"", 
    1.90 +     (code[i].lineWidth)?code[i].lineWidth:"", 
    1.91 +     (code[i].left)?code[i].left:"", 
    1.92 +     (code[i].top)?code[i].top:"", 
    1.93 +     (code[i].width)?code[i].width:"", 
    1.94 +     (code[i].height)?code[i].height:"",  
    1.95 +     (code[i].text)?code[i].text:'', 
    1.96 +     (code[i].textSize)?code[i].textSize:"",    
    1.97 +     (code[i].textFamily)?code[i].textFamily:'Arial', 
    1.98 +     (code[i].href)?code[i].href:'', 
    1.99 +     (code[i].points)?code[i].points:'', 
   1.100 +     (code[i].transform)?code[i].transform:'',
   1.101 +     (code[i].parent)?code[i].parent:''); 
   1.102 +    
   1.103 +     co.id = ""+code[i].id;  
   1.104 +     if (!noattachlistener) 
   1.105 +      {  
   1.106 +        Ext.get(co).on("mousedown", draw.onHit, draw);
   1.107 +
   1.108 +        /*
   1.109 +        co.addEventListener("click", function(event) { myfunction(this.id,draw,event); }, false);
   1.110 +        co.addEventListener("mouseover", function(event) {myOverFunction(this.id,draw,event); }, false);
   1.111 +        co.addEventListener("mouseout", function(event) {myOutFunction(this.id,draw,event); }, false);
   1.112 +        co.addEventListener("mouseup", function(event) {myUpFunction(this.id,draw,event); }, false);
   1.113 +        co.addEventListener("mousedown", function(event) {myDownFunction(this.id,draw,event); }, false);
   1.114 +        co.addEventListener("mousemove", function(event) {myMoveFunction(this.id,draw,event); }, false);
   1.115 +        co.addEventListener("dblclick", function(event) {myDblclickFunction(this.id,draw,event); }, false);
   1.116 +        */
   1.117 +      }
   1.118 +    }
   1.119 +  }
   1.120 + if(renderdoc == false)
   1.121 +  { 
   1.122 +   if(fullscreen==false)
   1.123 +    {
   1.124 +     draw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400','');   
   1.125 +    }
   1.126 +     else
   1.127 +    {
   1.128 +     draw.renderer.view(0,0,screenW,screenH,'0 0 700 400','');
   1.129 +    }
   1.130 +  }  
   1.131 + if(renderinfo == false)
   1.132 +  { 
   1.133 +  }  
   1.134 +}
   1.135 +
   1.136 +
   1.137 +
   1.138 +
   1.139 +
   1.140 +
   1.141 +
   1.142 +
   1.143 +
   1.144 +function load03(code,richdraw){
   1.145 +
   1.146 + //var co  =richdraw.renderer.create('group', '', '', 1, '', '', 0, 0, '', '', '', '', '', '', '', '','');
   1.147 + //co.id = 'frame'+frameNum;  
   1.148 + // var co  ={};
   1.149 + var renderdoc=false;  
   1.150 + var renderinfo=false
   1.151 + for(var i = 0; i < code.length; i++){
   1.152 +  // code[i].parent='frame'+frameNum;   
   1.153 +  var rendering=true;
   1.154 +  if(code[i].type == "info")
   1.155 +   {
   1.156 +    rendering=false; 
   1.157 +    renderinfo=true;
   1.158 +    if(code[i].loop!=null)
   1.159 +     {
   1.160 +      timerNext=code[i].loop;
   1.161 +     }else{
   1.162 +      timerNext=0;
   1.163 +     }            
   1.164 +   } 
   1.165 +  if(code[i].type == "doc")
   1.166 +   { 
   1.167 +    rendering=false; 
   1.168 +    renderdoc=true;
   1.169 +   if(fullscreen==false){
   1.170 +     richdraw.renderer.view(
   1.171 +      code[i].left,
   1.172 +      code[i].top,
   1.173 +      code[i].width,
   1.174 +      code[i].height,
   1.175 +      code[i].viewBox
   1.176 +      ); 
   1.177 +    }else{
   1.178 +     richdraw.renderer.view(
   1.179 +      0,
   1.180 +      0,
   1.181 +      scr_w,
   1.182 +      scr_h,
   1.183 +      code[i].viewBox
   1.184 +      ); 
   1.185 +    
   1.186 +    
   1.187 +    }  
   1.188 +   /*richdraw.renderer.view((code[i].left)?code[i].left:NaN,
   1.189 +    (code[i].top)?code[i].top:NaN,
   1.190 +    (code[i].width)?code[i].width:NaN,
   1.191 +    (code[i].height)?code[i].height:NaN,
   1.192 +    (code[i].viewBox)?code[i].viewBox:''
   1.193 +    */
   1.194 +  
   1.195 +   }
   1.196 +      
   1.197 +  if( rendering==true)
   1.198 +  {
   1.199 +  var co  = richdraw.renderer.create(code[i].type, 
   1.200 +  (code[i].fillColor!=null)?code[i].fillColor:"", 
   1.201 +  (code[i].lineColor)?code[i].lineColor:"", 
   1.202 +  (code[i].fillOpac)?code[i].fillOpac:"", 
   1.203 +  (code[i].lineOpac)?code[i].lineOpac:"", 
   1.204 +  (code[i].lineWidth)?code[i].lineWidth:"", 
   1.205 +  (code[i].left)?code[i].left:"", 
   1.206 +  (code[i].top)?code[i].top:"", 
   1.207 +  (code[i].width)?code[i].width:"", 
   1.208 +  (code[i].height)?code[i].height:"",  
   1.209 +  (code[i].text)?code[i].text:'', 
   1.210 +  (code[i].textSize)?code[i].textSize:"",    
   1.211 +  (code[i].textFamily)?code[i].textFamily:'Arial', 
   1.212 +  (code[i].href)?code[i].href:'', 
   1.213 +  (code[i].points)?code[i].points:'', 
   1.214 +  (code[i].transform)?code[i].transform:'',
   1.215 +  (code[i].parent)?code[i].parent:''); 
   1.216 +  //(code[i].filter)?code[i].filter:'');  
   1.217 +  if(code[i].id==null){
   1.218 +   var nid='shape:' + createUUID(); 
   1.219 +    co.id = nid;
   1.220 +   }else{
   1.221 +    co.id = code[i].id;
   1.222 +   }
   1.223 +   
   1.224 +  //var cad=code[i].points;
   1.225 +  //co.id = ""+code[i].id; 
   1.226 +  //co.addEventListener("click", function(event) { myfunction(this.id); }, false);
   1.227 +  //co.addEventListener("mouseover", function(event) {myOverFunction(this.id); }, false);
   1.228 +  //co.addEventListener("mouseout", function(event) {myOutFunction(this.id); }, false);
   1.229 +  
   1.230 + 
   1.231 +  }
   1.232 +    Ext.get(co).on("mousedown", richdraw.onHit, richdraw);
   1.233 +   
   1.234 + }
   1.235 + if(renderdoc == false)
   1.236 +  { 
   1.237 +   if(fullscreen==false){
   1.238 +    richdraw.renderer.view(0,0,canvasWidth,canvasHeight,'0 0 700 400');   
   1.239 +   }else{
   1.240 +    richdraw.renderer.view(0,0,scr_w,scr_h,'0 0 700 400');
   1.241 +   }
   1.242 +   //richdraw.renderer.view(0,0,document.getElementById("richdraw").style.width,document.getElementById("richdraw").style.height,zoominit);   
   1.243 +
   1.244 +  }  
   1.245 + 
   1.246 + if(renderinfo == false){ 
   1.247 +
   1.248 + }  
   1.249 + 
   1.250 +}
   1.251 +
   1.252 +function load01(code,richdraw){
   1.253 +
   1.254 +for(var i = 0; i < code.length; i++){
   1.255 +
   1.256 +
   1.257 +  var co  = richdraw.renderer.create(code[i].type, //Shape
   1.258 +  (code[i].fillColor)?code[i].fillColor:"red", 
   1.259 +  (code[i].lineColor)?code[i].lineColor:"black", 
   1.260 +  (code[i].fillOpac)?code[i].fillOpac:1,
   1.261 +  (code[i].lineOpac)?code[i].lineOpac:1, 
   1.262 +  (code[i].lineWidth)?code[i].lineWidth:1, 
   1.263 +  (code[i].left)?code[i].left:100,
   1.264 +  (code[i].top)?code[i].top:100, 
   1.265 +  (code[i].width)?code[i].width:100, 
   1.266 +  (code[i].height)?code[i].height:100, 
   1.267 +  (code[i].text)?code[i].text:'',
   1.268 +  (code[i].textSize)?code[i].textSize:19,
   1.269 +  (code[i].textFamily)?code[i].textFamily:'Arial',
   1.270 +  (code[i].href)?code[i].href:'', 
   1.271 +  (code[i].points)?code[i].points:'', 
   1.272 +  (code[i].transform)?code[i].transform:'',
   1.273 +  (code[i].parent)?code[i].parent:''); 
   1.274 + 
   1.275 +
   1.276 +
   1.277 +co.id = "shape:"+code[i].id;
   1.278 +
   1.279 +/*
   1.280 +HACKS! HACKS!! NOT GOOD!!!
   1.281 +*/
   1.282 +if(code[i].type=="polyline"){
   1.283 + 
   1.284 +   //richdraw.renderer.editShape(co,code[i].points)
   1.285 +}else if(code[i].type=="path"){   
   1.286 + 
   1.287 +  // richdraw.renderer.editShape(co,code[i].d)
   1.288 +}else if(code[i].type == "text"){
   1.289 +  //--
   1.290 + //richdraw.renderer.editShape(co,code[i].text,null);
   1.291 + //richdraw.renderer.editShape(co,code[i].text)
   1.292 +}
   1.293 +
   1.294 +/*
   1.295 +End Evil Hacks
   1.296 +*/
   1.297 +
   1.298 +  
   1.299 +//Event.observe(co, "mousedown", richdraw.onHitListener);
   1.300 +
   1.301 +Ext.get(co).on("mousedown", richdraw.onHit, richdraw);
   1.302 +}
   1.303 +
   1.304 +
   1.305 +//create = function(shape, fillColor, lineColor, lineWidth, left, top, width, height)
   1.306 +}
   1.307 +
   1.308 +