Page 1 of 1

Push/Pop drawing state

Posted: Thu Aug 29, 2013 11:04 am
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()