Two new functions:

- vectorLength(vector): calculate the length of a vector
- asInt16(): round and cast any array (or number) to 16 bit ints


git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@69 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
Just 2000-01-26 19:32:45 +00:00
parent 56804d237a
commit deb3b632f4

View File

@ -1,5 +1,5 @@
#
# This module should move to a more appropriate location
# Various array and rectangle tools
#
import Numeric
@ -16,7 +16,6 @@ def calcBounds(array):
xmax, ymax = Numeric.maximum.reduce(array)
return xmin, ymin, xmax, ymax
def pointsInRect(array, rect):
"""Find out which points or array are inside rect.
Returns an array with a boolean for each point.
@ -30,6 +29,13 @@ def pointsInRect(array, rect):
Numeric.less(array, rightbottom))
return Numeric.logical_and.reduce(condition, -1)
def vectorLength(vector):
return Numeric.sqrt(vector[0]**2 + vector[1]**2)
def asInt16(array):
"Round and cast to 16 bit integer."
return Numeric.floor(array + 0.5).astype(Numeric.Int16)
def normRect((l, t, r, b)):
"""XXX doc"""