Solved

Drawing question...

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

747 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

17 Experts available now in Live!

Get 1:1 Help Now