return 0 #x = pixel_size * (curx + w2) #y = pixel_size * (cury + h2) x = pixel_size * (w2 + curx) y = pixel_size * (w2 + cury) sam.x = x sam.y = y sam.ix = curx sam.iy = cury return 1 """ args1 = arg_map([('endx', 0), ('endy', 0), ('tilex', 0), ('tiley', 0), ('pixel_size', 1.0), ('curx', 0), ('cury', 0), ('w2', 0.0), ('h2', 0.0)]) args2 = arg_list([('sam', sample)]) sample_shader = create_shader("generate_sample", code2, args1, args2, func=True) #print(sample_shader._code) arg_map1 = arg_map([('x', 0.0)]) code = """ sam = sample() ret = 1 while ret != 0: ret = generate_sample(sam) x = sam.y """ runtimes = [Runtime()] shader = create_shader("test", code, arg_map1, shaders=[sample_shader])
#x = pixel_size * (curx + w2) #y = pixel_size * (cury + h2) x = pixel_size * (w2 + curx) y = pixel_size * (w2 + cury) sam.x = x sam.y = y sam.ix = curx sam.iy = cury return 1 """ args1 = arg_map([('endx', 0), ('endy', 0), ('tilex', 0), ('tiley', 0), ('pixel_size', 1.0), ('curx', 0), ('cury', 0), ('w2', 0.0), ('h2', 0.0)]) args2 = arg_list([('sam', sample)]) sample_shader = create_shader("generate_sample", code2, args1, args2, func=True) #print(sample_shader._code) arg_map1 = arg_map([('x', 0.0)]) code = """ sam = sample() ret = 1 while ret != 0: ret = generate_sample(sam) x = sam.y """
from tdasm import Runtime from renmas3.base import create_shader, arg_map, Integer, Float, Vec3 from renmas3.base import create_function, arg_list runtimes = [Runtime()] code2 = """ #input a = float, b = int a = b return a """ arg_lst1 = arg_list([('a', Float), ('b', Integer)]) sh1 = create_function('conv_int', code2, input_args=arg_lst1) sh1.prepare(runtimes) arg_map1 = arg_map([('a', Integer), ('b', Float), ('c', Vec3), ('f', Vec3)]) code = """ a = 2 b = 2.2 c = (2, 3, 4) f = [6,7,7.7] b = conv_int(b, a) int(55) b = 3 + pow(2,3) * 2.5 #b = pow(2,3) * 2.5 + 3 """ shader = create_shader("test", code, arg_map1, shaders=[sh1])
if p1 > 96.8: break nn = (2.2, 1.1, 3.4) set_rgb(slika, 1, 2, nn) rect.k = get_rgb(slika, 1, 2) rect.w = pow(rect.w, 3.3) p1 = int(3) + 4 """ code2 = """ #p1 is input argument p2 = p1 return p2 """ arg_lst = arg_list([('p1', 3)]) arg_map2 = arg_map([]) shader2 = create_shader("ret_arg", code2, arg_map2, arg_lst, func=True) runtimes = [Runtime()] shader = create_shader("test", code, arg_map1, shaders=[shader2]) print(shader._code) shader.prepare(runtimes) img = ImagePRGBA(3,3) img.set_pixel(1, 2, 0.2, 0.3, 0.1) shader.set_value('slika', img) shader.execute() print(shader.get_value('p1')) print(shader.get_value('ps.x'))
from tdasm import Runtime from renmas3.base import create_shader, arg_map, Integer, Float, Vec3 from renmas3.base import create_function, arg_list runtimes = [Runtime()] code2 = """ #input a = float, b = int a = b return a """ arg_lst1 = arg_list([('a', Float), ('b', Integer)]) sh1 = create_function('conv_int', code2, input_args=arg_lst1) sh1.prepare(runtimes) arg_map1 = arg_map([('a', Integer), ('b', Float), ('c', Vec3), ('f', Vec3)]) code = """ a = 2 b = 2.2 c = (2, 3, 4) f = [6,7,7.7] b = conv_int(b, a) int(55) b = 3 + pow(2,3) * 2.5 #b = pow(2,3) * 2.5 + 3 """ shader = create_shader("test", code, arg_map1, shaders=[sh1]) shader.prepare(runtimes) shader.execute() print(shader._code)