Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var xscale:Float = (1.0 / _context.xScale);
- var yscale:Float = (1.0 / _context.yScale);
- var xoffset:Int = _context.xOrigin;
- var yoffset:Int = _context.yOrigin;
- var xcos:Float = Math.cos(-_context.rotation) * xscale;
- var xsin:Float = Math.sin(-_context.rotation) * xscale;
- var ycos:Float = Math.cos(-_context.rotation) * yscale;
- var ysin:Float = Math.sin(-_context.rotation) * yscale;
- var left:Int = -_x;
- var right:Int = Screen.width-_x;
- var up:Int = -_y;
- var down:Int = Screen.height-_y;
- var xS:Float = left*xcos-up*ysin+xoffset;
- var yS:Float = left*xsin+up*ycos+yoffset;
- var i:Int;
- var j:Int = up;
- var xSR:Float;
- var ySR:Float;
- var color:Int;
- var amount1:Int=0;
- var amount2:Int=0;
- var amount3:Int=0;
- var amount4:Int=0;
- while({xS-=ysin;yS+=ycos;++j<down;}) { // Y-Loop
- // Find the START of the x loop
- amount1 = Std.int( if(xcos<0&&xS>wClip) {(wClip-xS)/xcos+1;} else if(xcos>0&&xS<0) {-xS/xcos+1;} );
- amount2 = Std.int( if(xsin<0&&yS>hClip) {(hClip-yS)/xsin+1;} else if(xsin>0&&yS<0) {-yS/xsin+1;} );
- amount1 = ((amount1<amount2)?amount2:amount1);
- // Find the END of the x loop
- amount3 = Std.int( if(xcos>0&&xS<wClip) {(wClip-xS)/xcos+1;} else if(xcos<0&&xS>0) {-xS/xcos+1;} );
- amount4 = Std.int( if(xsin>0&&yS<hClip) {(hClip-yS)/xsin+1;} else if(xsin<0&&yS>0) {-yS/xsin+1;} );
- amount3 = ((amount3>amount4)?amount4:amount3);
- //_context.target.drawPixel(0xFF0000,30,_y+j);
- // If START is later than END then obviously we shouldn't draw this row (this is a skip-y solution)
- if(amount1>amount3) {continue;} //SKIP
- //_context.target.drawPixel(0xFFFF00,30,_y+j);
- // Set the starting position (this is a jump-x solution)
- i=left+amount1;
- xSR=xS+xcos*amount1-xcos;
- ySR=yS+xsin*amount1-xsin;
- // Set the ending position (this is a jump-x solution)
- right=left+amount3+1;
- // Start the loop
- while({xSR+=xcos;ySR+=xsin;++i<right;}) { // X-Loop
- //_context.target.drawPixel(0xFFFF00,_x+i,30);
- color=getPixel(Std.int(xSR)+xClip,Std.int(ySR)+yClip); // Get the color at a transformed position
- if(color!=0xFF00FF||!transparency) {_context.target.drawPixel(color,_x-1+i+_context.xOrigin,_y-1+j+_context.yOrigin);} // Set the color at an untransformed position
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement