recover what I draw

Find quick help here to get you started with Hollywood
Post Reply
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

recover what I draw

Post by sinisrus »

Hello,

I do not understand why I can not copy or recover what I draw?
Is there a function for this?

/* TEST */

Function p_Move()

If IsLeftMouse()

If (EndX<>1)&(EndY<>1)
StartX=EndX
StartY=EndY
Else
StartX=MouseX()
StartY=MouseY()
EndIf

EndX=MouseX()
EndY=MouseY()
Line(StartX,StartY,EndX,EndY,#WHITE,1)

Else If IsRightMouse()

Cls()

Else

EndX=1
EndY=1

EndIf

EndIf


EndFunction

/********************************************************************************************************/

Createbrush(0,100,50,#BLUE) DisplayBrush(0,0,0) TextOut(2,25,"Copy BGPic")

MakeButton(1,#SIMPLEBUTTON,0,0,100,50,{OnMouseUp = Function() CopyBGPic(1,2) DisplayBGPic(2) endfunction})

/********************************************************************************************************/

SetInterval(1, p_Move, 1000/150) ; 50fps

/********************************************************************************************************/

/* Loop */
Repeat
WaitEvent
Forever
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: recover what I draw

Post by airsoftsoftwair »

You could use a back buffer brush and recover from that back buffer brush, i.e. you draw everything to the back buffer brush instead of directly to the display. Then you draw the part of your back buffer brush that has changed to the display. If you need to restore anything, just draw the respective area of the back buffer brush to your display.
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: recover what I draw

Post by sinisrus »

Have you an example if you like it ?
User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: recover what I draw

Post by fjudde »

I don't know what Andreas meant with "back buffer brush" but I also would like some small example of that.

I have been playing with your code and managed to draw the same line() to a brush and the display. When clearing the display the drawing is still in the brush. And can be displayed again, and drawn to some more.

Code: Select all

Function p_Move()
	If IsLeftMouse()	
		If (EndX<>1)&(EndY<>1)
			StartX=EndX
			StartY=EndY
		Else
			StartX=MouseX()
			StartY=MouseY()
		EndIf
		EndX=MouseX()
		EndY=MouseY()
		SelectBrush(1)
		Line(StartX,StartY,EndX,EndY,#WHITE,1)
		EndSelect()
		Line(StartX,StartY,EndX,EndY,#WHITE,1)
	Else
		If IsRightMouse() ;Clear all
			Cls()
			CreateBrush(1, 640, 480)
			p_button()
		Else
			EndX=1
			EndY=1
		EndIf
	EndIf
EndFunction

Function p_Arne()
	Cls(); Clear Screen
	Wait(1,#SECONDS);symbolic wait just to se it's gone
	DisplayBrush(1,0,0);restore whats been drawn
	p_button()
EndFunction

Function p_button()
	CreateBrush(0,100,50,#BLUE)
	DisplayBrush(0,0,0)
	TextOut(4,16,"Clr Screen\nAnd restore")
	MakeButton(1,#SIMPLEBUTTON,0,0,100,50,{OnMouseUp = p_Arne})
EndFunction

CreateBrush(1, 640, 480)
;CreateBGPic(1,640,480)
p_button()

SetInterval(1, p_Move, 1000/50)

Repeat
	WaitEvent
Forever

_____________________________________
Hollywood 6.1
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: recover what I draw

Post by sinisrus »

Fjudde thank you but I do not see what I draw :-/
User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: recover what I draw

Post by fjudde »

sinisrus wrote:Fjudde thank you but I do not see what I draw :-/
Strange? I do see what I draw! Did copy and past code I posted in a new file and run it standalone? What wersion do you have (I have 6.1) and IDE (I have Windows IDE)?

The lines are beeing drawn twice. First to the brush and then to the display. The "EndSelect()" is supposed to select the display as output device.

Code: Select all

SelectBrush(1)
Line(StartX,StartY,EndX,EndY,#WHITE,1)
EndSelect()
Line(StartX,StartY,EndX,EndY,#WHITE,1)
Try adding a "SelectDisplay(1)" after "EndSelect()" to explicitly tell it to draw the line to the display.

Code: Select all

SelectBrush(1)
Line(StartX,StartY,EndX,EndY,#WHITE,1)
EndSelect()
SelectDisplay(1)
Line(StartX,StartY,EndX,EndY,#WHITE,1)
The second Line() has to be drawn somewhere? Try an offset to it and see if both lines() goes to the brush.
Cause you do see what you have drawn, When you press the button? Right?

Code: Select all

Line(StartX+3,StartY+3,EndX+3,EndY+3,#WHITE,1)
If both call to line() draws in the brush you should have a double line when pressing the button
_____________________________________
Hollywood 6.1
User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: recover what I draw

Post by fjudde »

Did copy and past code I posted in a new file and run it standalone?
Should have been:
Did you copy and past the code I posted in a new file and ran it standalone?
_____________________________________
Hollywood 6.1
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: recover what I draw

Post by sinisrus »

fjudde

Work now very tank :-))
Post Reply