Outline changes
|
Before Width: | Height: | Size: 624 KiB After Width: | Height: | Size: 642 KiB |
|
Before Width: | Height: | Size: 850 KiB After Width: | Height: | Size: 735 KiB |
|
Before Width: | Height: | Size: 695 KiB After Width: | Height: | Size: 1013 KiB |
|
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 188 KiB |
@@ -2,7 +2,6 @@ package mindustry.content;
|
|||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
@@ -62,6 +61,7 @@ public class UnitTypes implements ContentList{
|
|||||||
reload = 14f;
|
reload = 14f;
|
||||||
x = 4f;
|
x = 4f;
|
||||||
y = 2f;
|
y = 2f;
|
||||||
|
top = false;
|
||||||
ejectEffect = Fx.shellEjectSmall;
|
ejectEffect = Fx.shellEjectSmall;
|
||||||
bullet = Bullets.standardCopper;
|
bullet = Bullets.standardCopper;
|
||||||
}});
|
}});
|
||||||
@@ -76,6 +76,7 @@ public class UnitTypes implements ContentList{
|
|||||||
immunities.add(StatusEffects.burning);
|
immunities.add(StatusEffects.burning);
|
||||||
|
|
||||||
weapons.add(new Weapon("flamethrower"){{
|
weapons.add(new Weapon("flamethrower"){{
|
||||||
|
top = false;
|
||||||
shootSound = Sounds.flame;
|
shootSound = Sounds.flame;
|
||||||
shootY = 2f;
|
shootY = 2f;
|
||||||
reload = 14f;
|
reload = 14f;
|
||||||
@@ -107,6 +108,7 @@ public class UnitTypes implements ContentList{
|
|||||||
mechFrontSway = 0.55f;
|
mechFrontSway = 0.55f;
|
||||||
|
|
||||||
weapons.add(new Weapon("artillery"){{
|
weapons.add(new Weapon("artillery"){{
|
||||||
|
top = false;
|
||||||
y = 1f;
|
y = 1f;
|
||||||
x = 9f;
|
x = 9f;
|
||||||
reload = 60f;
|
reload = 60f;
|
||||||
@@ -143,6 +145,7 @@ public class UnitTypes implements ContentList{
|
|||||||
|
|
||||||
weapons.add(
|
weapons.add(
|
||||||
new Weapon("scepter-weapon"){{
|
new Weapon("scepter-weapon"){{
|
||||||
|
top = false;
|
||||||
y = 1f;
|
y = 1f;
|
||||||
x = 16f;
|
x = 16f;
|
||||||
shootY = 8f;
|
shootY = 8f;
|
||||||
@@ -202,6 +205,7 @@ public class UnitTypes implements ContentList{
|
|||||||
|
|
||||||
weapons.add(
|
weapons.add(
|
||||||
new Weapon("reign-weapon"){{
|
new Weapon("reign-weapon"){{
|
||||||
|
top = false;
|
||||||
y = 1f;
|
y = 1f;
|
||||||
x = 21.5f;
|
x = 21.5f;
|
||||||
shootY = 11f;
|
shootY = 11f;
|
||||||
@@ -260,6 +264,7 @@ public class UnitTypes implements ContentList{
|
|||||||
abilities.add(new HealFieldAbility(10f, 60f * 4, 60f));
|
abilities.add(new HealFieldAbility(10f, 60f * 4, 60f));
|
||||||
|
|
||||||
weapons.add(new Weapon("heal-weapon"){{
|
weapons.add(new Weapon("heal-weapon"){{
|
||||||
|
top = false;
|
||||||
shootY = 2f;
|
shootY = 2f;
|
||||||
reload = 24f;
|
reload = 24f;
|
||||||
x = 4.5f;
|
x = 4.5f;
|
||||||
@@ -288,6 +293,7 @@ public class UnitTypes implements ContentList{
|
|||||||
abilities.add(new ShieldFieldAbility(20f, 40f, 60f * 5, 60f));
|
abilities.add(new ShieldFieldAbility(20f, 40f, 60f * 5, 60f));
|
||||||
|
|
||||||
weapons.add(new Weapon("heal-shotgun-weapon"){{
|
weapons.add(new Weapon("heal-shotgun-weapon"){{
|
||||||
|
top = false;
|
||||||
x = 5f;
|
x = 5f;
|
||||||
shake = 2.2f;
|
shake = 2.2f;
|
||||||
y = 0.5f;
|
y = 0.5f;
|
||||||
@@ -337,6 +343,7 @@ public class UnitTypes implements ContentList{
|
|||||||
abilities.add(new ForceFieldAbility(60f, 0.3f, 400f, 60f * 6));
|
abilities.add(new ForceFieldAbility(60f, 0.3f, 400f, 60f * 6));
|
||||||
|
|
||||||
weapons.add(new Weapon("beam-weapon"){{
|
weapons.add(new Weapon("beam-weapon"){{
|
||||||
|
top = false;
|
||||||
shake = 2f;
|
shake = 2f;
|
||||||
shootY = 4f;
|
shootY = 4f;
|
||||||
x = 6.5f;
|
x = 6.5f;
|
||||||
@@ -407,6 +414,7 @@ public class UnitTypes implements ContentList{
|
|||||||
groundLayer = Layer.legUnit - 1f;
|
groundLayer = Layer.legUnit - 1f;
|
||||||
|
|
||||||
weapons.add(new Weapon("eruption"){{
|
weapons.add(new Weapon("eruption"){{
|
||||||
|
top = false;
|
||||||
shootY = 3f;
|
shootY = 3f;
|
||||||
reload = 10f;
|
reload = 10f;
|
||||||
ejectEffect = Fx.none;
|
ejectEffect = Fx.none;
|
||||||
@@ -1188,7 +1196,7 @@ public class UnitTypes implements ContentList{
|
|||||||
shootY = 7f;
|
shootY = 7f;
|
||||||
shake = 5f;
|
shake = 5f;
|
||||||
recoil = 4f;
|
recoil = 4f;
|
||||||
occlusion = 17f;
|
occlusion = 12f;
|
||||||
|
|
||||||
shots = 1;
|
shots = 1;
|
||||||
inaccuracy = 3f;
|
inaccuracy = 3f;
|
||||||
@@ -1279,7 +1287,7 @@ public class UnitTypes implements ContentList{
|
|||||||
rotateSpeed = 4f;
|
rotateSpeed = 4f;
|
||||||
mirror = false;
|
mirror = false;
|
||||||
|
|
||||||
occlusion = 30f;
|
occlusion = 20f;
|
||||||
|
|
||||||
shootY = 2f;
|
shootY = 2f;
|
||||||
recoil = 4f;
|
recoil = 4f;
|
||||||
@@ -1351,7 +1359,7 @@ public class UnitTypes implements ContentList{
|
|||||||
immunities = ObjectSet.with(StatusEffects.wet);
|
immunities = ObjectSet.with(StatusEffects.wet);
|
||||||
rotateShooting = false;
|
rotateShooting = false;
|
||||||
|
|
||||||
float spawnTime = 0.5f * Time.toMinutes;
|
float spawnTime = 60f * 25f;
|
||||||
|
|
||||||
abilities.add(new UnitSpawnAbility(flare, spawnTime, 19.25f, -31.75f), new UnitSpawnAbility(flare, spawnTime, -19.25f, -31.75f));
|
abilities.add(new UnitSpawnAbility(flare, spawnTime, 19.25f, -31.75f), new UnitSpawnAbility(flare, spawnTime, -19.25f, -31.75f));
|
||||||
|
|
||||||
@@ -1446,6 +1454,7 @@ public class UnitTypes implements ContentList{
|
|||||||
lowAltitude = true;
|
lowAltitude = true;
|
||||||
|
|
||||||
weapons.add(new Weapon("small-mount-weapon"){{
|
weapons.add(new Weapon("small-mount-weapon"){{
|
||||||
|
top = false;
|
||||||
reload = 20f;
|
reload = 20f;
|
||||||
x = 3f;
|
x = 3f;
|
||||||
y = 0.5f;
|
y = 0.5f;
|
||||||
@@ -1483,6 +1492,7 @@ public class UnitTypes implements ContentList{
|
|||||||
hitsize = 10f;
|
hitsize = 10f;
|
||||||
|
|
||||||
weapons.add(new Weapon("small-mount-weapon"){{
|
weapons.add(new Weapon("small-mount-weapon"){{
|
||||||
|
top = false;
|
||||||
reload = 15f;
|
reload = 15f;
|
||||||
x = 1f;
|
x = 1f;
|
||||||
y = 2f;
|
y = 2f;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import mindustry.world.blocks.units.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class UnitType extends UnlockableContent{
|
public class UnitType extends UnlockableContent{
|
||||||
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f);
|
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f), outlineSpace = 0.01f;
|
||||||
private static final Vec2 legOffset = new Vec2();
|
private static final Vec2 legOffset = new Vec2();
|
||||||
|
|
||||||
/** If true, the unit is always at elevation 1. */
|
/** If true, the unit is always at elevation 1. */
|
||||||
@@ -81,7 +81,6 @@ public class UnitType extends UnlockableContent{
|
|||||||
public float lightRadius = 60f, lightOpacity = 0.6f;
|
public float lightRadius = 60f, lightOpacity = 0.6f;
|
||||||
public Color lightColor = Pal.powerLight;
|
public Color lightColor = Pal.powerLight;
|
||||||
public boolean drawCell = true, drawItems = true, drawShields = true;
|
public boolean drawCell = true, drawItems = true, drawShields = true;
|
||||||
public int parts = 0;
|
|
||||||
public int trailLength = 3;
|
public int trailLength = 3;
|
||||||
public float trailX = 4f, trailY = -3f, trailScl = 1f;
|
public float trailX = 4f, trailY = -3f, trailScl = 1f;
|
||||||
/** Whether the unit can heal blocks. Initialized in init() */
|
/** Whether the unit can heal blocks. Initialized in init() */
|
||||||
@@ -93,8 +92,8 @@ public class UnitType extends UnlockableContent{
|
|||||||
|
|
||||||
public Seq<Weapon> weapons = new Seq<>();
|
public Seq<Weapon> weapons = new Seq<>();
|
||||||
public TextureRegion baseRegion, legRegion, region, shadowRegion, cellRegion,
|
public TextureRegion baseRegion, legRegion, region, shadowRegion, cellRegion,
|
||||||
occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion;
|
occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion;
|
||||||
public TextureRegion[] partRegions, partCellRegions, wreckRegions;
|
public TextureRegion[] wreckRegions;
|
||||||
|
|
||||||
public UnitType(String name){
|
public UnitType(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -291,16 +290,9 @@ public class UnitType extends UnlockableContent{
|
|||||||
baseRegion = Core.atlas.find(name + "-base");
|
baseRegion = Core.atlas.find(name + "-base");
|
||||||
cellRegion = Core.atlas.find(name + "-cell", Core.atlas.find("power-cell"));
|
cellRegion = Core.atlas.find(name + "-cell", Core.atlas.find("power-cell"));
|
||||||
occlusionRegion = Core.atlas.find("circle-shadow");
|
occlusionRegion = Core.atlas.find("circle-shadow");
|
||||||
|
outlineRegion = Core.atlas.find(name + "-outline");
|
||||||
shadowRegion = icon(Cicon.full);
|
shadowRegion = icon(Cicon.full);
|
||||||
|
|
||||||
partRegions = new TextureRegion[parts];
|
|
||||||
partCellRegions = new TextureRegion[parts];
|
|
||||||
|
|
||||||
for(int i = 0; i < parts; i++){
|
|
||||||
partRegions[i] = Core.atlas.find(name + "-part" + i);
|
|
||||||
partCellRegions[i] = Core.atlas.find(name + "-cell" + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
wreckRegions = new TextureRegion[3];
|
wreckRegions = new TextureRegion[3];
|
||||||
for(int i = 0; i < wreckRegions.length; i++){
|
for(int i = 0; i < wreckRegions.length; i++){
|
||||||
wreckRegions[i] = Core.atlas.find(name + "-wreck" + i);
|
wreckRegions[i] = Core.atlas.find(name + "-wreck" + i);
|
||||||
@@ -351,8 +343,13 @@ public class UnitType extends UnlockableContent{
|
|||||||
drawPayload((Unit & Payloadc)unit);
|
drawPayload((Unit & Payloadc)unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
drawOcclusion(unit);
|
drawOcclusion(unit);
|
||||||
|
|
||||||
|
Draw.z(z - outlineSpace);
|
||||||
|
|
||||||
|
drawOutline(unit);
|
||||||
|
|
||||||
Draw.z(z);
|
Draw.z(z);
|
||||||
if(engineSize > 0) drawEngine(unit);
|
if(engineSize > 0) drawEngine(unit);
|
||||||
drawBody(unit);
|
drawBody(unit);
|
||||||
@@ -507,6 +504,20 @@ public class UnitType extends UnlockableContent{
|
|||||||
Drawf.shadow(wx, wy, weapon.occlusion);
|
Drawf.shadow(wx, wy, weapon.occlusion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(weapon.outlineRegion.found()){
|
||||||
|
float z = Draw.z();
|
||||||
|
if(!weapon.top) Draw.z(z - outlineSpace);
|
||||||
|
|
||||||
|
Draw.rect(weapon.outlineRegion,
|
||||||
|
wx, wy,
|
||||||
|
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
||||||
|
weapon.region.height * Draw.scl,
|
||||||
|
weaponRotation);
|
||||||
|
|
||||||
|
|
||||||
|
Draw.z(z);
|
||||||
|
}
|
||||||
|
|
||||||
Draw.rect(weapon.region,
|
Draw.rect(weapon.region,
|
||||||
wx, wy,
|
wx, wy,
|
||||||
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
width * Draw.scl * -Mathf.sign(weapon.flipSprite),
|
||||||
@@ -529,10 +540,16 @@ public class UnitType extends UnlockableContent{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawOutline(Unit unit){
|
||||||
|
if(Core.atlas.isFound(outlineRegion)){
|
||||||
|
Draw.rect(outlineRegion, unit.x, unit.y, unit.rotation - 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void drawBody(Unit unit){
|
public void drawBody(Unit unit){
|
||||||
applyColor(unit);
|
applyColor(unit);
|
||||||
|
|
||||||
Draw.rect(region, unit, unit.rotation - 90);
|
Draw.rect(region, unit.x, unit.y, unit.rotation - 90);
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
@@ -541,7 +558,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
applyColor(unit);
|
applyColor(unit);
|
||||||
|
|
||||||
Draw.color(cellColor(unit));
|
Draw.color(cellColor(unit));
|
||||||
Draw.rect(cellRegion, unit, unit.rotation - 90);
|
Draw.rect(cellRegion, unit.x, unit.y, unit.rotation - 90);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +568,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
|
|
||||||
public void drawLight(Unit unit){
|
public void drawLight(Unit unit){
|
||||||
if(lightRadius > 0){
|
if(lightRadius > 0){
|
||||||
Drawf.light(unit.team, unit, lightRadius, lightColor, lightOpacity);
|
Drawf.light(unit.team, unit.x, unit.y, lightRadius, lightColor, lightOpacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class Weapon{
|
|||||||
public boolean alternate = true;
|
public boolean alternate = true;
|
||||||
/** whether to rotate toward the target independently of unit */
|
/** whether to rotate toward the target independently of unit */
|
||||||
public boolean rotate = false;
|
public boolean rotate = false;
|
||||||
|
/** whether to draw the outline on top. */
|
||||||
|
public boolean top = true;
|
||||||
/** rotation speed of weapon when rotation is enabled, in degrees/t*/
|
/** rotation speed of weapon when rotation is enabled, in degrees/t*/
|
||||||
public float rotateSpeed = 20f;
|
public float rotateSpeed = 20f;
|
||||||
/** weapon reload in frames */
|
/** weapon reload in frames */
|
||||||
@@ -71,6 +73,8 @@ public class Weapon{
|
|||||||
public TextureRegion region;
|
public TextureRegion region;
|
||||||
/** heat region, must be same size as region (optional) */
|
/** heat region, must be same size as region (optional) */
|
||||||
public TextureRegion heatRegion;
|
public TextureRegion heatRegion;
|
||||||
|
/** outline region to display if top is false */
|
||||||
|
public TextureRegion outlineRegion;
|
||||||
/** heat region tint */
|
/** heat region tint */
|
||||||
public Color heatColor = Pal.turretHeat;
|
public Color heatColor = Pal.turretHeat;
|
||||||
|
|
||||||
@@ -91,6 +95,7 @@ public class Weapon{
|
|||||||
public void load(){
|
public void load(){
|
||||||
region = Core.atlas.find(name, Core.atlas.find("clear"));
|
region = Core.atlas.find(name, Core.atlas.find("clear"));
|
||||||
heatRegion = Core.atlas.find(name + "-heat");
|
heatRegion = Core.atlas.find(name + "-heat");
|
||||||
|
outlineRegion = Core.atlas.find(name + "-outline");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mindustry.tools;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@@ -312,23 +313,36 @@ public class Generators{
|
|||||||
type.load();
|
type.load();
|
||||||
type.init();
|
type.init();
|
||||||
|
|
||||||
//TODO decide whether to keep weapon outlines or not
|
Color outc = Pal.darkerMetal;
|
||||||
if(true)
|
//Func<Image, Image> outlineS = i -> i.shadow(0.8f, 9);
|
||||||
|
Func<Image, Image> outline = i -> i.outline(4, outc);
|
||||||
|
Cons<TextureRegion> outliner = t -> {
|
||||||
|
if(t != null && t.found()){
|
||||||
|
ImagePacker.replace(t, outline.get(ImagePacker.get(t)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for(Weapon weapon : type.weapons){
|
for(Weapon weapon : type.weapons){
|
||||||
if(weapon.rotate && outlined.add(weapon.name) && ImagePacker.has(weapon.name)){
|
if(outlined.add(weapon.name) && ImagePacker.has(weapon.name)){
|
||||||
ImagePacker.get(weapon.name).outline(4, Pal.darkerMetal).save(weapon.name);
|
outline.get(ImagePacker.get(weapon.name)).save(weapon.name + "-outline");
|
||||||
|
|
||||||
((GenRegion)Core.atlas.find(weapon.name)).path.delete();
|
//old outline
|
||||||
|
//ImagePacker.get(weapon.name).outline(4, Pal.darkerMetal).save(weapon.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image image = ImagePacker.get(type.parts > 0 ? type.partRegions[0] : type.region);
|
//baseRegion, legRegion, region, shadowRegion, cellRegion,
|
||||||
for(int i = 1; i < type.parts; i++){
|
// occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion;
|
||||||
image.draw(ImagePacker.get(type.partRegions[i]));
|
|
||||||
}
|
outliner.get(type.jointRegion);
|
||||||
if(type.parts > 0){
|
outliner.get(type.footRegion);
|
||||||
image.save(type.name);
|
outliner.get(type.legBaseRegion);
|
||||||
}
|
outliner.get(type.baseJointRegion);
|
||||||
|
|
||||||
|
Image image = ImagePacker.get(type.region);
|
||||||
|
|
||||||
|
outline.get(image).save(type.name + "-outline");
|
||||||
|
//ImagePacker.replace(type.region, outline.get(image));
|
||||||
|
|
||||||
if(type.constructor.get() instanceof Mechc){
|
if(type.constructor.get() instanceof Mechc){
|
||||||
image.drawCenter(type.baseRegion);
|
image.drawCenter(type.baseRegion);
|
||||||
@@ -337,15 +351,7 @@ public class Generators{
|
|||||||
image.draw(type.region);
|
image.draw(type.region);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image baseCell = ImagePacker.get(type.parts > 0 ? type.partCellRegions[0] : type.cellRegion);
|
Image baseCell = ImagePacker.get(type.cellRegion);
|
||||||
for(int i = 1; i < type.parts; i++){
|
|
||||||
baseCell.draw(ImagePacker.get(type.partCellRegions[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type.parts > 0){
|
|
||||||
image.save(type.name + "-cell");
|
|
||||||
}
|
|
||||||
|
|
||||||
Image cell = new Image(type.cellRegion.width, type.cellRegion.height);
|
Image cell = new Image(type.cellRegion.width, type.cellRegion.height);
|
||||||
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.func.*;
|
|||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.tools.ImagePacker.*;
|
import mindustry.tools.ImagePacker.*;
|
||||||
@@ -88,6 +89,49 @@ class Image{
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image shadow(float alpha, int rad){
|
||||||
|
Image out = silhouette(new Color(0f, 0f, 0f, alpha)).blur(rad);
|
||||||
|
out.draw(this);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image silhouette(Color color){
|
||||||
|
Image out = copy();
|
||||||
|
|
||||||
|
each((x, y) -> out.draw(x, y, getColor(x, y).set(color.r, color.g, color.b, this.color.a * color.a)));
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image blur(int radius){
|
||||||
|
Image out = copy();
|
||||||
|
Color c = new Color();
|
||||||
|
int[] sum = {0};
|
||||||
|
|
||||||
|
for(int x = 0; x < out.width; x++){
|
||||||
|
for(int y = 0; y < out.height; y++){
|
||||||
|
sum[0] = 0;
|
||||||
|
|
||||||
|
Geometry.circle(x, y, radius, (cx, cy) -> {
|
||||||
|
int rx = Mathf.clamp(cx, 0, out.width - 1), ry = Mathf.clamp(cy, 0, out.height - 1);
|
||||||
|
|
||||||
|
Color other = getColor(rx, ry);
|
||||||
|
c.r += other.r;
|
||||||
|
c.g += other.g;
|
||||||
|
c.b += other.b;
|
||||||
|
c.a += other.a;
|
||||||
|
sum[0] ++;
|
||||||
|
});
|
||||||
|
|
||||||
|
c.mula(1f / sum[0]);
|
||||||
|
|
||||||
|
out.draw(x, y, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
void each(Intc2 cons){
|
void each(Intc2 cons){
|
||||||
for(int x = 0; x < width; x++){
|
for(int x = 0; x < width; x++){
|
||||||
for(int y = 0; y < height; y++){
|
for(int y = 0; y < height; y++){
|
||||||
|
|||||||
@@ -163,6 +163,15 @@ public class ImagePacker{
|
|||||||
return new Image(imageCache.get(((AtlasRegion)region).name));
|
return new Image(imageCache.get(((AtlasRegion)region).name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void replace(String name, Image image){
|
||||||
|
image.save(name);
|
||||||
|
((GenRegion)Core.atlas.find(name)).path.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void replace(TextureRegion region, Image image){
|
||||||
|
replace(((GenRegion)region).name, image);
|
||||||
|
}
|
||||||
|
|
||||||
static void err(String message, Object... args){
|
static void err(String message, Object... args){
|
||||||
throw new IllegalArgumentException(Strings.format(message, args));
|
throw new IllegalArgumentException(Strings.format(message, args));
|
||||||
}
|
}
|
||||||
|
|||||||