gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src_libs/com/badlogic/gdx/tools/hiero/unicodefont/effects/FilterEffect.java
| a62d533 | 1 | /******************************************************************************* |
| a62d533 | 2 | * Copyright 2011 See AUTHORS file. |
| a62d533 | 3 | * |
| a62d533 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| a62d533 | 5 | * you may not use this file except in compliance with the License. |
| a62d533 | 6 | * You may obtain a copy of the License at |
| a62d533 | 7 | * |
| a62d533 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| a62d533 | 9 | * |
| a62d533 | 10 | * Unless required by applicable law or agreed to in writing, software |
| a62d533 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| a62d533 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| a62d533 | 13 | * See the License for the specific language governing permissions and |
| a62d533 | 14 | * limitations under the License. |
| a62d533 | 15 | ******************************************************************************/ |
| a62d533 | 16 | |
| a62d533 | 17 | package com.badlogic.gdx.tools.hiero.unicodefont.effects; |
| a62d533 | 18 | |
| a62d533 | 19 | import java.awt.Graphics2D; |
| a62d533 | 20 | import java.awt.image.BufferedImage; |
| a62d533 | 21 | import java.awt.image.BufferedImageOp; |
| a62d533 | 22 | |
| a62d533 | 23 | import com.badlogic.gdx.tools.hiero.unicodefont.Glyph; |
| a62d533 | 24 | import com.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont; |
| a62d533 | 25 | |
| a62d533 | 26 | /** Applys a {@link BufferedImageOp} filter to glyphs. Many filters can be fond here: http://www.jhlabs.com/ip/filters/index.html
|
| a62d533 | 27 | * @author Nathan Sweet */ |
| a62d533 | 28 | public class FilterEffect implements Effect {
|
| a62d533 | 29 | private BufferedImageOp filter; |
| a62d533 | 30 | |
| a62d533 | 31 | public FilterEffect () {
|
| a62d533 | 32 | } |
| a62d533 | 33 | |
| a62d533 | 34 | public FilterEffect (BufferedImageOp filter) {
|
| a62d533 | 35 | this.filter = filter; |
| a62d533 | 36 | } |
| a62d533 | 37 | |
| a62d533 | 38 | public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
|
| a62d533 | 39 | BufferedImage scratchImage = EffectUtil.getScratchImage(); |
| a62d533 | 40 | filter.filter(image, scratchImage); |
| a62d533 | 41 | image.getGraphics().drawImage(scratchImage, 0, 0, null); |
| a62d533 | 42 | } |
| a62d533 | 43 | |
| a62d533 | 44 | public BufferedImageOp getFilter () {
|
| a62d533 | 45 | return filter; |
| a62d533 | 46 | } |
| a62d533 | 47 | |
| a62d533 | 48 | public void setFilter (BufferedImageOp filter) {
|
| a62d533 | 49 | this.filter = filter; |
| a62d533 | 50 | } |
| a62d533 | 51 | } |