• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transparent Diamonds.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been looking all over the internet for a tutorial that makes transparent diamonds, and I just can't find one. I could maybe put one together myself, but first I would need to find a working transparency tutorial for java. Most of them use a bunch of libraries I have never heard of, so they won't compile on my system.

So, does the standard jvm library come with some transparency library or something?

Also I found some paint Demo tutorial, but it says the api is depreciated? Is the Canvas depreciated? How can I make my applications use stuff that is current to Java 6 and above?
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lori, welcome to CodeRanch.

I'm assuming from the fact that you're posting in the Game Dev forum, that you're referring to graphics for diamonds, as in treasure.

First off, for graphical user interfaces in Java, you should primarily use Swing and not AWT. Instead of using a Canvas, use a JPanel.

Now, the easiest way to solve this is to have a gif or png file containing an image of your diamond sprite, and paint it using one of the Graphics.drawImage() methods inside the paintComponent() method of your JPanel. These formats support transparent pixels, and the drawImage() methods also take transparency into account.

If you're not familiar with Swing, check the Oracle tutorials. Find them through Google.
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic