Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 11:14 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 09, 2012 7:19 am 
Offline

Joined: Mon Jan 09, 2012 2:10 am
Posts: 17
So, I've called setDrawMode(Graphics.MODE_ALPHA_MAP), drawn shapes, and then tried to draw something else after setting the mode back to normal. Any idea why this might be happening?


Top
 Profile  
 
PostPosted: Thu Feb 09, 2012 5:26 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
Alpha map works like so:

Code:
   //you can fade the result by changing the alpha component -- RGB will be ignored
   private Color alphaFilter = new Color(1f, 1f, 1f, 1f);

   //you can tint the result by changing the RGB components -- alpha will be ignored
   private Color colorFilter = new Color(1f, 1f, 1f, 1f);

   public void render(GameContainer c, Graphics g) throws SlickException {
      //render the map first
      g.setDrawMode(Graphics.MODE_ALPHA_MAP);
      alpha.draw(50, 50, 500, 500);
      
      //render the image we want blended
      g.setDrawMode(Graphics.MODE_ALPHA_BLEND);
      clouds.draw(50, 50, 500, 500, alphaFilter);
      
      //then reset draw mode to normal
      g.setDrawMode(Graphics.MODE_NORMAL, colorFilter);
   }


The colorFilter/alphaFilter parameters are optional.

Alpha:
Image

Clouds:
Image

Result:
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group