# Thread: converting double to pixel coordinates

1. Member Join Date
Jan 2012
Posts
15
Rep Power
0

## converting double to pixel coordinates

hi all,
in my program i have a circle in a panel, that i want it to move0 on a parabola of equation y = ax2. in the circle class i have created a move method that moves that this circle using the repaint() method but the problem that i am having is that the filloval(int x, int y, int w, int h) does not accept double variables for x and y. for this reason my parabola trajectory is not so precise and the circle seems to jump instead of moving.
i want to ask how can i make my circle move in smaller intervals to make it move instead of jumping.
i was thinking of converting the double variables to pixel variables? does there exist any method that can do this
thanks for any help.  Reply With Quote

2. ## Re: converting double to pixel coordinates

converting the double variables to pixel variables?
Can you give some examples of this?
pixels are referenced by int values: 0 to width and 0 to height of the panel. There isn't a pixel at 4.345 There is a pixel at 4 and there is a pixel at 5.

Look at the classes in the java.awt.geom package. Many of them take doubles are arguments.  Reply With Quote

3. ## Re: converting double to pixel coordinates

All Graphics objects are instances of Graphics2D. You can cast the reference, apply suitable RenderingHints and draw or fill a Shape -- which may have subpixel coordinates.

Have you gone through the 2D Graphics tutorial? For now you could start with Drawing Geometric Primitives (The Java Tutorials > 2D Graphics > Working with Geometry) but you should go through the whole tutorial trail as soon as you get the time.

db  Reply With Quote

circle, display, motion, move, pixel 