
Untitled
By: a guest on
Jul 1st, 2012 | syntax:
None | size: 1.57 KB | hits: 13 | expires: Never
public function flipto(h:Bool, v:Bool, map:PixMap, x:Int, y:Int):Void
{
if (h&&v)
{
var q:Vector<UInt> = getVector(this.rect);
q.reverse();
var tMap:PixMap = new PixMap(width, height, transparent, fillColor);
tMap.setVector(tMap.rect, q);
map.copyPixels(tMap, tMap.rect, new Point(x, y));
}
else if (h)
{
var i:Int = 0;
var r:Rectangle = new Rectangle(0, 0, 1, height);
point.x = width;
point.y = y;
while (i < width)
{
r.x = i;
point.x = x + width - i - 1;
map.copyPixels(this, r, point);
i++;
}
}
else if (v)
{
var i:Int = 0;
var r:Rectangle = new Rectangle(0, 0, width, 1);
point.x = x;
point.y = height;
while (i < height)
{
r.y = i;
point.y = y + height - i - 1;
map.copyPixels(this, r, point);
i++;
}
}
}
//--------May or may not be broken. Haven't used in ages. I THINK it works.
public function rot90(cw:Bool, map:PixMap, x:Int, y:Int):Void
{
if (cw)
{
var i:Int = 0;
var r1:Rectangle = new Rectangle(0, 0, width, 1);
var r2:Rectangle = new Rectangle(x + width, y, 1, width);
while (i < height)
{
r1.y++;
r2.x--;
var v:Vector<UInt> = getVector(r1);
map.setVector(r2, v);
i++;
}
}
else
{
var i:Int = 0;
var r1:Rectangle = new Rectangle(0, 0, 1, height);
var r2:Rectangle = new Rectangle(x, y + height, height, 1);
while (i < width)
{
r1.x++;
r2.y--;
var v:Vector<UInt> = getVector(r1);
map.setVector(r2, v);
i++;
}
}
}