Solved

Drawing question...

Posted on 1998-03-24
1
218 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now