Renamed constraints to bounds.

This commit is contained in:
Ondřej Hruška
2014-04-13 00:02:45 +02:00
parent 4816e0b539
commit e1d87df697
49 changed files with 1168 additions and 1291 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
package mightypork.rogue.screens;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.Screen;
@@ -12,7 +12,7 @@ import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.string.StringProvider;
@@ -39,7 +39,7 @@ public class LayerFps extends ScreenLayer {
final GLFont font = Res.getFont("default");
final RectConstraint constraint = cBox(cAdd(cTopRight(this), -8, 8), 0, 32);
final RectBound constraint = box(add(topRight(this), -8, 8), 0, 32);
tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, new StringProvider() {
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.test_bouncyboxes;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import java.util.Random;
@@ -11,31 +11,31 @@ import mightypork.gamecore.render.Render;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.NumberConstraint;
import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.constraints.NumberBound;
import mightypork.utils.math.constraints.RectBound;
public class BouncyBox extends PluggableRenderer implements Updateable {
private final Random rand = new Random();
private final RectConstraint box;
private final RectBound box;
private final AnimDouble pos = new AnimDouble(0, Easing.BOUNCE_OUT);
public BouncyBox() {
// create box
final NumberConstraint side = cHeight(this);
RectConstraint abox = cBox(this, side, side);
final NumberBound side = height(this);
RectBound abox = box(this, side, side);
// move
final NumberConstraint move_length = cSub(cWidth(this), side);
final NumberConstraint offset = cMul(move_length, pos);
abox = cMove(abox, offset, 0);
final NumberBound move_length = sub(width(this), side);
final NumberBound offset = mul(move_length, pos);
abox = move(abox, offset, 0);
// add padding
abox = cShrink(abox, cPerc(side, 10));
abox = shrink(abox, perc(side, 10));
box = abox;
}
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.test_bouncyboxes;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import java.util.ArrayList;
import java.util.List;
@@ -15,7 +15,7 @@ import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.VectVal;
@@ -47,7 +47,7 @@ public class LayerBouncyBoxes extends ScreenLayer {
});
// shrink screen rect by 8% on all sides
final RectConstraint holder_rect = cShrink(this, cPerc(cWidth(this), 4));
final RectBound holder_rect = shrink(this, perc(width(this), 4));
addChildClient(layout = new RowHolder(screen, holder_rect, 11));
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.test_cat_sound;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import java.util.Random;
@@ -19,6 +19,7 @@ import mightypork.rogue.Res;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.Bounds;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectMutable;
import mightypork.utils.math.vect.VectMutableAnim;
@@ -45,7 +46,7 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
cat = new ImagePainter(Res.getTxQuad("test.kitten"));
cat.setContext(cCenterTo(cBox(size, size), pos));
cat.setContext(centerTo(box(size, size), pos));
tp = new TextPainter(Res.getFont("default"));
tp.setAlign(Align.CENTER);
@@ -53,10 +54,10 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
tp.setText("Meow!");
tp.setShadow(RGB.dark(0.8), VectVal.make(2, 2));
tp.setContext(cCenterTo(cBox(64, 64), cMousePos));
tp.setContext(centerTo(box(64, 64), cMousePos));
qp = QuadPainter.gradV(RGB.YELLOW, RGB.RED);
qp.setContext(cExpand(cBottomLeft(cat), 0, 0, 50, 50));
qp.setContext(expand(bottomLeft(cat), 0, 0, 50, 50));
/*
* Register keys
@@ -1,15 +1,15 @@
package mightypork.rogue.screens.test_font;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.NumberConstraint;
import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.constraints.NumberBound;
import mightypork.utils.math.constraints.RectBound;
public class ScreenTestFont extends Screen {
@@ -23,9 +23,9 @@ public class ScreenTestFont extends Screen {
tp = new TextPainter(Res.getFont("default"), Align.CENTER, RGB.GREEN);
tp.setText("Hello World!");
final NumberConstraint fontHeight = cMul(getDisplay().getSize().yc(), 0.1);
final NumberBound fontHeight = mul(getDisplay().getSize().yc(), 0.1);
final RectConstraint strbox = cCenterTo(cBox(fontHeight), this);
final RectBound strbox = centerTo(box(fontHeight), this);
tp.setContext(strbox);
}
@@ -1,13 +1,13 @@
package mightypork.rogue.screens.test_render;
import static mightypork.utils.math.constraints.Constraints.*;
import static mightypork.utils.math.constraints.Bounds.*;
import mightypork.gamecore.control.timing.Poller;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.Vect;
@@ -15,15 +15,15 @@ public class LayerTestGradient extends ScreenLayer {
private final Poller p = new Poller();
private final RectConstraint pos1;
private final RectConstraint pos2;
private final RectBound pos1;
private final RectBound pos2;
public LayerTestGradient(Screen screen) {
super(screen);
pos1 = cCached(p, cGrowDown(cTopEdge(this), 64));
pos2 = cCached(p, cShrinkTop(cGrowRight(cLeftEdge(this), 64), 64));
pos1 = cached(p, growDown(edgeTop(this), 64));
pos2 = cached(p, shrinkTop(growRight(edgeLeft(this), 64), 64));
}