[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] [propose] point and rect extensions



As I proposed recently, I want to add basic math and conversion Utilities for Point and Rect.
Any objections about this?
If not, could someone please check them in?
(I've removed strange math methods as discussed with JmC)

regards
Till


+ Point {
    	asArray {
        	^[this.x, this.y]
    	}
   	mod {|that|
        	var thatPoint;
        	thatPoint = that.asPoint;
        	^(this.x mod: thatPoint.x) @ (this.y mod: thatPoint.y)
    	}
}

+ Rect {
    	asArray {
        	^[this.left, this.top, this.width, this.height]
    	}
    	+ {|that|
        	var thatRect;
        	thatRect = that.asRect;

        	^Rect(
            		this.left + thatRect.left,
            		this.top + thatRect.top,
            		this.width + thatRect.width,
            		this.height + thatRect.height
        	)
    	}
    	- {|that|
        	var thatRect;
        	thatRect = that.asRect;

        	^Rect(
            		this.left - thatRect.left,
            		this.top - thatRect.top,
            		this.width - thatRect.width,
            		this.height - thatRect.height
        	)
    	}
}

+ SimpleNumber {
    asRect {
        ^Rect(this, this, this, this)
    }
}

+ Collection {
    asPoint {
        ^Point(this[0] ? 0, this[1] ? 0)
    }
    asRect {
        ^Rect(this[0] ? 0, this[1] ? 0, this[2] ? 0, this[3] ? 0)
    }
}


On 05 Oct 2005, at 15:20, Till Bovermann wrote:

I just want to have a nice possibility to scale either the position or the extend of a Rect...

What about the other extensions?


have a nice day
Till


On 03 Oct 2005, at 19:49, James McCartney wrote:


when is it necessary to multiply two rectangles together?

_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev


_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev