Code archives/3D Graphics - Misc/Transform Texture!

This code has been declared by its author to be Public Domain code.

Download source code

Transform Texture! by Rob 2002
This offsets a texture to center with your own rotation & scale. Very useful for shaders and stuff. Ever wanted to scale a texture and/or rotate it yet keep it in the middle? Now you can!
Function TransTex(texture,angle#,scale#=1)
	ScaleTexture texture,scale,scale
	RotateTexture texture,angle#
	x#=Cos(angle)/scale/2
	y#=Sin(angle)/scale/2
	PositionTexture texture,(x-.5)-y,(y-.5)+x
End Function

Comments

Jams2006
Lovely :)


Chroma2006
Rob, you wrote this for me like 3 years ago...and I'm just now using it...

Where are you hiding out Rob!!


Perturbatio2006
Where are you hiding out Rob!!


Hujiklo2006
Late thanks for a great function!


Kryzon2009
Late late thanks for a great function.


Code Archives Forum