Guest User

Untitled

a guest
Feb 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       _context.yScale = _context.xScale;
  2.       var xscale:Float = (1.0 / _context.xScale);
  3.       var yscale:Float = (1.0 / _context.yScale);
  4.  
  5.       var xoffset:Int = Std.int((wClip)/2);
  6.       var yoffset:Int = Std.int((hClip)/2);
  7.      
  8.       var xcos:Float = Math.cos(-_context.rotation) * xscale;
  9.       var xsin:Float = Math.sin(-_context.rotation) * xscale;
  10.       var ycos:Float = Math.cos(-_context.rotation) * yscale;
  11.       var ysin:Float = Math.sin(-_context.rotation) * yscale;
  12.      
  13.  
  14.       var biggest:Int = (wClip>hClip)?wClip:hClip;
  15.       var left:Int = Std.int((-Std.int(((biggest+1)/2)*_context.xScale))*1.5)+xoffset;
  16.       var right:Int = Std.int((Std.int(((biggest-1)/2)*_context.xScale)+1)*1.5)+xoffset;
  17.       var up:Int = Std.int((-Std.int(((biggest+1)/2)*_context.yScale))*1.5)+xoffset;
  18.       var down:Int = Std.int((Std.int(((biggest-1)/2)*_context.yScale)+1)*1.5)+xoffset;
  19.  
  20.      
  21.       var xS:Float = (left-xoffset)*xcos-(up-yoffset)*ysin+xoffset;
  22.       var yS:Float = (left-xoffset)*xsin+(up-yoffset)*ycos+yoffset;
  23.       var i:Int = left;
  24.       var j:Int = up;
  25.  
  26.       while(j<down) {
  27.         var xSR:Float = xS;
  28.         var ySR:Float = yS;
  29.         if(xcos<0&&xSR>wClip) {var amount:Int = Math.floor((wClip-xSR)/xcos);i+=amount;xSR+=xcos*amount;ySR+=xsin*amount;}
  30.         if(xsin<0&&ySR>hClip) {var amount:Int = Math.ceil((hClip-ySR)/xsin);i+=amount;xSR+=xcos*amount;ySR+=xsin*amount;}
  31.         if(xcos>0&&xSR<-1) {var amount:Int = Math.ceil((-1-xSR)/xcos);i+=amount;xSR+=xcos*amount;ySR+=xsin*amount;}
  32.         if(xsin>0&&ySR<-1) {var amount:Int = Math.round((-1-ySR)/xsin);i+=amount;xSR+=xcos*amount;ySR+=xsin*amount;}
  33.         while(i<right) {
  34.           var xSRr:Int = Math.round(xSR);
  35.           var ySRr:Int = Math.round(ySR);
  36.           if(xcos>0&&xSRr>wClip-1||xsin>0&&ySRr>hClip-1||xcos<0&&xSRr<0||xsin<0&&ySRr<0) {xSR+=xcos*(right-i);ySR+=xsin*(right-i);break;}
  37.           _context.target.bitmapdata.setPixel(_x+i,_y+j,0xFF0000);
  38.           if(xSRr>-1&&xSRr<wClip&&ySRr>-1&&ySRr<hClip) {
  39.             _context.target.bitmapdata.setPixel(_x+i,_y+j,0xFFFF00);
  40.             var color:Int=getPixel(xSRr+xClip,ySRr+yClip);
  41.             if(!transparency||color!=0xFF00FF) {
  42.            
  43.             _context.target.bitmapdata.setPixel(_x+i,_y+j,color);
  44.             _context.target.drawPixel(color,_x+i,_y+j);
  45.            
  46.             }
  47.           }
  48.           xSR+=xcos;
  49.           ySR+=xsin;
  50.           i++;
  51.         }
  52.         xS-=ysin;
  53.         yS+=ycos;
  54.         i=left;
  55.         j++;
  56.       }
Add Comment
Please, Sign In to add comment