# This program was generated by "Generative Art Synthesizer" 
# Generation date: 2021-11-28 09:21:40 UTC 
# GAS change date: 2021-11-28 09:20:21 UTC 
# GAS md5 hash: ad55481e87ca5a7e9a8e92cd336d1cad 
# Python version: 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] 
# For more information visit: https://github.com/volotat/GAS

#import python libraries 
import os #OS version: default 
import numpy as np #Numpy version: 1.19.5 
from PIL import Image #PIL version: 8.1.2 

#set initial params
SIZE = 768 
GRID_CHANNELS = 16 

def test_values(arr):
    if np.isnan(arr).any():
        raise Exception('Array has None elements!') 
        
    if np.amin(arr) < -1 or np.amax(arr) > 1:
        raise Exception('Values went to far! [ %.2f : %.2f ]'%(np.amin(arr), np.amax(arr)) ) 
           
    return arr

#define grid transformation methods

def transit(x, t_indx, s_indx, alphas):
    res = x.copy()
    res[:,:,t_indx] = np.sum(x[:,:,s_indx] * alphas, axis = -1)
    return test_values(res.clip(-1,1)) 

def sin(x, t_indx, s_indx, scale = 1, shift = 0): 
    res = x.copy()
    res[:,:,t_indx] = np.sin(x[:,:,s_indx] * 0.5 * np.pi * scale + shift)
    return test_values(res)     

def magnitude(x, t_indx, s_indx, ord = 2): 
    res = x.copy()
    res[:,:,t_indx] = np.linalg.norm(x[:,:,s_indx], axis = -1, ord = ord) / np.sqrt(len(s_indx))
    return test_values(res)   

def shift(x, t_indx, s_indx, shift):
    res = x.copy()
    if shift > 0: res[:,:,t_indx] = (-np.abs(((x[:,:,s_indx] + 1) / 2) ** (1 + shift) - 1) ** (1 / (1 + shift)) + 1) * 2 - 1
    if shift < 0: res[:,:,t_indx] = np.abs((1 - (x[:,:,s_indx] + 1) / 2) ** (1 - shift) - 1) ** (1 / (1 - shift)) * 2 - 1  
    return test_values(res) 

def inverse(x, t_indx, s_indx): 
    res = x.copy()
    res[:,:,t_indx] = -x[:,:,s_indx] 
    return test_values(res)   

def smooth_max(x, t_indx, s1_indx, s2_indx, p = 10): 
    res = x.copy()
    res[:,:,t_indx] = np.log((np.exp(x[:,:,s1_indx] * p) + np.exp(x[:,:,s2_indx] * p)) ** (1/p)) / 1.07
    return test_values(res)   

def smooth_min(x, t_indx, s1_indx, s2_indx, p = 10): 
    res = x.copy()
    res[:,:,t_indx] = -np.log((np.exp(-x[:,:,s1_indx] * p) + np.exp(-x[:,:,s2_indx] * p)) ** (1/p)) / 1.07
    return test_values(res)   

def prod(x, t_indx, s_indx):
    res = x.copy()
    res[:,:,t_indx] = np.prod(x[:,:,s_indx], -1)
    return test_values(res) 

def power(x, t_indx, s_indx, p = 1): 
    res = x.copy()
    res[:,:,t_indx] = np.sign(x[:,:,s_indx]) * np.abs(x[:,:,s_indx]) ** p 
    return test_values(res)   

#set initial grid
grid = np.zeros((SIZE, SIZE, GRID_CHANNELS))

x = ((np.arange(SIZE)/(SIZE-1) - 0.5) * 2).reshape((1, SIZE)).repeat(SIZE, 0)
y = ((np.arange(SIZE)/(SIZE-1) - 0.5) * 2).reshape((SIZE, 1)).repeat(SIZE, 1)

grid[:,:,0] = (x * 0.9386329219527516 + y * -0.45147169454413794) / 2 
grid[:,:,1] = (x * 0.8090860808441245 + y * 0.2914526739617249) / 2 
grid[:,:,2] = (x * 0.9804797761207309 + y * -0.5063344373124843) / 2 
grid[:,:,3] = (x * -0.8484277738516293 + y * -0.5155435342135386) / 2 
grid[:,:,4] = (x * -0.6644350461377522 + y * 0.1739322518414499) / 2 
grid[:,:,5] = (x * -0.5986715486203882 + y * 0.9515468928881716) / 2 
grid[:,:,6] = (x * 0.2265055481768512 + y * 0.4365452266748293) / 2 
grid[:,:,7] = (x * 0.5049774961793401 + y * 0.05113255120007798) / 2 
grid[:,:,8] = (x * -0.3391983246964396 + y * -0.5135707069423852) / 2 
grid[:,:,9] = (x * -0.4075423366723827 + y * 0.5388833863473126) / 2 
grid[:,:,10] = (x * -0.4262457935185371 + y * -0.6817079327248272) / 2 
grid[:,:,11] = (x * 0.8435706697714382 + y * 0.7746597063144072) / 2 
grid[:,:,12] = (x * -0.5303146721156469 + y * -0.41048419195488317) / 2 
grid[:,:,13] = (x * -0.5864100240508576 + y * -0.9425245660964123) / 2 
grid[:,:,14] = (x * -0.7665883618456049 + y * -0.3867357840809138) / 2 
grid[:,:,15] = (x * 0.49037959172682255 + y * -0.7671554143072785) / 2 

#apply transformations to the grid
grid = transit(grid, 4, [7, 6, 12, 8, 9, 0, 1], [0.05863158300898051, 0.3467981515651057, 0.262107802795733, 0.038001653167336905, 0.2112967596903696, 0.002128256606899112, 0.08103579316557531])
grid = shift(grid, 3, 3, 2.4622222565241207)
grid = sin(grid, 10, 0, 0.5112825397666086, 37.95950546335726)
grid = sin(grid, 12, 13, 3.6938747278005737, 76.37702042567852)
grid = magnitude(grid, 15, [5, 3, 8, 0, 15], 2)
grid = prod(grid, 2, [3, 11, 1])
grid = smooth_min(grid, 3, 2, 7)
grid = smooth_max(grid, 8, 10, 6)
grid = prod(grid, 3, [2, 6, 10, 7, 4])
grid = smooth_min(grid, 7, 12, 0)
grid = transit(grid, 2, [1, 2], [0.9078557995211777, 0.09214420047882232])
grid = smooth_max(grid, 1, 0, 1)
grid = sin(grid, 9, 4, 3.0281102269529683, 11.185401112275173)
grid = sin(grid, 10, 4, 1.2844464834351186, -45.836492724169695)
grid = sin(grid, 1, 2, -1.5301674594368837, -60.29431568717391)
grid = transit(grid, 2, [13, 11, 5], [0.421270391024163, 0.5054038923567993, 0.07332571661903758])
grid = transit(grid, 11, [1, 15, 5, 0, 6, 12, 2, 7, 4], [0.03047869593495055, 0.024092687676923453, 0.02665655056773558, 0.17667886361751853, 0.15211061797378253, 0.016462544099609754, 0.0072484377164178625, 0.4477791048998878, 0.11849249751317383])
grid = transit(grid, 10, [5, 11, 15, 8, 2, 13, 12, 3, 6], [0.1020239434902293, 0.05405846145210329, 0.11525379082942891, 0.11556721863292163, 0.12372657123165616, 0.1356897031789931, 0.20047556686480725, 0.09921434949484752, 0.05399039482501285])
grid = transit(grid, 9, [5], [1.0])
grid = transit(grid, 15, [12, 0, 1, 11], [0.01847979792505241, 0.33442336387003857, 0.15192425697494277, 0.4951725812299663])
grid = sin(grid, 4, 8, 3.386521226555936, 60.95572898751007)
grid = shift(grid, 14, 2, 2.55681173849493)
grid = sin(grid, 10, 14, 0.8649185298731181, 3.1973516320924773)
grid = sin(grid, 9, 7, -2.4657577404884132, 72.95418196004374)
grid = transit(grid, 12, [7, 4, 10, 5], [0.5076634403621766, 0.003404332378773421, 0.04142944289977586, 0.4475027843592742])
grid = inverse(grid, 4, 5)
grid = transit(grid, 1, [4, 14, 0, 13], [0.2785496566747933, 0.004915230889640017, 0.30146401859790545, 0.4150710938376613])
grid = sin(grid, 3, 11, -6.496603906160505, -73.75617586359363)
grid = transit(grid, 6, [6, 14], [0.7201753385758813, 0.2798246614241187])
grid = prod(grid, 4, [10, 0, 2, 4, 8, 5, 6, 7])
grid = transit(grid, 8, [3], [1.0])
grid = inverse(grid, 8, 5)
grid = smooth_max(grid, 10, 5, 13)
grid = sin(grid, 9, 10, -1.8565532127479274, -54.75186223635349)
grid = transit(grid, 10, [14], [1.0])
grid = transit(grid, 15, [11, 4, 10], [0.6926745567135898, 0.1831142410590532, 0.12421120222735695])
grid = magnitude(grid, 7, [6, 12, 7, 13, 8], 2)
grid = transit(grid, 8, [3, 15, 9, 6, 11], [0.036102265915692405, 0.1224495166624379, 0.2384660328868578, 0.3357862916746864, 0.2671958928603256])
grid = smooth_min(grid, 1, 1, 11)
grid = transit(grid, 5, [11, 4, 2, 1, 13, 12, 0, 8], [0.08486049729383285, 0.15069099224942706, 0.024923245737924458, 0.07191051851248272, 0.25942601829807205, 0.16834508849259286, 0.14540219911263502, 0.094441440303033])
grid = transit(grid, 11, [12], [1.0])
grid = power(grid, 3, 5, 0.10200689258338674)
grid = transit(grid, 2, [10, 11, 4, 15, 0, 6], [0.24973877983541862, 0.3378766591098989, 0.15974656746239488, 0.027776085211312595, 0.02330072841260748, 0.20156117996836745])
grid = smooth_min(grid, 0, 5, 1)
grid = magnitude(grid, 0, [5, 0], 2)
grid = transit(grid, 6, [15, 8], [0.5303803951305812, 0.4696196048694189])
grid = inverse(grid, 0, 0)
grid = magnitude(grid, 13, [8], 2)
grid = transit(grid, 13, [15, 5, 9, 4, 6, 12], [0.18067242214638962, 0.12939497982917472, 0.08164480089591167, 0.24583958083442445, 0.2244518823086713, 0.13799633398542827])
grid = transit(grid, 11, [0], [1.0])
grid = magnitude(grid, 0, [4, 13], 2)
grid = transit(grid, 8, [5, 4, 15, 6, 14, 0, 3, 11], [0.13835365002720226, 0.008781149737259792, 0.24627334258742545, 0.04870190081124998, 0.049950480577274, 0.15123046752435387, 0.31255198044446264, 0.04415702829077187])
grid = transit(grid, 1, [3], [1.0])
grid = magnitude(grid, 14, [4], 2)
grid = sin(grid, 1, 5, 8.18216846853571, -6.729427492311089)
grid = magnitude(grid, 11, [8, 2], 2)
grid = transit(grid, 7, [12, 11, 13, 4], [0.1713900685471786, 0.14082681623065177, 0.19859698568682838, 0.4891861295353413])
grid = transit(grid, 13, [12, 15, 9, 2, 0, 1, 5], [0.18796556626817826, 0.19260744772691155, 0.11226112831146452, 0.08161640805634696, 0.08706050582840198, 0.2243337708440404, 0.11415517296465624])
grid = sin(grid, 11, 13, -6.909579361872105, 70.84834564082374)
grid = transit(grid, 2, [11, 7, 13], [0.3629247592109436, 0.10073172896374764, 0.5363435118253088])
grid = sin(grid, 1, 5, 0.6814927249849106, 30.75954926767548)
grid = inverse(grid, 8, 7)
grid = prod(grid, 10, [5, 2])
grid = transit(grid, 15, [0, 3], [0.29345909580747953, 0.7065409041925205])
grid = sin(grid, 12, 4, -1.6398586072056767, 84.51374680259704)
grid = sin(grid, 1, 1, -0.183401440709518, -88.40242580975152)
grid = transit(grid, 12, [3, 13, 2, 9, 0], [0.24803411847529433, 0.2425397323068922, 0.0904752958055755, 0.11683555248582808, 0.30211530092641004])
grid = sin(grid, 5, 2, -2.2972705471452146, -12.522748365129786)
grid = smooth_min(grid, 12, 9, 11)
grid = sin(grid, 4, 15, -1.9527829039221054, 20.537776250912316)
grid = transit(grid, 7, [11, 9, 2], [0.5001532946669459, 0.42070604285213226, 0.07914066248092186])
grid = inverse(grid, 5, 12)
grid = sin(grid, 10, 2, 0.9155140652310594, -34.1653400637653)
grid = transit(grid, 8, [14], [1.0])
grid = transit(grid, 4, [1, 12, 15, 13, 3], [0.32356965941479515, 0.022696478437764827, 0.2132573540073865, 0.11957266769813353, 0.3209038404419199])
grid = transit(grid, 6, [1, 7, 0, 2, 9, 4, 8], [0.06904450551777742, 0.12680650314665426, 0.1756104206123629, 0.013987480750913602, 0.1337935702206657, 0.39097327478734406, 0.08978424496428203])
grid = smooth_min(grid, 9, 9, 10)
grid = shift(grid, 8, 1, -0.2952350240798842)
grid = sin(grid, 11, 6, 1.576100090732909, -21.508000199215132)
grid = shift(grid, 11, 5, 1.0526879494498724)
grid = transit(grid, 1, [14], [1.0])
grid = transit(grid, 8, [9, 10, 2, 15, 13], [0.3265190472987195, 0.21568397721657098, 0.06226802479442838, 0.0028158122366541832, 0.39271313845362693])
grid = magnitude(grid, 11, [13, 10, 12, 2, 11, 14], 2)
grid = transit(grid, 12, [8, 11, 3], [0.2717231795161624, 0.38648847983305307, 0.3417883406507845])
grid = transit(grid, 15, [7, 3], [0.9172074355564371, 0.08279256444356292])
grid = transit(grid, 13, [1, 2, 7, 5, 8, 9, 15], [0.085742434722219, 0.4119764535375412, 0.08377067725345017, 0.13045782410775286, 0.02917564277599849, 0.12489006625007311, 0.13398690135296518])
grid = transit(grid, 2, [2, 0, 11, 10, 5, 4, 15, 13], [0.1869735689344564, 0.06343641920215143, 0.038951322931441136, 0.04613309733662021, 0.19750663742298355, 0.16072124228620793, 0.15869932715876592, 0.14757838472737334])
grid = transit(grid, 2, [1, 7], [0.18247956114317448, 0.8175204388568255])
grid = transit(grid, 8, [11, 15, 0], [0.08195235243098883, 0.6796005904358621, 0.23844705713314918])
grid = power(grid, 14, 0, 0.10854801586669052)
grid = shift(grid, 8, 9, 2.766857264282361)
grid = transit(grid, 3, [6, 14, 0, 3, 15, 4, 2, 11, 13], [0.03597236183123865, 0.04938629068404894, 0.08457069101219464, 0.014801187461296406, 0.3649334871683411, 0.28062233683539095, 0.08637063851194285, 0.06076815802338077, 0.022574848472165728])
grid = transit(grid, 4, [11, 4, 15, 10, 8, 5, 2, 3], [0.23701292672659616, 0.08316792464084911, 0.017867439461611043, 0.36417402420248035, 0.02841485585755143, 0.19916101840344472, 0.03422984110049058, 0.03597196960697647])
grid = magnitude(grid, 13, [11, 7], 2)
grid = sin(grid, 4, 8, 4.28026157040775, -75.14180284322572)
grid = prod(grid, 3, [14, 15])
grid = inverse(grid, 5, 5)
grid = transit(grid, 4, [8, 4, 15, 9, 10], [0.10267794314653868, 0.019022820046952493, 0.061606568183823145, 0.4832751235896067, 0.33341754503307897])
grid = transit(grid, 13, [10, 8, 9, 12, 2], [0.031587088727564654, 0.024264739611302585, 0.0306940545567164, 0.19611241111174804, 0.7173417059926683])
grid = transit(grid, 0, [7, 1, 11, 0, 15], [0.036901331671075975, 0.5054281720479712, 0.13288430351514774, 0.10820806749406277, 0.21657812527174225])
grid = transit(grid, 3, [7, 3, 12, 9], [0.13643904772292245, 0.38438336340747, 0.15936221296996333, 0.31981537589964426])
grid = sin(grid, 10, 3, -2.5681840787633137, -30.256455817944243)
grid = sin(grid, 8, 2, 3.501615294498545, -75.50049353340206)
grid = prod(grid, 9, [1, 4, 0, 6])
grid = transit(grid, 8, [9, 3], [0.30088974760959275, 0.6991102523904072])
grid = transit(grid, 8, [2, 11, 15, 4, 1, 0, 14], [0.29712982335534416, 0.2526657169525107, 0.08415696601637544, 0.18541009701166816, 0.011062110917544764, 0.017334502896306194, 0.1522407828502505])
grid = prod(grid, 2, [8, 7, 11, 10, 15, 0, 5])
grid = transit(grid, 11, [7, 2, 3, 9, 5], [0.24039798004748805, 0.2886075990223525, 0.18742374307846998, 0.11615833154358073, 0.16741234630810867])
grid = prod(grid, 0, [0, 1, 2, 14])
grid = prod(grid, 9, [10, 11, 8, 15, 0, 12, 3])
grid = transit(grid, 13, [5, 15, 10], [0.13237609957996088, 0.22944646977966682, 0.6381774306403722])
grid = transit(grid, 6, [15], [1.0])
grid = sin(grid, 15, 0, -0.033265790773207085, 51.94880270063618)
grid = smooth_min(grid, 13, 10, 15)
grid = transit(grid, 1, [12, 8, 10, 4, 2], [0.43102537693091664, 0.25433300797798253, 0.21618454566402304, 0.046743011673522995, 0.05171405775355483])
grid = sin(grid, 10, 10, 0.9558311639914843, -47.618914508652054)
grid = shift(grid, 9, 8, -1.1449289879251126)
grid = transit(grid, 7, [4, 10, 1, 13, 5, 0, 7, 8, 9, 12, 6, 11, 14], [0.10006330804326793, 0.03891760159161208, 0.005474465860804227, 0.12962618248625338, 0.03090992138168193, 0.016043163973997736, 0.13259375374543056, 0.09920705802758992, 0.1415090600653345, 0.09597789664069131, 0.06106766497801195, 0.14032187015082653, 0.008288053054498123])
grid = prod(grid, 15, [12, 15])
grid = prod(grid, 8, [11, 7, 4, 12])
grid = transit(grid, 7, [15, 6, 2, 7], [0.45073658968521574, 0.16060948991238613, 0.12949271785123345, 0.2591612025511646])
grid = transit(grid, 10, [11, 4, 2, 8, 14], [0.3705316303566195, 0.1755951969700656, 0.043989590834687294, 0.22866693087969006, 0.1812166509589377])
grid = sin(grid, 4, 2, -3.329894296119046, -76.41676919069447)
grid = smooth_min(grid, 11, 8, 12)
grid = transit(grid, 1, [1, 14, 8], [0.38986786543390084, 0.40057743619803005, 0.20955469836806906])
grid = transit(grid, 9, [5], [1.0])
grid = shift(grid, 9, 13, -5.367438086043798)
grid = magnitude(grid, 13, [2, 0], 2)
grid = transit(grid, 13, [6, 2, 3, 15, 5, 7], [0.06492287400539203, 0.21223490901058306, 0.36311130408652753, 0.09994467226348329, 0.12833432959710458, 0.1314519110369097])
grid = transit(grid, 8, [6, 2], [0.6857167761482571, 0.31428322385174284])
grid = shift(grid, 6, 15, 4.115946851379848)
grid = transit(grid, 15, [13, 3], [0.5897775709748927, 0.41022242902510725])
grid = sin(grid, 12, 14, 1.097917736937588, 58.87772371184383)
grid = transit(grid, 11, [9, 11], [0.37033495928182997, 0.6296650407181701])
grid = smooth_min(grid, 4, 1, 8)
grid = sin(grid, 4, 4, 3.47544933993972, -37.11795195118333)
grid = sin(grid, 11, 7, -0.3409112713023047, 75.93313567333723)
grid = transit(grid, 11, [5, 10, 7], [0.22694849313985146, 0.5162695719847235, 0.25678193487542517])
grid = sin(grid, 9, 9, -4.261918262131112, 18.680580924548693)
grid = smooth_max(grid, 2, 2, 11)
grid = sin(grid, 13, 13, 7.718114740496995, 55.242200715207815)
grid = sin(grid, 12, 10, -3.1151555334821888, 17.571856948335267)
grid = prod(grid, 6, [2, 4, 13])
grid = transit(grid, 5, [1, 9, 3, 10, 4], [0.24075568684771534, 0.02527375632067568, 0.4828116495090197, 0.09546712897709621, 0.15569177834549294])
grid = sin(grid, 6, 3, -0.1377650382373763, -96.34412250071645)
grid = sin(grid, 7, 3, 1.6405444007982959, -37.09230830685477)
grid = transit(grid, 9, [8], [1.0])
grid = sin(grid, 5, 10, -1.5052434957207308, 24.900059771988836)
grid = sin(grid, 8, 10, 2.5947698108630664, -90.74050288622541)
grid = sin(grid, 9, 8, -0.8743741598911887, 15.92872484723533)
grid = transit(grid, 4, [3, 13, 9, 8, 5, 2, 12], [0.05731677054419865, 0.08527765171582982, 0.33929504571762287, 0.1932983536368378, 0.0036374435750729187, 0.12289545051895708, 0.19827928429148084])
grid = transit(grid, 8, [13, 9, 5, 7, 14], [0.05801706264076675, 0.341923243761946, 0.0494872820880747, 0.29583940098242745, 0.2547330105267852])
grid = inverse(grid, 11, 5)
grid = magnitude(grid, 14, [4, 6, 1, 0], 2)
grid = transit(grid, 13, [11, 0], [0.6569516962992897, 0.3430483037007103])
grid = sin(grid, 14, 5, 0.053526366336325744, 4.147364704932215)
grid = transit(grid, 4, [3], [1.0])
grid = sin(grid, 3, 12, -4.078686662791614, 24.459526349523884)
grid = inverse(grid, 15, 10)
grid = shift(grid, 6, 1, -1.115193397983063)
grid = smooth_max(grid, 13, 3, 8)
grid = transit(grid, 13, [13, 0, 5, 14], [0.09662806703796267, 0.1621478194912538, 0.21548762580464817, 0.5257364876661353])
grid = inverse(grid, 1, 0)
grid = smooth_max(grid, 1, 15, 12)
grid = prod(grid, 11, [3])
grid = smooth_max(grid, 8, 11, 15)
grid = sin(grid, 12, 6, -3.621533174445339, 24.02414911462421)
grid = sin(grid, 1, 11, 0.5071121900678415, 10.950101187785563)
grid = shift(grid, 13, 3, 5.677279514103952)
grid = transit(grid, 3, [15, 11, 2, 8, 0], [0.28772794692354614, 0.1935939805514465, 0.06024872230823076, 0.13457223936247906, 0.32385711085429764])
grid = transit(grid, 1, [7, 2, 6, 1, 4, 0], [0.2070905138265326, 0.06562120796792839, 0.17355051228662716, 0.05514926535269553, 0.0829726599151083, 0.41561584065110807])
grid = transit(grid, 2, [0, 4, 2], [0.010597803396528332, 0.7371576932264431, 0.25224450337702853])
grid = sin(grid, 11, 8, 4.303514875116891, -67.11152580467314)
grid = prod(grid, 5, [3, 9, 2])
grid = sin(grid, 5, 1, 2.0751861425380627, 63.37681521624819)
grid = smooth_min(grid, 11, 10, 9)
grid = sin(grid, 13, 2, 4.295107938126156, 57.378601701270014)
grid = sin(grid, 10, 2, -0.010214061334835559, 20.43114218394348)
grid = transit(grid, 8, [1], [1.0])
grid = sin(grid, 4, 9, 0.2366252211469413, -40.63773874328931)
grid = sin(grid, 9, 15, -2.507870105026106, -89.43842740853354)
grid = transit(grid, 0, [12, 6, 4, 9, 1, 0, 14], [0.36336761526831185, 0.17372789204937897, 0.08036453739500136, 0.09747098994785518, 0.040818441056887325, 0.16796111771248814, 0.07628940657007711])
grid = transit(grid, 3, [11, 1, 12, 9, 0, 8, 15, 2, 10, 14], [0.20381942291270427, 0.07753380798970702, 0.11445683149439734, 0.08475226158626031, 0.1416941580568898, 0.020968563089492034, 0.0847896752697893, 0.0921589665387646, 0.008240731277180186, 0.17158558178481512])
grid = transit(grid, 5, [11, 10], [0.9817011300708863, 0.018298869929113594])
grid = sin(grid, 14, 8, -0.4693746108213766, -98.17810769380118)
grid = sin(grid, 12, 10, 3.6427863324838423, 99.297524709649)
grid = sin(grid, 5, 14, -1.45141083652418, -99.85812912291547)
grid = transit(grid, 0, [4, 3, 8], [0.23275058190778222, 0.49901982570530873, 0.2682295923869092])
grid = magnitude(grid, 8, [10, 9, 12, 4, 7, 15], 2)
grid = sin(grid, 12, 7, 1.439019575760617, 13.126437741104823)
grid = transit(grid, 10, [15, 8, 13, 2], [0.32464063956303774, 0.20922781529873477, 0.16179927966914437, 0.30433226546908315])
grid = magnitude(grid, 6, [14, 5, 13, 11, 2, 9], 2)
grid = sin(grid, 9, 5, -5.606152225672729, -35.928477282758536)
grid = transit(grid, 0, [7, 11, 15, 8, 12, 0, 4, 14, 3, 5], [0.11084510086381213, 0.003439701966452383, 0.10819642722960272, 0.15371289739415475, 0.25812192912399506, 0.005727171643985687, 0.14633649245899077, 0.033890406689391105, 0.05550396325806974, 0.1242259093715456])
grid = smooth_max(grid, 10, 15, 10)
grid = transit(grid, 11, [9, 0, 11, 7, 3, 8], [0.03500911832175082, 0.03265868671024263, 0.3248025339288217, 0.4234363710484886, 0.13338109758306646, 0.050712192407629864])
grid = transit(grid, 7, [14, 2, 13, 1, 11, 3, 8, 7], [0.207462236904601, 0.11516125867317799, 0.12240760599022518, 0.05066197369764289, 0.13869178538077429, 0.09948828746526778, 0.16686217850764798, 0.09926467338066268])
grid = transit(grid, 6, [6, 13, 7], [0.16813621041531998, 0.42150135317124293, 0.410362436413437])
grid = inverse(grid, 6, 6)
grid = sin(grid, 7, 15, -4.9164570678736865, 86.15931416043557)
grid = sin(grid, 1, 7, 1.6265187305620117, -97.13150019385894)
grid = transit(grid, 11, [0, 9], [0.1290607634325389, 0.8709392365674611])
grid = transit(grid, 14, [14, 13, 15], [0.530662002197574, 0.1082014600047566, 0.36113653779766947])
grid = transit(grid, 14, [10, 14, 4, 9, 13, 6], [0.3199750359220948, 0.07376266150860299, 0.03622483092076182, 0.09070212266434277, 0.4030414045204916, 0.07629394446370606])
grid = magnitude(grid, 13, [7, 4, 15], 2)
grid = transit(grid, 13, [6, 15, 11, 9, 12], [0.21908823570589997, 0.1636179110868493, 0.03797238284324163, 0.29532957711092916, 0.2839918932530799])
grid = sin(grid, 4, 3, 2.634465399239887, 62.07538440217337)
grid = sin(grid, 7, 2, 3.41043792019894, 65.36615977552518)
grid = transit(grid, 0, [14, 3, 11, 10, 7], [0.5203714128788618, 0.068511863728177, 0.10141059844877331, 0.2728285912351676, 0.036877533709020166])
grid = transit(grid, 7, [11], [1.0])
grid = transit(grid, 5, [9, 13, 3, 14], [0.28064413535886806, 0.5181512474389621, 0.1504742947642479, 0.050730322437922])
grid = prod(grid, 1, [12, 13])
grid = sin(grid, 6, 14, -1.927951619591129, -65.3028706482776)
grid = prod(grid, 14, [13])
grid = sin(grid, 1, 12, -0.5111321725063378, 18.261359970959475)
grid = power(grid, 6, 5, 0.9223892145169746)
grid = transit(grid, 2, [9, 11, 10], [0.2662646690994658, 0.2460545507972383, 0.4876807801032959])
grid = transit(grid, 2, [7], [1.0])
grid = sin(grid, 10, 9, 6.219381309190064, -71.03631884776823)
grid = sin(grid, 9, 6, 1.6821417847846682, -64.12547446801875)
grid = sin(grid, 13, 3, -0.15800274281797377, 90.63950889076133)
grid = sin(grid, 14, 14, -1.842523240371888, 74.23947694195837)
grid = inverse(grid, 7, 8)
grid = smooth_max(grid, 10, 3, 15)
grid = magnitude(grid, 9, [15, 7], 2)
grid = transit(grid, 4, [4, 12, 14, 15, 7, 1], [0.20378471182464508, 0.038241020379710625, 0.16903312106740406, 0.3387613981701764, 0.11303295854369695, 0.13714679001436697])
grid = transit(grid, 4, [14, 11, 12, 13, 4, 7], [0.23221079251346607, 0.3307147367708056, 0.26199556841553734, 0.018127231672754242, 0.13788777275073352, 0.01906389787670339])
grid = sin(grid, 4, 7, 3.7705302330112063, 56.91558505626969)
grid = sin(grid, 3, 9, 1.4275963527158242, -76.78247379244436)
grid = sin(grid, 2, 5, -5.225820110717917, 57.71107021356826)
grid = transit(grid, 2, [12], [1.0])
grid = prod(grid, 14, [11, 10])
grid = transit(grid, 2, [0, 15, 10], [0.005204838856346087, 0.5116602651328436, 0.48313489601081044])
grid = transit(grid, 10, [10], [1.0])
grid = transit(grid, 1, [8, 10, 15, 14, 9], [0.33493798319460544, 0.14040206011900094, 0.3010385316537353, 0.07412413198773361, 0.14949729304492473])
grid = magnitude(grid, 10, [11, 0, 5], 2)
grid = magnitude(grid, 9, [15, 3, 11, 0, 14], 2)
grid = sin(grid, 4, 5, -1.8457292172108153, -53.43885199947502)
grid = sin(grid, 10, 0, 7.741409383532979, -12.082110529508299)
grid = prod(grid, 11, [9])
grid = sin(grid, 4, 3, 0.10154488887533689, 12.479110491961137)
grid = magnitude(grid, 1, [7], 2)
grid = smooth_min(grid, 7, 4, 13)
grid = magnitude(grid, 5, [7], 2)
grid = transit(grid, 6, [9, 11, 2, 13], [0.381505247910628, 0.12073241493361198, 0.3454992433435407, 0.15226309381221942])
grid = magnitude(grid, 10, [7, 15, 5], 2)
grid = magnitude(grid, 9, [12, 14, 4], 2)
grid = shift(grid, 3, 9, 3.0393348894939773)
grid = shift(grid, 2, 4, 2.1961962516242517)
grid = prod(grid, 15, [3, 5, 0, 1])
grid = sin(grid, 6, 11, -0.7697482296056479, 23.55348445076298)
grid = sin(grid, 7, 7, 0.5492744322205282, 35.873568370773654)
grid = transit(grid, 7, [13], [1.0])
grid = sin(grid, 3, 12, 6.470760426148978, -53.62090724330151)
grid = sin(grid, 10, 10, 0.7827958631857042, -90.82177259964699)
grid = transit(grid, 6, [8, 6, 5, 7, 4, 2], [0.39579476392315127, 0.3200094081197146, 0.06439062651950353, 0.03284446726347166, 0.04732779189481446, 0.13963294227934445])
grid = smooth_min(grid, 0, 13, 15)
grid = smooth_max(grid, 5, 8, 4)
grid = transit(grid, 10, [1], [1.0])
grid = transit(grid, 15, [15], [1.0])
grid = prod(grid, 13, [6, 3, 7])
grid = sin(grid, 0, 3, -3.561651028660104, 11.539889679902203)
grid = power(grid, 10, 5, 0.12539493928522222)
grid = power(grid, 0, 12, 2.5526439221510495)
grid = sin(grid, 4, 10, -3.680544885171134, 30.633332441673872)
grid = transit(grid, 11, [12, 6, 9], [0.1597221050818672, 0.523275926379751, 0.31700196853838186])
grid = sin(grid, 14, 7, 5.409920766787869, -58.09956716630187)
grid = sin(grid, 2, 15, -2.5319898824657017, -45.01904701883333)
grid = shift(grid, 5, 5, 3.1584260780059252)
grid = transit(grid, 10, [9, 8], [0.7777441717493406, 0.22225582825065934])
grid = transit(grid, 3, [9], [1.0])
grid = transit(grid, 11, [2], [1.0])

#create color space 
def shift_colors(x, shift):
    res = x.copy()
    for i in range(x.shape[-1]):
        if shift[i] > 0: res[:,:,i] = (-np.abs(((x[:,:,i] + 1) / 2) ** (1 + shift[i]) - 1) ** (1 / (1 + shift[i])) + 1) * 2 - 1
        if shift[i] < 0: res[:,:,i] = np.abs((1 - (x [:,:,i]+ 1) / 2) ** (1 - shift[i]) - 1) ** (1 / (1 - shift[i])) * 2 - 1  
    return test_values(res) 

res = np.zeros((SIZE, SIZE, 3)) 
res += shift_colors(grid[:,:,0:1].repeat(3, -1), [1.9355805467383669, 1.4677093499726706, 1.2451388311186942]) 

res = res / 1 
res = ((res + 1) / 2 * 255).clip(0,255) 

#save results 
im = Image.fromarray(np.uint8(res))
im.save(os.path.basename(__file__) + '.png')

#save layers
img = np.zeros((SIZE * 4, SIZE * 4))
for j in range(GRID_CHANNELS):
    x = j % 4
    y = j // 4
    img[x*SIZE:(x + 1)*SIZE, y*SIZE:(y+1)*SIZE] = grid[:,:,j]

img = (img + 1) * 127.5 
im = Image.fromarray(np.uint8(img))
im.save(os.path.basename(__file__) + '_layers.png')


[((75, 7, 75, 44), 'numpy.zeros', 'np.zeros', ({(75, 16, 75, 43): '(SIZE, SIZE, GRID_CHANNELS)'}, {}), '((SIZE, SIZE, GRID_CHANNELS))', True, 'import numpy as np\n'), ((379, 6, 379, 31), 'numpy.zeros', 'np.zeros', ({(379, 15, 379, 30): '(SIZE, SIZE, 3)'}, {}), '((SIZE, SIZE, 3))', True, 'import numpy as np\n'), ((390, 6, 390, 36), 'numpy.zeros', 'np.zeros', ({(390, 15, 390, 35): '(SIZE * 4, SIZE * 4)'}, {}), '((SIZE * 4, SIZE * 4))', True, 'import numpy as np\n'), ((30, 22, 30, 63), 'numpy.sum', 'np.sum', (), '', True, 'import numpy as np\n'), ((35, 22, 35, 73), 'numpy.sin', 'np.sin', ({(35, 29, 35, 72): 'x[:, :, (s_indx)] * 0.5 * np.pi * scale + shift'}, {}), '(x[:, :, (s_indx)] * 0.5 * np.pi * scale + shift)', True, 'import numpy as np\n'), ((66, 22, 66, 48), 'numpy.prod', 'np.prod', ({(66, 30, 66, 43): 'x[:, :, (s_indx)]', (66, 45, 66, 47): '-1'}, {}), '(x[:, :, (s_indx)], -1)', True, 'import numpy as np\n'), ((386, 21, 386, 34), 'numpy.uint8', 'np.uint8', ({(386, 30, 386, 33): 'res'}, {}), '(res)', True, 'import numpy as np\n'), ((397, 21, 397, 34), 'numpy.uint8', 'np.uint8', ({(397, 30, 397, 33): 'img'}, {}), '(img)', True, 'import numpy as np\n'), ((40, 22, 40, 73), 'numpy.linalg.norm', 'np.linalg.norm', (), '', True, 'import numpy as np\n'), ((71, 22, 71, 44), 'numpy.sign', 'np.sign', ({(71, 30, 71, 43): 'x[:, :, (s_indx)]'}, {}), '(x[:, :, (s_indx)])', True, 'import numpy as np\n'), ((387, 8, 387, 34), 'os.path.basename', 'os.path.basename', ({(387, 25, 387, 33): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((398, 8, 398, 34), 'os.path.basename', 'os.path.basename', ({(398, 25, 398, 33): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((18, 7, 18, 20), 'numpy.isnan', 'np.isnan', ({(18, 16, 18, 19): 'arr'}, {}), '(arr)', True, 'import numpy as np\n'), ((21, 7, 21, 19), 'numpy.amin', 'np.amin', ({(21, 15, 21, 18): 'arr'}, {}), '(arr)', True, 'import numpy as np\n'), ((21, 28, 21, 40), 'numpy.amax', 'np.amax', ({(21, 36, 21, 39): 'arr'}, {}), '(arr)', True, 'import numpy as np\n'), ((71, 47, 71, 68), 'numpy.abs', 'np.abs', ({(71, 54, 71, 67): 'x[:, :, (s_indx)]'}, {}), '(x[:, :, (s_indx)])', True, 'import numpy as np\n'), ((22, 63, 22, 75), 'numpy.amin', 'np.amin', ({(22, 71, 22, 74): 'arr'}, {}), '(arr)', True, 'import numpy as np\n'), ((22, 77, 22, 89), 'numpy.amax', 'np.amax', ({(22, 85, 22, 88): 'arr'}, {}), '(arr)', True, 'import numpy as np\n'), ((46, 36, 46, 92), 'numpy.abs', 'np.abs', ({(46, 43, 46, 91): '((1 - (x[:, :, (s_indx)] + 1) / 2) ** (1 - shift) - 1)'}, {}), '((1 - (x[:, :, (s_indx)] + 1) / 2) ** (1 - shift) - 1)', True, 'import numpy as np\n'), ((56, 30, 56, 56), 'numpy.exp', 'np.exp', ({(56, 37, 56, 55): '(x[:, :, (s1_indx)] * p)'}, {}), '(x[:, :, (s1_indx)] * p)', True, 'import numpy as np\n'), ((56, 59, 56, 85), 'numpy.exp', 'np.exp', ({(56, 66, 56, 84): '(x[:, :, (s2_indx)] * p)'}, {}), '(x[:, :, (s2_indx)] * p)', True, 'import numpy as np\n'), ((61, 31, 61, 58), 'numpy.exp', 'np.exp', ({(61, 38, 61, 57): '(-x[:, :, (s1_indx)] * p)'}, {}), '(-x[:, :, (s1_indx)] * p)', True, 'import numpy as np\n'), ((61, 61, 61, 88), 'numpy.exp', 'np.exp', ({(61, 68, 61, 87): '(-x[:, :, (s2_indx)] * p)'}, {}), '(-x[:, :, (s2_indx)] * p)', True, 'import numpy as np\n'), ((376, 38, 376, 92), 'numpy.abs', 'np.abs', ({(376, 45, 376, 91): '((1 - (x[:, :, (i)] + 1) / 2) ** (1 - shift[i]) - 1)'}, {}), '((1 - (x[:, :, (i)] + 1) / 2) ** (1 - shift[i]) - 1)', True, 'import numpy as np\n'), ((45, 38, 45, 90), 'numpy.abs', 'np.abs', ({(45, 45, 45, 89): '(((x[:, :, (s_indx)] + 1) / 2) ** (1 + shift) - 1)'}, {}), '(((x[:, :, (s_indx)] + 1) / 2) ** (1 + shift) - 1)', True, 'import numpy as np\n'), ((77, 6, 77, 21), 'numpy.arange', 'np.arange', ({(77, 16, 77, 20): 'SIZE'}, {}), '(SIZE)', True, 'import numpy as np\n'), ((78, 6, 78, 21), 'numpy.arange', 'np.arange', ({(78, 16, 78, 20): 'SIZE'}, {}), '(SIZE)', True, 'import numpy as np\n'), ((375, 40, 375, 90), 'numpy.abs', 'np.abs', ({(375, 47, 375, 89): '(((x[:, :, (i)] + 1) / 2) ** (1 + shift[i]) - 1)'}, {}), '(((x[:, :, (i)] + 1) / 2) ** (1 + shift[i]) - 1)', True, 'import numpy as np\n')]