It is unclear what we want here. Is this a cipher of 3x3 blocks, where first row is w
, second h
and third val
? E.g.
5 5
9 -> 9
0 0
9 9
5 -> 5
0 1
5 5
5 -> 5
0 2
5 9 5
9 5 5
0 1 2
It is unclear what we want here. Is this a cipher of 3x3 blocks, where first row is w
, second h
and third val
? E.g.
5 5
9 -> 9
0 0
9 9
5 -> 5
0 1
5 5
5 -> 5
0 2
5 9 5
9 5 5
0 1 2
I finally got what I wanted.
dct_tileset:
{$1^2},{$2^2},1,1
f. :"begin(const tw=$1;const th=$2;const stw=sqrt(tw);const sth=sqrt(th);const itw=1/tw;const ith=1/th;const istw=sqrt(itw);const isth=sqrt(ith);const s2=sqrt(2));
px=x%tw;
py=y%th;
tx=(x-(px))*itw;
ty=(y-(py))*ith;
cx=cos((tx*0.5+((tx+0.5)*x*itw))*pi)*istw;
cy=cos((ty*0.5+((ty+0.5)*y*ith))*pi)*isth;
px!=0?(cx*=s2);
py!=0?(cy*=s2);
val=cx*cy;
val;
"
idct_tileset:
{$1^2},{$2^2},1,1
f. :"begin(const tw=$1;const th=$2;const stw=sqrt(tw);const sth=sqrt(th);const itw=1/tw;const ith=1/th;const istw=sqrt(itw);const isth=sqrt(ith);const s2=sqrt(2));
px=x%tw;
py=y%th;
tx=(x-(px))*itw;
ty=(y-(py))*ith;
cx=cos((x+0.5)*tx*pi*itw)*istw;
cy=cos((y+0.5)*ty*pi*ith)*isth;
tx!=0?(cx*=s2);
ty!=0?(cy*=s2);
val=cx*cy;
((tx+ty)%2)?(val*=-1);
val;
"
fx_jpeg :
to_rgb
inum=$!
q=$1
($2,$4,$6;$3,$5,$7;0,0,0)
nm. params
eval. "begin(index=0;list=transpose(crop(0,0,3,2),3);foundlist=vector6(0));
for(n=0,n<3,++n,
pos=n*2;
cp=list[pos,2];
(find(foundlist,cp,0,2)==-1)?(
index=find(foundlist,[0,0],0,2);
foundlist[index]=cp[0];
foundlist[index+1]=cp[1]);
i(n,2)=find(foundlist,cp,0,2)*0.5
);"
tcount=0
repeat 3
tnum={i(#$params,$>,2)}
if $tnum==$tcount
tw={i(#$params,$>,0)}
th={i(#$params,$>,1)}
dct_tileset $tw,$th
idct_tileset $tw,$th
# nm[-2,-1] "dct"$tcount"","idct"$tcount""
tcount+=1
fi
done
repeat {$inum} l[$>,{(-2*$tcount)-1}--1]
ww={w(#0)}
hh={h(#0)}
csswap[0] 0,15 s[0] c
repeat 3
tw={i(#$params,$>,0)}
th={i(#$params,$>,1)}
tn={i(#$params,$>,2)}
r[$>] {w(#0)+(-w(#0)%$tw)},{h(#0)+(-h(#0)%$th)},1,100%,0,3
{w#0},{h#0},{d#0},{s#0}
f[$>] :"
begin(const tw="$tw";const th="$th";const twh=tw*th;const tn="$tn";const tileset=(tn-"$tcount")*2-1);
if (!(x%tw) && !(y%th),
res=vector(#twh,0);
ref(crop(x,y,tw,th),src);
for (l = 0, l<th, ++l, for (k = 0, k<tw, ++k,
off = k + tw*l;
res += src[off]*crop(#tileset,k*tw,l*th,tw,th,1))); # ?
draw(#-1,res,x,y,0,0,tw,th);
); i"
f. :"begin_t(const qual=sqrt("$tw"*"$th")*64*((1-"$q"*0.01)^3));round(i,qual)"
f. :"
begin(const tw="$tw";const th="$th";const twh=tw*th;const tn="$tn";const tileset=(tn-"$tcount")*2);
if (!(x%tw) && !(y%th),
res=vector(#twh,0);
ref(crop(x,y,tw,th),src);
for (l = 0, l<th, ++l, for (k = 0, k<tw, ++k,
off = k + tw*l;
res += src[off]*crop(#tileset,k*tw,l*th,tw,th,1))); # ?
draw(#"$>",res,x,y,0,0,tw,th);
); i"
rm.
r[$>] {$ww},{$hh},1,100%,0,3
done
a[0-2] c csswap[0] 15,0
endl done
rm[{(-2*$tcount)-1}--1]
@afre It’s meant to assign numbers to the pairs of parameters, based on when it first encounters them in the list. It doesn’t matter what those parameters precisely are, it just matters whether they’re the same as any other parameters or different. There’s no encoding going on there.
Glad to see your code working.
EDIT: For those who’s looking to do what Joan_Rake1 did, but easier to translate:
jr_test_1:
($1,$4,$7^$2,$5,$8^$3,$6,$9)
sh 0,1
eval. "begin(v=expr('x',w););
if(x,
for(n=0,n<x,n++,
I(n)==I?(v[x]=n;break(););
);
);
end(
!v[1]&&(I(1)!=I)?v[2]=1;
run('v=',vtos(v););
);"
echo $v
rm.
Now it’s time to do some tile offsets. This is gonna hurt.
Before I do that, here’s a more basic script. This’ll be a separate one from the big one.
I tried making it crash or cause error. So far, none has been detected. It works.
One of the settings doesn’t work because luv2rgb
is missing. I’ll have to fix that.
Just a feature request. Could you add a checkmark option to allow only changing width and height? I know that means adding in dynamic gui.
I can’t remember how to do that. It’ll take some time when I’m done figuring out how to properly add the offsets in…
I will provide a brief tutorial to speed up your work.
fx_rep_trsa_preview:
param1,param2,param3,param4,param5,param6,param7,param8,param9=$4,$5,$6,$7,$8,$9,$10,$11,$12
if $13
param1,param2,param3,param4,param5,param6,param7,param8,param9={[u(-1,1),u(-1,1),u(-1,1),u(-1,1),u(-1,1),u(-1,1),u(-1,1),u(-1,1),u(-1,1)]}
fi
fx_rep_trsa ${1-3},$param1,$param2,$param3,$param4,$param5,$param6,$param7,$param8,$param9,0,${14-17},,0
fill_decimal={${}}
fill_perc={round($fill_decimal*10000)/100}
if $18 to $fill_perc"%" fi
u "{$1}"\
"{$2}"\
"{$3}"\
"{"$param1"}"\
"{"$param2"}"\
"{"$param3"}_"{$1!=3?2}\
"{"$param4"}_"{$1!=3?2}\
"{"$param5"}_"{$1>3?2}\
"{"$param6"}_"{$1>3?2}\
"{"$param7"}_"{$1==5?2}\
"{"$param8"}_"{$1==5?2}\
"{"$param9"}_"{$1==5?2}\
"{0}"\
"{$14}"\
"{$15}"\
"{$16}"\
"{$17}"\
"{$18}"
u is the command that targets gui filter. {$n} usually correspond to the gui element though some gui element can contains multiple variables (See below). Next to it can include variable options which affects the gui elements. If the result is 2, then it’s visible, if the result is 1, it’s just disabled but not hidden, if it 0 then it’s hidden. {0} means that it’ll return 0 at the end, this is used for buttons related filter. You can however have custom formula in place of $n.
On Multiple variables within a gui element:
In fx_rep_rpgtiler_noniso_preview:
, you will note “{$11,$12,$13}_”{$10?2:1}\
I hope this helps.
I have to halt my efforts with that because I’ve found another issue: when an entire channel has just one value, the DCT breaks and I get a grid of NaNs. Is this another bug? I’m not sure why this happens at all! Try a grayscale image with HSV, Lch, YCbCr or YIQ and you’ll see what I mean.
Edit: it was a sneaky division by zero error! Here’s the fixed code: dct_tileset:{$1^2},{$2^2},1,1f. :"begin(const tw=$1;const th=$2;const stw=sq - Pastebin.com
Different, negative or periodic ranges to start, and unexpected combination of values that the inverse conversion won’t like…
I keep screwing this up! dct_tileset:{$1^2},{$2^2},1,1f. :"begin(const tw=$1;const th=$2;const stw=sq - Pastebin.com This one has working tile offsets.
Looks good. I think you’re ready to start on dynamic gui, but I’m not the author.
Also:
repeat {$inum} l[$>,{(-2*$tcount)-1}--1]
You don’t need bracket around $inum. Repeat will work without it.
Is there a way to turn this into a repeat
loop:
param1,param2,param3,param4,param5,param6,param7,param8,param9=$4,$5,$6,$7,$8,$9,$10,$11,$12
You could do
variable_name={"
forloop();
vector_variable;
"}
Not sure about the repeat, but pretty sure you can convert repeat into forloop();
. I haven’t really tested this idea for multiple variables.
I wasn’t sure, but it’s actually very simple!
repeat 3
param$>=$>
done
I’ve tried this but it’s just not working:
fx_jpeg_preview:
if $9
o0,o1,o2,o3,o4,o5=${10-15}
else
repeat 6
o$>=0
done
fi
fx_jpeg ${1-8},$o0,$o1,$o2,$o3,$o4,$o5
u "{$1}"\
"{$2}"\
"{$3}"\
"{$4}"\
"{$5}"\
"{$6}"\
"{$7}"\
"{$8}"\
"{$9}"\
"{"$o0","$o1","$o2","$o3","$o4","$o5"}_"{$9?2:0}\
The offset options don’t get hidden.
You’re not supposed to combine gui elements with single variable at one group. You have to separate them. Yes, that is tedious. GUI elements with two variables is two variables in one group.
Here’s a example which you could base off.
fx_rep_cstdmap_preview:
fx_rep_cstdmap $*
u "{$1}"\
"{$2}"\
"{$3}"\
"{$4}"\
"{$5}"\
"{$6}"\
"{$7}"\
"{$8}"\
"{$9}"\
"{$10}"\
"{$11}"\
"{$12}_"{$10==1?2:0}\
"{$13}_"{$10==2?2:0}\
"{$14}_"{(($10==3)||($10==4))?2:0}\
"{$15}_"{(($10==3)||($10==4))?2:0}