def as_vec4(obj, default=(0, 0, 0, 1)):
 obj = np.atleast_2d(obj)
 if (obj.shape[(-1)] < 4):
  new = np.empty((obj.shape[:(-1)] + (4,)), dtype=obj.dtype)
  new[:] = default
  new[..., :obj.shape[(-1)]] = obj
  obj = new
 elif (obj.shape[(-1)] > 4):
  raise TypeError(('Array shape %s cannot be converted to vec4' % obj.shape))
 return obj

def as_vec4 ( obj , default = ( 0 , 0 , 0 , 1 ) ) : obj = np . atleast_2d ( obj ) if ( obj . shape [ ( - 1 ) ] < 4 ) : new = np . empty ( ( obj . shape [ : ( - 1 ) ] + ( 4 , ) ) , dtype = obj . dtype ) new [ : ] = default new [ ... , : obj . shape [ ( - 1 ) ] ] = obj obj = new elif ( obj . shape [ ( - 1 ) ] > 4 ) : raise TypeError ( ( 'Array shape %s cannot be converted to vec4' % obj . shape ) ) return obj
convert obj to 4-element vector parameters obj : array-like original object .