Page 1 of 1
recover what I draw
Posted: Fri May 13, 2016 9:09 am
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
Re: recover what I draw
Posted: Sat May 14, 2016 12:50 pm
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.
Re: recover what I draw
Posted: Sat May 14, 2016 4:34 pm
by sinisrus
Have you an example if you like it ?
Re: recover what I draw
Posted: Sat May 14, 2016 11:17 pm
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
Re: recover what I draw
Posted: Sun May 15, 2016 1:10 pm
by sinisrus
Fjudde thank you but I do not see what I draw :-/
Re: recover what I draw
Posted: Sun May 15, 2016 4:20 pm
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
Re: recover what I draw
Posted: Sun May 15, 2016 9:00 pm
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?
Re: recover what I draw
Posted: Mon May 16, 2016 10:14 am
by sinisrus
fjudde
Work now very tank
)