Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function resize(width:int, height:int):void
- {
- if (usePositions)
- {
- width /= _tile.width;
- height /= _tile.height;
- }
- _temp = _map.clone();
- _map = new BitmapData(width, height, false, 0);
- _map.copyPixels(_temp, _map.rect, FP.zero);
- _temp = new BitmapData(width, height, false, 0);
- resizeCanvas(width * _tile.width, height * _tile.height);
- updateAll();
- _columns = width;
- _rows = height;
- }
- //Then on canvas you modify:
- public function Canvas(width:uint, height:uint)
- {
- resizeCanvas(width, height);
- }
- public function resizeCanvas(width:uint, height:uint):void
- {
- _width = width;
- _height = height;
- _refWidth = Math.ceil(width / _maxWidth);
- _refHeight = Math.ceil(height / _maxHeight);
- _ref = new BitmapData(_refWidth, _refHeight, false, 0);
- var x:uint, y:uint, w:uint, h:uint, i:uint,
- ww:uint = _width % _maxWidth,
- hh:uint = _height % _maxHeight;
- if (!ww) ww = _maxWidth;
- if (!hh) hh = _maxHeight;
- while (y < _refHeight)
- {
- h = y < _refHeight - 1 ? _maxHeight : hh;
- while (x < _refWidth)
- {
- w = x < _refWidth - 1 ? _maxWidth : ww;
- _ref.setPixel(x, y, i);
- _buffers[i] = new BitmapData(w, h, true, 0);
- i ++; x ++;
- }
- x = 0; y ++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement