Hi,
I have some troubles understanding this TransformSprite() command, especially the "z" parameter, because I don't get how we can define a z axis in a 2D drawing.
Anyway, I'd like to use this command to perform two very basic things : increase/decrease the width of the sprite, and increase/decrease its height.
Thanks
TransformSprite()
Re: TransformSprite()
If you just want to alter the width or height, why not use ZoomSprite((#Sprite, Width, Height)?
Re: TransformSprite()
My sprite is just a simple box, so if I zoom it, the borders will be zoomed. And I don't want that. So I'd hope that TransformSprite() would make me avoid redrawing an entire new sprite every time I want to resize it.
Re: TransformSprite()
For your idear , you have to clip your sprite in 9 subsprites.
The center middle sprite is zoomed, and the side sprite only zoomed in one axis, and the corner sprite not zoomed.
Edit3: Example:
Edit2: Bugfix ^^
Edit3: Bugfix2
The center middle sprite is zoomed, and the side sprite only zoomed in one axis, and the corner sprite not zoomed.
Edit3: Example:
Code: Select all
InitSprite()
Procedure DisplayBoxedSprite(Sprite.i, X.i, Y.i, Width.i, Height.i, Top.i, Right.i, Bottom.i, Left.i)
Protected Dim u.i(3), Dim v.i(3) ; Vertex
Protected Dim x.i(3), Dim y.i(3) ; Position
Protected ix.i, iy.i
u(0) = 0 : u(1) = Left : u(2) = SpriteWidth(Sprite)-Right : u(3) = SpriteWidth(Sprite)
v(0) = 0 : v(1) = Top : v(2) = SpriteHeight(Sprite)-Bottom : v(3) = SpriteHeight(Sprite)
x(0) = x : x(1) = x+Left : x(2) = x+Width-Right : x(3) = x+Width
y(0) = y : y(1) = y+Top : y(2) = y+Height-Bottom : y(3) = y+Height
For iy = 0 To 2
For ix = 0 To 2
ClipSprite(Sprite, u(ix), v(iy), u(ix+1)-u(ix), v(iy+1)-v(iy))
ZoomSprite(Sprite, x(ix+1)-x(ix), y(iy+1)-y(iy))
DisplayTransparentSprite(Sprite, x(ix), y(iy))
Next
Next
ClipSprite(Sprite, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
EndProcedure
OpenWindow(0, 0, 0, 800, 600, "Screen", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
UsePNGImageDecoder()
CatchSprite(0, ?Window_png, #PB_Sprite_AlphaBlending)
Repeat
ClearScreen($FFFFFF)
Time.f = ElapsedMilliseconds()/1000
DisplayTransparentSprite(0, 0, 0)
DisplayBoxedSprite(0, 100, 100, 400+Sin(Time)*100, 300+Cos(Time)*100, 32, 16, 16, 16)
FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow
DataSection
Window_png:
Data.q $0A1A0A0D474E5089,$524448490D000000,$4000000040000000,$7169AA0000000608,$47527301000000DE
Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
Data.q $000000189C9A0001,$08DA07454D497407,$5F29C112161B151C,$5441444959020000,$30C26E7D9BEDDA78
Data.q $F7636C413F5FC50C,$E0970A3D28E0971A,$D368A7D92760DC06,$DD2851337B51FD96,$DA0AD592D8B250D8
Data.q $22017814DD8BF78A,$E94A651931C2648F,$C800AFE51D94F463,$ED0899210C941400,$BBB286F164A0719A
Data.q $F02AE4A732294004,$1C88D94B7E8F0011,$1549644CDAF1DC8D,$AC6F16016E7C10C0,$73E124A003BFAAC1
Data.q $D1C8056BE004820B,$D5B9095630F39F97,$0DA214212E10A5F3,$8FC5B7D189D0047C,$0CFDF44280251CDE
Data.q $B2A610C7AAAAACC0,$E213EBD4A81EAAAA,$8085CA31320073DB,$76EDF8B5E56AD580,$1CDE00F600F7000B
Data.q $ADC866739348616D,$B6DB400059173EB9,$A1D3916852C11421,$0809E90031B2C19C,$2DB696E00084C630
Data.q $00B58E9F10E341B5,$B0154059915238DF,$92D49B83C52F11A0,$3F73EF29EB00039C,$2D29E9AA4F900A90
Data.q $F80A90228E841F53,$1DFC054810059C71,$BA00D44015EFBE80,$EF400A00500AD3AE,$006E24924802F101
Data.q $0532CB200DC79E79,$05B400A015A02DA0,$E2EDDBB0056202B4,$D9B016BDAF5EB006,$00A1E4453F3A2E6C
Data.q $01400A0050028014,$02801400A0050028,$07BF90C6200A0050,$DBEFD2FF68FAEBB0,$A9D03FB1C6B60A57
Data.q $0DC01CD7BFFC15C5,$30EE00176F15B706,$900B68AC18971098,$015E00EFF133CC7B,$BDAF42F00278033C
Data.q $02AA7F76F24F3063,$7C49D35915B69FA4,$B4F7224D4014F19C,$5C05AC7EAEB0352F,$062DA7ED8C5D0DE2
Data.q $565F06E9668F9E1F,$0028C20BBB3E9AD9,$F0B94CE72DB5A9E9,$08D992C18BD9C6F0,$5EDC2CE2DC130610
Data.q $BB77CF7E7476C219,$3A059D9C41810DBC,$4C1690E1301B17B8,$2707400029BA10D8,$00B1A664B6870B8E
Data.q $01B17249D0002A60,$E6CBA5345CBFFE8F,$686A4E17AFF31C26,$0555541F1D446868,$0000000B4E3C66FF
Data.q $6042AE444E454900,$0000000000000082
EndDataSection
Edit3: Bugfix2
Last edited by STARGÅTE on Tue Oct 07, 2014 6:26 pm, edited 2 times in total.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TransformSprite()
Hmm that's more complex than I imagined. So what's the point of TransformSprite() ?
By the way, your example was working fine before your edit2, now it isn't
By the way, your example was working fine before your edit2, now it isn't

Re: TransformSprite()
Hi,
ZoomSprite() does only a 'flat' resize.
With TransformSprite() you can do this too, but also a 'perspective' change.
Bernd
ZoomSprite() does only a 'flat' resize.
With TransformSprite() you can do this too, but also a 'perspective' change.
Bernd
Re: TransformSprite()
And how would you do the same thing with TransformSprite() infratec ?
Re: TransformSprite()
Now you can use my Edit3.
TransformSprite() is not useful in this case.
With TransformSprite() you need 9 displays too.
With TransformSprite() you can set the 4 vertices by your self.
For example:is the same like:
TransformSprite() is not useful in this case.
With TransformSprite() you need 9 displays too.
With TransformSprite() you can set the 4 vertices by your self.
For example:
Code: Select all
ZoomSprite(Sprite, Width, Height)
Code: Select all
TransformSprite(Sprite, 0, 0, Width, 0, Height, Width, 0, Height)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TransformSprite()
That's exactly what I didn't understand, thank you for the explanation Stargate 
