def _make_linear_gradient(width, height, angle=90.):
    """Generates index map for linear gradients."""
    import numpy as np
    X, Y = np.meshgrid(np.linspace(0, 1, width), np.linspace(0, 1, height))
    theta = np.radians(angle % 360)
    c, s = np.cos(theta), np.sin(theta)
    if 0 <= theta and theta < 0.5 * np.pi:
        Z = np.abs(c * X + s * Y)
    elif 0.5 * np.pi <= theta and theta < np.pi:
        Z = np.abs(c * (X - width) + s * Y)
    elif np.pi <= theta and theta < 1.5 * np.pi:
        Z = np.abs(c * (X - width) + s * (Y - height))
    elif 1.5 * np.pi <= theta and theta < 2.0 * np.pi:
        Z = np.abs(c * X + s * (Y - height))
    return (Z - Z.min()) / (Z.max() - Z.min())
def _make_linear_gradient ( width , height , angle = 90. ) : import numpy as np X , Y = np . meshgrid ( np . linspace ( 0 , 1 , width ) , np . linspace ( 0 , 1 , height ) ) theta = np . radians ( angle % 360 ) c , s = np . cos ( theta ) , np . sin ( theta ) if 0 <= theta and theta < 0.5 * np . pi : Z = np . abs ( c * X + s * Y ) elif 0.5 * np . pi <= theta and theta < np . pi : Z = np . abs ( c * ( X - width ) + s * Y ) elif np . pi <= theta and theta < 1.5 * np . pi : Z = np . abs ( c * ( X - width ) + s * ( Y - height ) ) elif 1.5 * np . pi <= theta and theta < 2.0 * np . pi : Z = np . abs ( c * X + s * ( Y - height ) ) return ( Z - Z . min ( ) ) / ( Z . max ( ) - Z . min ( ) )
Generates index map for linear gradients.