Slick Forums

Discuss the Slick 2D Library
It is currently Mon May 20, 2013 3:21 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jun 05, 2012 9:48 pm 
Offline

Joined: Sat Feb 19, 2011 2:59 pm
Posts: 52
Hello together,

I need a function that clears only part of an image. With graphics.clear() I can clear the whole image. But I only want to clear a rectangular region of an image.

A method like graphics.clearRect(x, y, width, height) would be perfect. But there is no function like that (?)

If there is really no method like that, how can I achieve my wish to clear a rect area?

fillRect() with color(0, 0, 0, 0) does not help since it has absolutely no effect. how can i change the draw mode so that the fillRect color is not added but replaces the underlying colors which are only in buffer at these positions?

Thanks for your help!
smallfly

_________________
http://www.p1sim.org - Economy/Logistics simulaton based on Java and Slick2D


Last edited by smallfly on Sat Jun 09, 2012 11:15 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Jun 05, 2012 10:28 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Option A:
Code:
      g.setDrawMode(Graphics.MODE_COLOR_MULTIPLY);
      g.setColor(new Color(0f,0f,0f,0f));
      g.fillRect(50, 50, 100, 100);
      g.setDrawMode(Graphics.MODE_NORMAL);


Option B:
(I just tested it and it seems bugged -- the y value is flipped.)
Code:
      g.setClip(50, 50, 100, 100);

      // not always necessary since this is the default background/clear color
      g.setBackground(new Color(0f, 0f, 0f, 0f));
      g.clear();
      g.clearClip();


Top
 Profile  
 
PostPosted: Wed Jun 06, 2012 7:58 am 
Offline

Joined: Sat Feb 19, 2011 2:59 pm
Posts: 52
aaaah. of course: MODE_COLOR_MULTIPLY. stupid me. i saw this draw mode but i ignored it, since i looked for something like OVERWRITE. but yeah: 0 * color = 0 :) thank you very much :)

_________________
http://www.p1sim.org - Economy/Logistics simulaton based on Java and Slick2D


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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