|
Post by glennl on Apr 27, 2024 6:07:03 GMT
Hi.
I have a graphics box ( #main.Map ) with a background BMP file, a aerial photo. On this graphic box I'm drawing a marker to indicate the position of a rover.
graphicbox #main.Map, 360, 10, 640, 640 loadbmp "Map1", "Map1.bmp" print #main.Map,"background Map1"
I can move the marker ( just a circle for now, eventually a arrow indicating direction ), but I want to remove the previous marker. Below is part of a function that runs after receiving data from the rover
print #main.Map, "delsegment "; Seg-1 print #main.Map, "redraw"
print #main.Map, "segment Seg" print #main.Map, "circle 10" print #main.Map, "flush"
Its job is to remove the old marker, get the segment number of the new marker for use later, draw the circle and flush it.
problem is, seams the redraw command removes the background image.
If I remove the print #main.Map, "redraw" command, every stays, but so do the old markers.
Any suggestions?
Thanks Glenn
|
|
|
Post by tsh73 on Apr 27, 2024 8:39:52 GMT
basically, "background" is sprite command You probably need "drawbmp" instead.
|
|
|
Post by tsh73 on Apr 27, 2024 8:54:43 GMT
If marker is drawn frequently (so you do not need it flushed with a map), this will probably do
nomainwin
graphicbox #main.Map, 360, 10, 640, 640 ''graphicbox #main.Map, 10, 10, 640, 640 open "#main" for window as #main #main "trapclose [quit]" #main.Map,"down"
loadbmp "Map1", "Map1.bmp" ''loadbmp "Map1", "ring54387.bmp" print #main.Map,"background Map1" print #main.Map,"drawbmp Map1 0 0 " print #main.Map, "flush bg"
x=150 y=150
timer 30, [nxt] wait
[nxt] 'I can move the marker ( just a circle for now, eventually a arrow indicating direction ), but I want to remove the previous marker. Below is part of a function that runs after receiving data from the rover
'print #main.Map, "delsegment "; Seg-1 print #main.Map, "redraw bg"
'print #main.Map, "segment Seg"
x=x+rnd(0)*10-5 y=y+rnd(0)*10-5 print #main.Map, "place ";x;" ";y print #main.Map, "circle 10" 'print #main.Map, "flush"
wait
[quit] timer 0 close #main end
|
|
|
Post by Rod on Apr 27, 2024 9:05:21 GMT
I did it this way.
graphicbox #main.Map, 360, 10, 640, 640 loadbmp "Map1", "Map1.bmp" #main.Map "down ; drawbmp Map1 0 0" #main.Map "flush bak"
#main.Map "discard ; redraw bak" #main.Map "place ";x;" ";y #main.Map "circle 10"
Since you constantly redraw the circle, no need to flush so just the bak segment gets redrawn and the circle overlaid
|
|
|
Post by tsh73 on Apr 27, 2024 9:13:33 GMT
OK after re-reading tutorial alycesrestaurant.com/lbpe/Graphic%20Segments.htmlI've got this: 1) your BG needs separate flush 2) since sequence starts with delsegment, we should draw/flush first set of markers (or delsegment will delete BG!) 3) "segment" command should be used after flush 'nomainwin
graphicbox #main.Map, 360, 10, 640, 640 ''graphicbox #main.Map, 10, 10, 640, 640 open "#main" for window as #main #main "trapclose [quit]" #main.Map,"down"
loadbmp "Map1", "Map1.bmp" ''loadbmp "Map1", "ring54387.bmp" print #main.Map,"background Map1"
print #main.Map,"drawbmp Map1 0 0 " 'needs separate flush print #main.Map, "flush"
print #main.Map, "segment Seg" print "bg seg", Seg
x=150 y=150
'initial segment to be deleted with delsegment print #main.Map, "place ";x;" ";y print #main.Map, "circle 10" print #main.Map, "flush" print #main.Map, "segment Seg"
print "initial seg", Seg
timer 1500, [nxt] wait
[nxt] 'I can move the marker ( just a circle for now, eventually a arrow indicating direction ), but I want to remove the previous marker. Below is part of a function that runs after receiving data from the rover
print #main.Map, "delsegment "; Seg-1 print #main.Map, "redraw"
x=x+rnd(0)*10-5 y=y+rnd(0)*10-5 print #main.Map, "place ";x;" ";y print #main.Map, "circle 10" print #main.Map, "flush"
print #main.Map, "segment Seg" print "current seg", Seg
wait
[quit] timer 0 close #main end
|
|
|
Post by glennl on Apr 28, 2024 5:24:08 GMT
Thanks guys, I'll have a play around this evening.
|
|