-1

I'm just beginning to learn basic graphics, particularly drawing, and I would like to ask for suggestions on how I draw animals such as this fox.

http://www.wikihow.com/images/2/2f/Draw-a-Fox-Step-9.jpg

Do I use polygons and hard code the whole drawing? Or is there a program that allows me to input the image in it and it outputs the x and y coordinates of all the vertices that I'd need in order to draw it? Basically, what I have to do is I'd draw that fox in Java but I have to draw it on my own using shapes. I'd have to start from scratch and work my way up until I recreate the fox using Java's shapes. Any suggestions how I do this?

rotkiv
  • 3
  • 4
  • Umm.. DYM to draw the fox when you **don't** have an image of it? *"..is there a program that allows me to input the image in it and it outputs the x and y coordinates of all the vertices that I'd need in order to draw it?"* No. But wait, let me reconsi.. No. – Andrew Thompson Jan 01 '14 at 06:56
  • It depends on what you want to achieve. Mods it need to be scalable? Because of the coloring, it would suggest the need for a series of polygons or paths. My personal approach might be to generate the images as SVG and use the [Apache Batik](http://xmlgraphics.apache.org/batik/) to transcode them to Java classes, which can then be painted as Icons or Images. Take a look at [this](http://www.pushing-pixels.org/2008/08/24/flamingo-svg-trancoder-enhancements.html), which is what I based my own solution on – MadProgrammer Jan 01 '14 at 06:57
  • Do you just need to draw an image from a file? This tutorial may help you with that. http://docs.oracle.com/javase/tutorial/2d/images/loadimage.html – Connor Pearson Jan 01 '14 at 06:59
  • 1
    Basically, what I have to do is I'd draw that fox in Java but I have to draw it on my own using shapes. I'd have to start from scratch and work my way up until I recreate the fox using Java's shapes. – rotkiv Jan 01 '14 at 07:11
  • 2
    I'd make that more clear in your question then. It's a bit vague how it's written now. – Connor Pearson Jan 01 '14 at 07:17
  • It sounds like you need something different, but see [this Q&A](http://stackoverflow.com/q/7218309/418556) that obtains a (crude) outline from an image based on a target color. – Andrew Thompson Jan 01 '14 at 08:16

2 Answers2

1

When people want graphics like that in their games/applications, they usually create the files in other applications and then import the image files. There are many different application to create images in, but two of the popular ones are Photoshop and Illustrator. For a free application to create images, look into GIMP.

There are a variety of different files types you can use in almost all languages and platforms. For example, .png files are particularly useful because they can have transparency. For resolution independent images people often use .svn file format.

It is rare for anyone to have the program generate the images with polygons, unless you have some type of severe constraint, there is no reason to.

Look up how to load and display image files in the language and platform of your choice.

Damien Black
  • 5,579
  • 18
  • 24
  • 1
    Scalable based images (or vector based images) are a reasonable solution for some problems. For example, because no one can decide on the size of the icons in our application, I based all our icons on vectors, so they can be easily scaled at runtime and doesn't require me me carry 4 pixel based images for each icon ... Just saying – MadProgrammer Jan 01 '14 at 07:03
-1

This block'll paint the fox:

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    ImageIcon fox = new ImageIcon(new URL('https://i.stack.imgur.com/vJOsv.jpg'));
    fox.paintIcon(this, g, x, y) // Replace x and y with the x/y coordinates
}
piticent123
  • 193
  • 1
  • 7
  • 1
    Don't attempt to load resources in the `paint..` methods, and don't encourage others to do so by showing code snippets based on that! The paint methods are intended to finish 'very fast'. – Andrew Thompson Jan 01 '14 at 07:05
  • I see. Thank you for the advice! You learn something new every day :) – piticent123 Jan 01 '14 at 07:07