Ejemplo n.º 1
0
 public BinNode(PackingObject obj, BinNode parent, Rect rect)
 {
     this.nodes  = new BinNode[2];
     this.parent = parent;
     this.obj    = obj;
     this.rect   = rect;
 }
Ejemplo n.º 2
0
    private bool Add(PackingObject obj, BinNode currNode)
    {
        if (currNode.obj != null)
        {
            if (Add(obj, currNode.nodes[0]) || Add(obj, currNode.nodes[1]))
            {
                return(true);
            }
        }
        else if (currNode.obj == null && currNode.CanPack(obj.rect))
        {
            return(currNode.SetObject(obj, packType));
        }

        return(false);
    }
Ejemplo n.º 3
0
    public bool SetObject(PackingObject obj, PackType packType)
    {
        this.obj = obj;

        if (packType == PackType.LEFT_ALIGN)
        {
            this.nodes[0] = new BinNode(null, this, new Rect(
                                            rect.x + this.obj.rect.width
                                            , rect.y
                                            , rect.width - obj.rect.width
                                            , obj.rect.height
                                            ));
            this.nodes[1] = new BinNode(null, this, new Rect(
                                            rect.x
                                            , rect.y + this.obj.rect.height
                                            , rect.width
                                            , rect.height - obj.rect.height
                                            ));
        }
        else if (packType == PackType.RIGHT_ALIGN)
        {
            this.nodes[0] = new BinNode(null, this, new Rect(
                                            rect.x
                                            , rect.y
                                            , rect.width - obj.rect.width
                                            , obj.rect.height
                                            ));
            this.nodes[1] = new BinNode(null, this, new Rect(
                                            rect.x
                                            , rect.y + this.obj.rect.height
                                            , rect.width
                                            , rect.height - obj.rect.height
                                            ));
            this.rect.x = this.rect.x + this.rect.width - obj.rect.width;
        }

        return(true);
    }
Ejemplo n.º 4
0
 private BinNode CreateNode(PackingObject obj, Rect rect)
 {
     return(new BinNode(obj, null, rect));
 }