Images with 'wavy sine effect'

BlitzMax Forums/BlitzMax Programming/Images with 'wavy sine effect'

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You can do it, but it's a struggle for Max to distort an entire screen's worth of image data (Blitz, B+ and B3D have a much easier time with this sort of thing) so you're going to have to manipulate the tiles instead. This should get you going:

SuperStrict
SeedRnd( MilliSecs() )

Const GWIDTH:Int = 800
Const GHEIGHT:Int = 600

Graphics GWIDTH,GHEIGHT,0

For Local circleIndex:Int = 1 To 1000
	SetColor Rand(100,200),Rand(100,200),Rand(200,255)
	Local size:Int = Rand(10,20)
	DrawOval Rand(0,127), Rand(0, 127),size,size
Next
SetColor 255,255,255

Local tile:TPixmap = GrabPixmap(10,10,64,64)
Local SineBase:Int = 0
Local TILED_MODE:Byte = True

While Not KeyHit(KEY_ESCAPE)
	If KeyHit(KEY_SPACE) Then TILED_MODE = 1-TILED_MODE

	If TILED_MODE
		DrawPixmap tile,0,0
		For Local scanline:Int = 0 To 63
			Local subPixmap:TPixmap = GrabPixmap(0,scanline,63,1)
			tile.Paste(SubPixmap,Cos((SineBase+scanline)*6.0)*2.0,scanline)
		Next	
		SineBase:+1
		
		For Local X:Int = 0 To 12
		For Local y:Int = 0 To 9
			DrawPixmap tile,x*64,y*64
		Next
		Next
		DrawText "Currently distorting tile. Press space to toggle.",10,10
	Else
		For Local X:Int = 0 To 12
		For Local y:Int = 0 To 9
			DrawPixmap tile,x*64,y*64
		Next
		Next	
		
		For Local scanline:Int = 0 To GHEIGHT - 1
			Local subPixmap:TPixmap = GrabPixmap(0,scanline,GWIDTH-1,1)
			DrawPixmap subPixmap,Cos((SineBase+scanline)*6.0)*2.0,scanline
		Next
		SineBase:+1
		DrawText "Currently distorting entire screen. Press space to toggle.",10,10
	EndIf
		
	Flip
	Cls
Wend