package ru.m.puzzlez.render;

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

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();
        bitmap.bitmapData = image;
        addChild(bitmap);
    }

}
