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/ColorEffect.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.Color; |
| a62d533 | 20 | import java.awt.Graphics2D; |
| a62d533 | 21 | import java.awt.image.BufferedImage; |
| a62d533 | 22 | import java.util.ArrayList; |
| a62d533 | 23 | import java.util.Iterator; |
| a62d533 | 24 | import java.util.List; |
| a62d533 | 25 | |
| a62d533 | 26 | import com.badlogic.gdx.tools.hiero.unicodefont.Glyph; |
| a62d533 | 27 | import com.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont; |
| a62d533 | 28 | |
| a62d533 | 29 | /** Makes glyphs a solid color. |
| a62d533 | 30 | * @author Nathan Sweet */ |
| a62d533 | 31 | public class ColorEffect implements ConfigurableEffect {
|
| a62d533 | 32 | private Color color = Color.white; |
| a62d533 | 33 | |
| a62d533 | 34 | public ColorEffect () {
|
| a62d533 | 35 | } |
| a62d533 | 36 | |
| a62d533 | 37 | public ColorEffect (Color color) {
|
| a62d533 | 38 | this.color = color; |
| a62d533 | 39 | } |
| a62d533 | 40 | |
| a62d533 | 41 | public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
|
| a62d533 | 42 | g.setColor(color); |
| a62d533 | 43 | g.fill(glyph.getShape()); |
| a62d533 | 44 | } |
| a62d533 | 45 | |
| a62d533 | 46 | public Color getColor () {
|
| a62d533 | 47 | return color; |
| a62d533 | 48 | } |
| a62d533 | 49 | |
| a62d533 | 50 | public void setColor (Color color) {
|
| a62d533 | 51 | if (color == null) throw new IllegalArgumentException("color cannot be null.");
|
| a62d533 | 52 | this.color = color; |
| a62d533 | 53 | } |
| a62d533 | 54 | |
| a62d533 | 55 | public String toString () {
|
| a62d533 | 56 | return "Color"; |
| a62d533 | 57 | } |
| a62d533 | 58 | |
| a62d533 | 59 | public List getValues () {
|
| a62d533 | 60 | List values = new ArrayList(); |
| a62d533 | 61 | values.add(EffectUtil.colorValue("Color", color));
|
| a62d533 | 62 | return values; |
| a62d533 | 63 | } |
| a62d533 | 64 | |
| a62d533 | 65 | public void setValues (List values) {
|
| a62d533 | 66 | for (Iterator iter = values.iterator(); iter.hasNext();) {
|
| a62d533 | 67 | Value value = (Value)iter.next(); |
| a62d533 | 68 | if (value.getName().equals("Color")) {
|
| a62d533 | 69 | setColor((Color)value.getObject()); |
| a62d533 | 70 | } |
| a62d533 | 71 | } |
| a62d533 | 72 | } |
| a62d533 | 73 | } |