Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init()
- setName("MirrMix")
- setDesc("Mix with the mirror image")
- setSize(95,18+24+32+24+64+8+8+7+4+18+18)
- addOutput(24+32)
- addInput("Texture",24+64+8+8,0,0,1)
- addInputParameter("Loop H","Loop Horizontally",18+18+24+64+8+8,0,0,1)
- addInputParameter("Loop V","Loop Vertically",18+18+24+64+8+8+18,0,0,1)
- addParameter("Mix","Mix looped image",18+18+18+18+24+64+8+8,100,0,100, true)
- addParameter("MixType","0:Clip 1:Opacity 2:Textured clip 3:Textured Opacity",18+18+18+18+24+64+8+8+18,0,0,3)
- addParameter("MirrorType","0:Average 1:Darken 2:Lighten",18+18+18+18+24+64+8+8+18+18,0,0,2)
- addInput("Mix",18+24+64+8+8,0,0,1)
- end
- -- Ugly way to use channels
- function loopr(x, y, ori)
- xy = getValue(0,x,y,1)--image not mirrowed
- mx = getValue(0,size-x,y,1)--image mirrowed in x
- my = getValue(0,x,size-y,1)--image mirrowed in y
- mxy = getValue(0,size-x,size-y,1)--image mirrowed in x and y
- if(getValue(5,0,0,1) == 0) then
- if (ori==0) then --H
- return (xy + mx)/2
- end
- if (ori==1) then --v
- return (xy + my)/2
- end
- if (ori==2) then --HV
- return (xy + mx + my + mxy)/4
- end
- end
- if(getValue(5,0,0,1) == 1) then
- if (ori==0) then --H
- return math.min(xy , mx)
- end
- if (ori==1) then --v
- return math.min(xy , my)
- end
- if (ori==2) then --HV
- return math.min(xy , mx, my, mxy)
- end
- end
- if(getValue(5,0,0,1) == 2) then
- if (ori==0) then --H
- return math.max(xy , mx)
- end
- if (ori==1) then --v
- return math.max(xy , my)
- end
- if (ori==2) then --HV
- return math.max(xy , mx, my, mxy)
- end
- end
- end
- function apply()
- tileSize = getTileSize()
- if (getValue(4,0,0,1) == 0) then --clip loop
- for i=0, tileSize*tileSize-1 do
- x = i%tileSize --get x
- y = math.floor(i/tileSize) --get y
- size = tileSize-1
- valuexy = getValue(0,x,y,1)--normal image
- loopperc = getValue(3,x,y,50)
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 0) then --if H and not V
- opacityIndex = math.max(0, math.min(1, math.abs( ((size/2) - x )/(size/2) )+(loopperc-1) ))--middle H gradient
- looped = loopr(x,y,0)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 1) then --if V and not H
- opacityIndex = math.max(0, math.min(1, math.abs( ((size/2) - y )/(size/2) )+(loopperc-1) ))--middle V gradient
- looped = loopr(x,y,1)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 1) then --if H and V
- opacityIndex = math.max(0, math.min(1, math.max( math.abs( ((size/2) - x )/(size/2) )+(loopperc-1), math.abs( ((size/2) - y )/(size/2) )+(loopperc-1) )))--middle sqr gradient
- looped = loopr(x,y,2)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 0) then --if neithe
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- --setPixel(0,x,y,opacityIndex,opacityIndex,opacityIndex)
- end
- end
- if (getValue(4,0,0,1) == 1) then --opacity loop
- for i=0, tileSize*tileSize-1 do
- x = i%tileSize --get x
- y = math.floor(i/tileSize) --get y
- size = tileSize-1
- valuexy = getValue(0,x,y,1)--normal image
- loopperc = getValue(3,x,y,50)
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 0) then --if H and not V
- opacityIndex = math.max(0, math.min(1, math.abs( ((size/2) - x )/(size/2) )+(loopperc-1) ))--middle H gradient
- looped = loopr(x,y,0)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 1) then --if V and not H
- opacityIndex = math.max(0, math.min(1, math.abs( ((size/2) - y )/(size/2) )+(loopperc-1) ))--middle V gradient
- looped = loopr(x,y,1)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 1) then --if H and V
- opacityIndex = math.max(0, math.min(1, math.max( math.abs( ((size/2) - x )/(size/2) )+(loopperc-1), math.abs( ((size/2) - y )/(size/2) )+(loopperc-1) )))--middle sqr gradient
- looped = loopr(x,y,2)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 0) then --if neithe
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- --setPixel(0,x,y,opacityIndex,opacityIndex,opacityIndex)
- end
- end
- if (getValue(4,0,0,1) == 2) then --textured clip
- for i=0, tileSize*tileSize-1 do
- x = i%tileSize --get x
- y = math.floor(i/tileSize) --get y
- size = tileSize-1
- valuexy = getValue(0,x,y,1)--normal image
- loopperc = getValue(3,x,y,50)
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 0) then --if H and not V
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,0)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 1) then --if V and not H
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,1)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 1) then --if H and V
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,2)
- if (opacityIndex>0.5) then--boolMask
- setPixel(0,x,y,looped,looped,looped)
- else
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 0) then --if neithe
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- --setPixel(0,x,y,opacityIndex,opacityIndex,opacityIndex)
- end
- end
- if (getValue(4,0,0,1) == 3) then --textured opacity
- for i=0, tileSize*tileSize-1 do
- x = i%tileSize --get x
- y = math.floor(i/tileSize) --get y
- size = tileSize-1
- valuexy = getValue(0,x,y,1)--normal image
- loopperc = getValue(3,x,y,50)
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 0) then --if H and not V
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,0)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 1) then --if V and not H
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,1)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 1 and getValue(2,0,0,1) == 1) then --if H and V
- opacityIndex = math.max(0, math.min(1, getValue(6,x,y,1)+ (loopperc-1) ))--middle H gradient
- looped = loopr(x,y,2)
- mixImage = (looped * opacityIndex)+(valuexy * (1-opacityIndex))--mixes img and loopd img
- setPixel(0,x,y,mixImage,mixImage,mixImage)
- end
- if (getValue(1,0,0,1) == 0 and getValue(2,0,0,1) == 0) then --if neithe
- setPixel(0,x,y,valuexy,valuexy,valuexy)
- end
- --setPixel(0,x,y,opacityIndex,opacityIndex,opacityIndex)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement