package ru.m.puzzlez.render;

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.PixelSnapping;
import flash.display.Sprite;
import flash.geom.Point;

class PartView extends Sprite {

    public var id(default, null):Int;
    public var position(default, set):Point;

    private function set_position(value:Point):Point {
        position = value.clone();
        x = position.x - (bitmap.bitmapData.width - size.x) / 2;
        y = position.y - (bitmap.bitmapData.height - size.y) / 2;
        return position;
    }

    private var size:Point;
    private var bitmap:Bitmap;

    public function new(id:Int, image:BitmapData, size:Point) {
        super();
        this.id = id;
        this.size = size;
        bitmap = new Bitmap(image, PixelSnapping.ALWAYS, true);
        addChild(bitmap);
    }

}
