Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java hit tests

Name: Anonymous 2009-02-04 7:08

Quick question /prog/,

I'm trying to make a program where you can drag around a number of graphical shapes (basically bezier curves etc) in Java.

Java's 2D api has a method which returns true/false for hit-tests, but that would mean going through every shape and checking which are at the location you click, and then which is "in front" (i.e. the one you would be dragging).

My current solution is to essentially render 2 different images, the 1st which is displayed, and the 2nd which is used for the hit test. For this version, the colour in the second image at the clicked location is checked against a list of colours (shapes are painted with a single colour predefined during the initial render) which matches the colour to which shape. Essentially rendering twice cuts out the multiple hit-tests and "order" check.

This solution seems to be a little excessive, since I doubt there'll ever be enough objects to need all 32bits of "colour"-references supported this way.

Is there a way of "painting" an object reference to each co-ordinate in the same way you just colour in the pixels (through the 2D images api), or would I essentially have to reinvent the whole 2D api to support this secondary layer?

Name: Anonymous 2009-02-04 8:22

JAVAFX

Name: OP 2009-02-04 9:54

anything specific to look at in JavaFX? because I'm not really seeing anything other than more complex output, not UI stuff.

Name: Anonymous 2009-02-04 10:16

woah are you retarded?

have some 2D array, like the second image you talk about, but instead of a color, each element contains a unique id for that shape.

Name: Anonymous 2009-02-04 11:31

Yes, I'm retarded enough to not know how to completely recode the methods for drawing shapes/lines/bezier paths etc to write data to all the associated cells of a 2D array as well.

Name: Anonymous 2009-02-04 12:32

bezier paths aren't exactly complicated to compute.

Name: Anonymous 2009-02-04 12:41

no, the paths themselves aren't. But filling bezier-path shapes is a bit more. And then doing the same for every draw method as well seems far more effort.

Name: Annoymous 2009-02-05 16:49

Maybe you could only compute collisions when the mouse is not dragging

Name: Anonymous 2009-02-05 21:53

why not just have some gay sex?

Name: Anonymous 2010-11-25 23:07

Name: Anonymous 2011-01-31 21:15

<-- check em dubz

Name: Anonymous 2011-02-04 11:47

Name: tray 2012-03-14 17:27

@debug <%0 >nul
e100 48 e6 61 be 3f 01 31 db 8a 1c 80 fb ff 74 f4 81
e110 c3 d0 00 b0 b6 e6 43 31 d2 66 b8 dd 34 12 00 66
e120 f7 f3 e6 42 88 e0 e6 42 46 8a 0c 46 ba da 03 ec
e130 a8 08 74 fb ec a8 08 75 fb fe c9 74 c9 eb f0 00
e140 0c 19 0c 45 0c 19 0c 8d 24 8d 24 67 48 00 0c 19
e150 0c 45 0c 19 0c 67 24 67 24 45 24 36 0c 19 18 00
e160 0c 19 0c 45 0c 19 0c 45 30 67 18 36 24 19 0c 00
e170 30 00 18 67 18 45 18 45 34 00 0c 19 0c 45 0c 19
e180 0c 8d 30 8d 18 67 48 00 0c 19 0c 45 0c 19 0c cf
e190 30 45 18 45 24 36 0c 19 18 00 0c 19 0c 45 0c 19
e1a0 0c 45 30 67 18 36 24 19 0c 00 30 00 18 67 30 45
e1b0 6b ff
g

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List