Last active
June 26, 2022 12:52
-
-
Save ManishAradwad/c2608827ba76ba693dd4b3a06d41e5bb to your computer and use it in GitHub Desktop.
Parabolic Gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parabolic_crease(spacing, c, scale=100, corner=1, resolution = 1000): | |
""" | |
Parameters: | |
spacing = controls how close the intermediate values will be to lower value | |
c = higher the c more spread out the gradient will be | |
scale = lesser the scale more concentrated is gradient towards the corner | |
""" | |
img = np.zeros((resolution, resolution)) | |
# Varying the scale parameter of create_uneven_array will give the parabolic gradient transition | |
for i in range(resolution): | |
img[i] = create_uneven_array(255, 0, resolution, spacing + c*i/scale) | |
if corner == 1: | |
return img | |
elif corner == 2: | |
return img[::-1] | |
elif corner == 3: | |
return img.T | |
else: | |
return img.T[::-1] | |
# If cross=1, then cross crease else linear crease is returned | |
def cross_crease(spacing, cross=1, resolution = 1000): | |
a = create_uneven_array(255, 0, resolution, spacing, cross=True) | |
img = np.tile(a, (resolution, 1)) | |
return normalize_img(img*img.T) if cross else img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment