I am making a 2D Java game and I'd like to darken stuff in the dark areas. I was wondering if I could use alphatransparent colors in a paintComponent method. If not, does translucent PNGs work or is there effects for darkening images.
Thanks
Translucent fill in paintComponent
114 Views Asked by AudioBubble At
2
There are 2 best solutions below
0
Adam Yost
On
You can use transparency/opacity in java.
Here you can find some basic info on the procedure. The important step is using an AlphaComposite object to set the alpha value of your drawing
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in COLORS
- X3DOM Inline Background skyColor
- Set Background Color on UIButton when Disabled?
- WPF text control with colors only
- Trying to make a random pixel in a bitmap a new color, but it is giving an error why
- background is not working properly
- LWJGL Drawing colored text to the screen issue
- Python: list of strings, change color of character if found (using xlsxwriter)
- How to plot colors on CIE 1931 Color Space in Matlab?
- Change all MenuItems ForeColor at once when click a button
- Selectioncolor doesn't work within KeyPress event
- Change color button in Kivy
- Matlab - Using symbols in gscatter
- Java replacing the background of an image
- Java JMapViewer: How can I change the color of a MapPolygon?
- How do I change symbol type colors on D3js?
Related Questions in PAINTCOMPONENT
- Removing flashiness/ shakiness from scrolling text
- Java BufferedImage / JPanel not updating new black pixel rows using JButton
- Paint Panel Incorrect Rendering
- Custom JPanel causing rendering problems in second custom JPanel
- Java basic paint program ugly brush
- paintComponent does not work on the East Panel, on West is ok
- Issue drawing rectangle in negative direction - Java
- How to paint/repaint/animate (MVC)
- How to draw 2d arrows with Java Swing?
- ActionListener works but painting doesn't
- paintComponent clears the JPanel when paint an image
- Java - paintComponent memory leak
- Replicate JMenu in paintComponent of child
- DrawLine in Java Swing
- how can i clear my rectangle after drawing it to the screen?
Related Questions in ALPHA-TRANSPARENCY
- Split physicsBody or alternatives
- How to make a nice overlay with variable transparency using WinForms?
- Preview tool on Mac OS X 10.10 adds transparency during resize
- delphi convert gif to png with transparency
- Rendering QWidget to QImage loses alpha-channel
- How to make alpha transparent TImage in Delphi?
- android background in xml: tranparency become black not white
- Setting alpha transparency at a listView android
- Access to raw data in ARGB_8888 Android Bitmap
- How can I dynamically generate an image with an alpha gradient?
- How to create an h264 video with an alpha channel for use with HTML5 Canvas?
- IOS set transparent border of path of cgcontext
- Resize png image in Delphi - incorrect alpha channel
- Setting alpha on UIView sets the alpha on its subviews which should not happen
- OpenGL - How to read Alpha from a texture
Related Questions in TRANSLUCENCY
- Translucency in a Tile Based Lighting System
- Translucent panel over AWT component
- Java Swing - Translucent Components causing Artifacts
- Java Swing - Translucent Components
- Using Qt to create the OS X Yosemite Translucency effect
- how to make JLable visible and Translucent (almost invisible) on mouse hovering
- Transparent JPanels
- Rendering translucent triangles in models animated by a vertex shader?
- Gaussian translucent effect in VB.Net
- Setting the JFrame background transparent making PopupMenu blank
- Getting unexpected output from the swing program
- Unable to understand the code properly
- Translucent icons in ActionBar when disabled: only on my phone?
- Navigation bar becomes transparent when set to translucent
- Custom navigation bar image + translucency effect not working for iOS 7
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I would create a new BufferedImage of type TYPE_INT_ARGB, edit straight into the raster data, - set the color of your choice (with desired alpha), and just draw it after everything else, in your paint method. drawImage is pretty fast. And if you want to change the darkness colors, you can set the new alpha values on the fly directly into the data array of the image.