| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.github.weisj.jsvg.nodes; |
| 23 |
|
| 24 |
import java.awt.*; |
| 25 |
|
| 26 |
import org.jetbrains.annotations.NotNull; |
| 27 |
|
| 28 |
import com.github.weisj.jsvg.geometry.size.Percentage; |
| 29 |
import com.github.weisj.jsvg.nodes.prototype.spec.Category; |
| 30 |
import com.github.weisj.jsvg.nodes.prototype.spec.ElementCategories; |
| 31 |
import com.github.weisj.jsvg.nodes.prototype.spec.PermittedContent; |
| 32 |
import com.github.weisj.jsvg.paint.SimplePaintSVGPaint; |
| 33 |
import com.github.weisj.jsvg.parser.impl.AttributeNode; |
| 34 |
import com.github.weisj.jsvg.util.ColorUtil; |
| 35 |
|
| 36 |
@ElementCategories(Category.Gradient) |
| 37 |
@PermittedContent(categories = {Category.Animation, Category.Descriptive}) |
| 38 |
public final class SolidColor extends AbstractSVGNode implements SimplePaintSVGPaint { |
| 39 |
public static final String TAG = "solidcolor"; |
| 40 |
private Color color; |
| 41 |
|
| 42 |
@Override |
| 43 |
public @NotNull String tagName() { |
| 44 |
return TAG; |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
public @NotNull Paint paint() { |
| 49 |
return color; |
| 50 |
} |
| 51 |
|
| 52 |
@Override |
| 53 |
public void build(@NotNull AttributeNode attributeNode) { |
| 54 |
super.build(attributeNode); |
| 55 |
Color c = attributeNode.getColor("solid-color"); |
| 56 |
float opacity = attributeNode.getPercentage("solid-opacity", new Percentage(c.getAlpha() / 255f)).value(); |
| 57 |
color = ColorUtil.withAlpha(c, opacity); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
} |