Push/Pop drawing state

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2798
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Push/Pop drawing state

Post by Michael Vogel »

Not sure, if this could be implemented easily, but saving the state of StartDrawing on a stack would bring more flexibility for creating procedures and may speed up things (Start/StopDrawing is very slow).

Code: Select all


Procedure CreateShadow(x,y,w,h,depth)

	Protected temp

	temp=CreateImage(#PB_Any,w,h,32|#PB_Image_Transparent)

	PushDrawingState(); ***

	StartDrawing(ImageOutput(temp))
	; Prepare Shadow
	StopDrawing()

	PopDrawingState(); ***
	DrawAlphaImage(ImageID(temp),x,y,depth)

	FreeImage(temp)

EndProcedure

CreateImage(1,800,800,32)
StartDrawing(ImageOutput(1))

For i=1 To 20
	x=Random(800)
	y=Random(800)
	DrawText(x,y,"Test")
	CreateShadow(x,y,200,200,20)
Next i

StopDrawing()