Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Drawing question...

Posted on 1998-03-24
1
Medium Priority
?
226 Views
Last Modified: 2010-04-16
How can I draw a filled in triangle using java.awt.Graphics?
I want to draw one triangle pointing up, one pointing down, one pointing left and one pointing right...
0
Comment
Question by:cupOjava
1 Comment
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1233738
I can think of two options. The first and simplest would be to use a graphic (a .GIF of .JPEG) can be drawn very easily using the drawImage method. A graphic has to be square, of course, but the remaining space can be set to be transparent.

The second approach would be simply a series of lines. The bottom one is n pixels wide, the next one up n-2 pixels wide (or n-4, it would depend on how "steep" it is).

If you're having trouble with the transparency in the first option (you have to output with Photoshop, or something, and do it just so), or the second is too slow, and you want to use an offscreen buffer to save the image in, you will also need a filter to make relevant sections of the image transparent.

Feel free to ask for further details if you decide to try one of these.


0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question