Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drawing question...

Posted on 1998-03-24
1
Medium Priority
?
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses

705 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