• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphics2D please help JAVA GUI

 
wan kent
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone please help me to add horizontal line(nose) (just search baymax at google) because can't find the right coordinate , please use only g2d.drawline
thanks !

feel free to edit my code if you want to make baymax's body, really really really do appreciate that . super thanks




 
Campbell Ritchie
Sheriff
Posts: 51343
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Why do you have the three rotate(...) calls? Those do not seem to do anything and applying an affine transform to a Graphics object may distort the Graphics object in such a way that you can never quite undo it. Why do you not remove them?
For drawing a line, you need to work out the coordinates. Look at the documentation for Graphics#drawLine, and work out what the four arguments mean. By passing 0, 0 you are telling it to start at the very top left. By passing 100, 150, you are telling it to finish 100px to the right and 150px down. You want to have the same y for the start as the finish. You want somewhere down and right of the top left of the oval and a bit to the right. If your oval starts at 145, 145, the first two arguments should be more than 145. Then the 4th argument should be the same as the second. The third argument should be more than the first.
You will have to try different numbers until your line is in the place you want.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic