awt - draw ellipse2d around mouse click java -
i making program draws ellipses when user clicks screen. when ellipse drawn origin (0,0) being drawn top right. want drawn around mouse click center user clicks i'm not sure how it. if steer me in right direction great!
public void drawsprite( graphics2d g2 ) { affinetransform toldtransform = g2.gettransform(); g2.setcolor(setspritecolor()); g2.translate(mx, my); g2.rotate(mrotation*(math.pi/180)); g2.draw(new ellipse2d.double(0, 0, mwidth, mheight)); g2.settransform(toldtransform); }
g2.translate(mx, my);
i'm guessing mx , point mouse clicked. translation can't exact point. maybe like:
g2.translate(mx - (mwidth / 2), - (mheight / 2));
Comments
Post a Comment