-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_gradient.genjit
More file actions
83 lines (79 loc) · 4.09 KB
/
x_gradient.genjit
File metadata and controls
83 lines (79 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 8,
"minor" : 6,
"revision" : 2,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "jit.gen",
"rect" : [ 599.0, 274.0, 1065.0, 1155.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"code" : "f_circle(px,py,o,i,resolution) \r\n{\r\n\t\r\n\tratio = resolution.x / resolution.y;\r\n dist = vec(ratio,1) * (norm - vec(px,py));\r\n\tgr = 1. - smoothstep(i-i*o,i+i*o, dot(dist,dist));\r\n\treturn gr;\r\n}\r\n\r\nf_horizontal(p,o,i) \r\n{\r\n\tsi = scale(i,0,1,0,0.5,1);\r\n\tgr1 = smoothstep(p-o-si,p-si,norm.y);\r\n\tgr2 = gr1 - smoothstep(p+si,p+o+si,norm.y);\r\n\tgr = vec(gr2,gr2,gr2,1);\r\n\treturn gr;\r\n}\r\n\r\nf_vertical(p,o,i) \r\n{\r\n\tsi = scale(i,0,1,0,0.5,1);\r\n\tgr1 = smoothstep(p-o-si,p-si,norm.x);\r\n\tgr2 = gr1 - smoothstep(p+si,p+o+si,norm.x);\r\n\tgr = vec(gr2,gr2,gr2,1);\r\n\treturn gr;\r\n}\r\n\r\nf_dist(px,py,o,i,resolution)\r\n{\r\n\tox = o * o;\r\n\tox *= PI;\r\n\tpos = vec(px,py);\r\n\tratio = resolution.x / resolution.y;\r\n\tdir = vec(i,1-i) * (vec(1,1) * (norm - pos));\r\n\t\r\n\tgr = ox * length(dir);\r\n\treturn gr;\r\n\r\n}\r\n\r\n\r\nf_rect(px,py,o,i,resolution) \r\n{\r\n\t\r\n\tratio = resolution.x / resolution.y;\r\n\tcw = i * 0.5;\r\n\tch = i * 0.5;\r\n\t\r\n\tleft \t= px - cw;\r\n\tright \t= px + cw;\r\n\ttop \t= py - ch;\r\n\tbottom \t= py + ch;\r\n\t\r\n\tlr = smoothstep(left,left+o,norm.x) - smoothstep(right-o,right,norm.x);\r\n\ttb = smoothstep(top,top+o*ratio,norm.y) - smoothstep(bottom-o*ratio,bottom,norm.y);\r\n\tmask = tb*lr;\r\n\treturn mask;\r\n\t}\r\n\r\nf_rect2(px,py,o,i,resolution) \r\n{\r\n\t\r\n\tratio = resolution.x / resolution.y;\r\n\tcw = i * 0.5;\r\n\tch = i * 0.5;\r\n\t\r\n\tleft \t= px - cw;\r\n\tright \t= px + cw;\r\n\ttop \t= py - ch;\r\n\tbottom \t= py + ch;\r\n\t\r\n\tlr = smoothstep(left-o,left,norm.x) - smoothstep(right,right+o,norm.x);\r\n\ttb = smoothstep(top-o,top,norm.y) - smoothstep(bottom,bottom+o,norm.y);\r\n\tmask = tb*lr;\r\n\treturn mask;\r\n\t}\r\n\r\n\t\r\nParam mode;\t\t\t\r\nParam xposition;\r\nParam yposition;\r\nParam gradientsize;\r\nParam innersize;\r\nParam invert;\r\nParam size (1280,600);\r\n\r\n\r\ncircle = f_circle(xposition,yposition,gradientsize,innersize,size);\r\nhorizontal = f_horizontal(yposition,gradientsize,innersize);\r\nvertical = f_vertical(xposition,gradientsize,innersize);\r\ndis = f_dist(xposition,yposition,gradientsize,innersize,size);\r\nrect = f_rect(xposition,yposition,gradientsize,innersize,size);\r\nrect2 = f_rect2(xposition,yposition,gradientsize,innersize,size);\r\n\r\n\r\nfinal = selector(mode,horizontal,vertical,circle,rect,rect2);\r\n\r\n\t\t\t\t\t\t\r\nout1 = mix(final,1-final,invert);",
"fontface" : 0,
"fontname" : "<Monospaced>",
"fontsize" : 11.0,
"id" : "obj-28",
"maxclass" : "codebox",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 43.0, 31.0, 749.0, 944.0 ]
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-4",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 43.0, 1044.0, 37.0, 22.0 ],
"text" : "out 1"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"source" : [ "obj-28", 0 ]
}
}
],
"autosave" : 0,
"bgcolor" : [ 0.9, 0.9, 0.9, 1.0 ],
"editing_bgcolor" : [ 0.9, 0.9, 0.9, 1.0 ]
}
}