tformimage help?
BlitzPlus Forums/BlitzPlus Programming/tformimage help?
| ||
Could someone explain the tform image command please? I get what it does but the docs are as good as useless when it comes to explaining how it works. |
| ||
Have a look at these screenies. They each show what the individual TFormImage parameters do: Command format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TFormImage image,a#,b#,c#,d# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a# stretches the image horizontally b# shears the image vertically c# shears the image horizontally d# stretches the image vertically The amount of shear/stretching depends on what values are supplied. As you can see from the screenshots, both positive and negative values can be used. However, setting a# or d# to zero causes an error. Some examples: TFormIMage img,2,0,0,1 ; double image width TFormIMage img,1,0,0,-1 ; flip image vertically |
| ||
Thanks That helped. I had tried going through and playing with values but it wasn't working. I'm guessing thats because of the not having 0 on 'a' or 'd'. |
| ||
Now *that* is a damned fine explanitory set of pics Syntax. :) |
| ||
is tform image quicker than using scaleimage? |
| ||
AFAIK the speed is about the same, although I haven't tested it. The main advantage is the fact you can shear images. |
| ||
oh je oh je... here is my code: Dim matrix#(3) bild=CreateImage(50,50) SetBuffer ImageBuffer(bild) ClsColor 255,0,0 Cls Color 255,255,255 Line 0,0,49,49 SetBuffer FrontBuffer() DrawBlock bild,0,0 bild2=CopyImage(bild) matrixreset() matrixscale(2,1) matrixrotate(-30) TFormImage bild,matrix(0),matrix(1),matrix(2),matrix(3) DrawBlock bild,0,130 matrixreset() matrixrotate(-30) matrixscale(2,1) TFormImage bild2,matrix(0),matrix(1),matrix(2),matrix(3) DrawBlock bild2,0,220 Text 150,0,"original" Text 150,130,"scale+rotate":Text 150,145,"in 1 operation" Text 150,220,"rotate+scale":Text 150,235,"in 1 operation" WaitKey() End Function matrixreset() matrix#(0)=1 matrix#(1)=0 matrix#(2)=0 matrix#(3)=1 End Function Function matrixrotate(winkel#) m0#=Cos(winkel#) m1#=Sin(winkel#) m2#=-Sin(winkel#) m3#=Cos(winkel#) matrixmultiply(m0#,m1#,m2#,m3#) End Function Function matrixscale(sx#,sy#) m0#=sx# m1#=0 m2#=0 m3#=sy# matrixmultiply(m0#,m1#,m2#,m3#) End Function Function matrixmultiply(m0#,m1#,m2#,m3#) x0#=matrix#(0)*m0#+matrix#(1)*m2# x1#=matrix#(0)*m1#+matrix#(1)*m3# x2#=matrix#(2)*m0#+matrix#(3)*m2# x3#=matrix#(2)*m1#+matrix#(3)*m3# matrix#(0)=x0# matrix#(1)=x1# matrix#(2)=x2# matrix#(3)=x3# End Function |
| ||
ok, thanks alot :) |
| ||
Nice. Methinks Syntax Error's and Mr Credo's contributions should be in the docs. |
| ||
Absolutely, I intend to do that soonish...but currently we don't have a means of including images in the docs. So I need to come up with a single code example that explains the whole lot... |
| ||
Online documentation has been updated, with a heavily modified version of the example above. |