Rotate slider in the mirror filter. (#5228)

* Rotate

* ToggleOption
This commit is contained in:
TranquillyUnpleasant 2021-06-03 23:35:31 +05:00 committed by GitHub
parent f91cc2eace
commit eb7e65668c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -484,6 +484,7 @@ filter.option.circle-scale = Circle Scale
filter.option.octaves = Octaves
filter.option.falloff = Falloff
filter.option.angle = Angle
filter.option.rotate = Rotate
filter.option.amount = Amount
filter.option.block = Block
filter.option.floor = Floor

View File

@ -111,4 +111,23 @@ public abstract class FilterOption{
table.add("@filter.option." + name);
}
}
static class ToggleOption extends FilterOption{
final String name;
final Boolp getter;
final Boolc setter;
ToggleOption(String name, Boolp getter, Boolc setter){
this.name = name;
this.getter = getter;
this.setter = setter;
}
@Override
public void build(Table table){
table.row();
CheckBox check = table.check("@filter.option." + name, setter).growX().padBottom(5).padTop(5).center().get();
check.changed(changed);
}
}
}

View File

@ -15,11 +15,13 @@ public class MirrorFilter extends GenerateFilter{
private final Vec2 v1 = new Vec2(), v2 = new Vec2(), v3 = new Vec2();
int angle = 45;
boolean rotate = false;
@Override
public FilterOption[] options(){
return Structs.arr(
new SliderOption("angle", () -> angle, f -> angle = (int)f, 0, 360, 45)
new SliderOption("angle", () -> angle, f -> angle = (int)f, 0, 360, 45),
new ToggleOption("rotate", () -> rotate, f -> rotate = f)
);
}
@ -72,8 +74,8 @@ public class MirrorFilter extends GenerateFilter{
}
void mirror(Vec2 p, float x0, float y0, float x1, float y1){
//special case: uneven map mirrored at 45 degree angle
if(in.width != in.height && angle % 90 != 0){
//special case: uneven map mirrored at 45 degree angle (or someone might just want rotational symmetry)
if((in.width != in.height && angle % 90 != 0) || rotate){
p.x = in.width - p.x - 1;
p.y = in.height - p.y - 1;
}else{