Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Dark Basic Question about unfilled box

Author
Message
Brazos
22
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 30th May 2009 23:25
Does someone have code to click mouse, hold and drag and draw an unfilled box?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st May 2009 00:09
I don't but I could walk you through the idea of how I would approach it.

1. Wait for the mouse click
2. Record the mouses x and y coordinates
3. While the mouse is clicked, draw a box from the original coordinates to the new mouse coodinates
4. At the same time draw another box colored black within the colored one whatever size you want it
5. Keep doing it until the mouse is un-clicked

Alternatively you could write a function that would just draw the lines give the 4 coordinates (old mouse coordinates and new mouse coordinates)

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st May 2009 01:58
Quote: "3. While the mouse is clicked, draw a box from the original coordinates to the new mouse coodinates4. At the same time draw another box colored black within the colored one whatever size you want it"

What if there's something underneath the box? It would be blacked out.

Quote: "Alternatively you could write a function that would just draw the lines give the 4 coordinates (old mouse coordinates and new mouse coordinates)"

Yes, this is a great chance to get into writing your own functions.
If you don't know how post back and one of us will help you.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st May 2009 02:46
Quote: "What if there's something underneath the box? It would be blacked out."


You could draw it on a separate bitmap and then get the image and paste it to the screen, this would also allow the preservation of what was there without having to clear the screen so that it doesn't streak the box

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st May 2009 05:07
@BN2
touche.
I still prefer drawing lines as it seems tidier.
You'd have to store the screen in another bitmap for both methods so there's not much difference there.
I wonder which is faster...
I'll give them a test.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Brazos
22
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 31st May 2009 07:16
I want to use it as a selection box. For example I click, drag and draw an unfilled box around a section of an image. What ever is inside the unfilled box can then be copied (get image command).
Done any testing yet OBese87?
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 31st May 2009 07:23
I made a paint program one time and just cleared the screen every loop and had images of the stuff i needed then i just used my "Box outline" code and it did it fine.

New Site! Check it out \/
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 31st May 2009 21:27
Here's a function and how to use it:



TheComet


Make the path of your enemies easier with Waypoint Pro!
Yodaman Jer
User Banned
Posted: 1st Jun 2009 07:11
@Comet:

That function is awesome! It's fast and very well done!


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Jun 2009 12:12
Thanks a lot, Yodaman Jer!

TheComet


Make the path of your enemies easier with Waypoint Pro!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Jun 2009 02:15 Edited at: 2nd Jun 2009 02:33
@TheComet
Line is quite an expensive command - because it uses maths to work out the angle of the line and so forth - even if your line is square.
Sorry if you picked that up from me saying I'd draw lines. You can use the box command to draw square lines and it's much faster seeing as boxes are drawn like a for loop; no maths involved.


The selection size display is a nice touch, I would put it at the top left or bottom right corner though as it wouldn't require the math and just seems more logical to me, but hey if you like it like that keep it.

[edit]
A third method would be to use a memblock which would be the fastest I'm sure.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 2nd Jun 2009 04:08
whats the problem with using:



There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Jun 2009 04:48
Quote: "box x1+1,y1+1,x2-1,y2-1"


That would require some math, since it assumes that the first point is the top left and the second is the bottom right, but they could be opposite or COMPLETELY DIFFERENT (bottom left and top right).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2025-05-14 23:54:28
Your offset time is: 2025-05-14 23:54:28