Drawing a selection box

BlitzMax Forums/BlitzMax Beginners Area/Drawing a selection box

rs22(Posted 2009) [#1]
Hi,

I'm positive this is a ridiculously simple question, but I can't quite get my head around it this evening. Performance wise, what is the best way to draw a selection box like the one in Paint, where the lines are dashed?

Thanks.


GfK(Posted 2009) [#2]
My 2009 Christmas selection box:

My favourite is Curly Wurly. I'm saving it for last.

I realise this doesn't help. Not sure how to do the dotted line thing - is it imperative that you do that? Or can't you just use a normal line?


rs22(Posted 2009) [#3]
Mmm, Cadbury. Now I want a Curly Wurly.

It's not really super important. I just think it looks better.


Czar Flavius(Posted 2009) [#4]
I have no idea how to do this code-wise, but an idea off the top of my head: Create a thin image, for example 1x8, where the first 4 pixels are white and the second 4 pixels are black (or transparent). And then use some kind of image tiling command to tile that strip the length of the box. Is that helpful?

Personally I'm a sucker for Flakes, but they make a mess everywhere.


TaskMaster(Posted 2009) [#5]
I have never heard of any of those candies before. Do they name candies differently in the UK than in the US? I wonder if we have the same candy with different names?


Czar Flavius(Posted 2009) [#6]
Do you mean of Cadbury's kind?


Zeke(Posted 2009) [#7]
use GDI, http://www.blitzbasic.com/Community/posts.php?topic=56055


Midimaster(Posted 2009) [#8]
this example is simple and does not really need time:

Graphics 800,600
Global FirstMouseX%, FirstMouseY%
Repeat
	Cls
	' draw anything
	If MouseDown(1) Then
		If FirstMouseX=-1 Then
			FirstMouseX=MouseX()
			FirstMouseY=MouseY()
		EndIf
		zeit=MilliSecs()
		DrawSelectBox FirstMouseX,FirstMouseY,MouseX(),MouseY()
		zeit=MilliSecs()-zeit
		Print zeit
		
	Else
		FirstMouseX=-1
	EndIf
	Flip
Until KeyHit(Key_escape)

Function DrawSelectBox(X%,Y%,EndX%,EndY%)
	SetColor 255,255,255
	For I= 0 To EndX-X Step 10
		DrawLine x+i,Y,X+I+4,Y
		DrawLine x+i,EndY,X+I+4,EndY
	Next 
	For I= 0 To EndY-Y Step 10
		DrawLine x,Y+i,X,y+i+4
		DrawLine EndX,Y+i,EndX,y+i+4
	Next 
End Function