new layouts & start of main menu

v5stable
Ondřej Hruška 11 years ago
parent 3cad5ad202
commit 990c3de5ca
  1. 11
      src/mightypork/gamecore/gui/AlignX.java
  2. 11
      src/mightypork/gamecore/gui/AlignY.java
  3. 2
      src/mightypork/gamecore/gui/components/InputComponent.java
  4. 2
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  5. 2
      src/mightypork/gamecore/gui/components/VisualComponent.java
  6. 2
      src/mightypork/gamecore/gui/components/layout/ColumnHolder.java
  7. 82
      src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java
  8. 2
      src/mightypork/gamecore/gui/components/layout/RowHolder.java
  9. 82
      src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java
  10. 14
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  11. 14
      src/mightypork/gamecore/render/fonts/FontRenderer.java
  12. 1
      src/mightypork/gamecore/render/fonts/impl/NullFont.java
  13. 5
      src/mightypork/rogue/App.java
  14. 4
      src/mightypork/rogue/screens/LayerFps.java
  15. 46
      src/mightypork/rogue/screens/main_menu/MenuLayer.java
  16. 23
      src/mightypork/rogue/screens/main_menu/ScreenMainMenu.java
  17. 4
      src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java
  18. 14
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java
  19. 47
      src/mightypork/utils/math/constraints/rect/Rect.java

@ -0,0 +1,11 @@
package mightypork.gamecore.gui;
/**
* Horizontal align sides
*
* @author MightyPork
*/
public enum AlignX
{
LEFT, CENTER, RIGHT;
}

@ -0,0 +1,11 @@
package mightypork.gamecore.gui;
/**
* Vertical align sides
*
* @author MightyPork
*/
public enum AlignY
{
TOP, CENTER, BOTTOM;
}

@ -7,7 +7,7 @@ import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.ActionTrigger; import mightypork.gamecore.gui.ActionTrigger;
public abstract class InputComponent extends VisualComponent implements Component, Enableable, ActionTrigger, MouseButtonEvent.Listener { public abstract class InputComponent extends VisualComponent implements Enableable, ActionTrigger, MouseButtonEvent.Listener {
private boolean enabled; private boolean enabled;
private Action action; private Action action;

@ -15,7 +15,7 @@ import mightypork.gamecore.render.DisplaySystem;
import mightypork.utils.math.constraints.rect.proxy.RectBound; import mightypork.utils.math.constraints.rect.proxy.RectBound;
public abstract class LayoutComponent extends VisualComponent implements Component, Enableable, ClientHub, AppAccess { public abstract class LayoutComponent extends VisualComponent implements Enableable, ClientHub, AppAccess {
private boolean enabled; private boolean enabled;

@ -67,7 +67,7 @@ public abstract class VisualComponent extends AbstractRectCache implements Compo
if (!visible) return; if (!visible) return;
renderComponent(); renderComponent();
}; }
@Override @Override

@ -26,7 +26,7 @@ public class ColumnHolder extends LayoutComponent {
*/ */
public ColumnHolder(AppAccess app, RectBound context, int cols) { public ColumnHolder(AppAccess app, RectBound context, int cols) {
super(app, context); super(app, context);
this.tiler = getRect().columns(cols).zeroBased(); this.tiler = columns(cols).zeroBased();
} }

@ -0,0 +1,82 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.gui.components.Component;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.proxy.RectBound;
/**
* Holder with same-sized columns, aligned to left or right
*
* @author MightyPork
*/
public class HorizontalFixedFlowLayout extends LayoutComponent {
private int col = 0;
private Num colWidth;
private AlignX align;
/**
* @param app app access
* @param context context
* @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT.
*/
public HorizontalFixedFlowLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align) {
super(app, context);
this.colWidth = elementWidth;
this.align = align;
if (align != AlignX.LEFT && align != AlignX.RIGHT) {
throw new IllegalArgumentException("Can align only left or right.");
}
}
/**
* make a new holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT.
*/
public HorizontalFixedFlowLayout(AppAccess app, Num elementWidth, AlignX align) {
this(app, null, elementWidth, align);
}
/**
* Add an item
*
* @param elem
*/
public void add(final Component elem)
{
if (elem == null) return;
final Rect r;
switch (align) {
case LEFT:
r = leftEdge().growRight(colWidth).moveX(colWidth.mul(col++));
break;
case RIGHT:
r = rightEdge().growLeft(colWidth).moveX(colWidth.mul(-(col++)));
break;
default:
throw new IllegalArgumentException("Bad align.");
}
elem.setRect(r);
attach(elem);
}
}

@ -38,7 +38,7 @@ public class RowHolder extends LayoutComponent {
*/ */
public RowHolder(AppAccess app, RectBound context, int rows) { public RowHolder(AppAccess app, RectBound context, int rows) {
super(app, context); super(app, context);
this.tiler = getRect().rows(rows).zeroBased(); this.tiler = rows(rows).zeroBased();
} }

@ -0,0 +1,82 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.AlignY;
import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.gui.components.Component;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.proxy.RectBound;
/**
* Holder with same-sized rows, aligned to top or bottom
*
* @author MightyPork
*/
public class VerticalFixedFlowLayout extends LayoutComponent {
private int row = 0;
private Num rowHeight;
private AlignY align;
/**
* @param app app access
* @param context context
* @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM.
*/
public VerticalFixedFlowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align) {
super(app, context);
this.rowHeight = elementHeight;
this.align = align;
if (align != AlignY.TOP && align != AlignY.BOTTOM) {
throw new IllegalArgumentException("Can align only to top or bottom.");
}
}
/**
* make a new holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM.
*/
public VerticalFixedFlowLayout(AppAccess app, Num elementHeight, AlignY align) {
this(app, null, elementHeight, align);
}
/**
* Add an item
*
* @param elem
*/
public void add(final Component elem)
{
if (elem == null) return;
final Rect r;
switch (align) {
case TOP:
r = topEdge().growDown(rowHeight).moveY(rowHeight.mul(row++));
break;
case BOTTOM:
r = bottomEdge().growUp(rowHeight).moveY(rowHeight.mul(-(row++)));
break;
default:
throw new IllegalArgumentException("Bad align.");
}
elem.setRect(r);
attach(elem);
}
}

@ -1,9 +1,9 @@
package mightypork.gamecore.gui.components.painters; package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.VisualComponent; import mightypork.gamecore.gui.components.VisualComponent;
import mightypork.gamecore.render.fonts.FontRenderer; import mightypork.gamecore.render.fonts.FontRenderer;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont; import mightypork.gamecore.render.fonts.GLFont;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.rect.Rect; import mightypork.utils.math.constraints.rect.Rect;
@ -23,7 +23,7 @@ public class TextPainter extends VisualComponent {
private final FontRenderer font; private final FontRenderer font;
private RGB color; private RGB color;
private Align align; private AlignX align;
private StringProvider text; private StringProvider text;
private boolean shadow; private boolean shadow;
@ -35,7 +35,7 @@ public class TextPainter extends VisualComponent {
* @param font font to use * @param font font to use
*/ */
public TextPainter(GLFont font) { public TextPainter(GLFont font) {
this(font, Align.LEFT, RGB.WHITE); this(font, AlignX.LEFT, RGB.WHITE);
} }
@ -47,7 +47,7 @@ public class TextPainter extends VisualComponent {
* @param color default color * @param color default color
* @param text drawn text * @param text drawn text
*/ */
public TextPainter(GLFont font, Align align, RGB color, String text) { public TextPainter(GLFont font, AlignX align, RGB color, String text) {
this(font, align, color, new StringWrapper(text)); this(font, align, color, new StringWrapper(text));
} }
@ -60,7 +60,7 @@ public class TextPainter extends VisualComponent {
* @param color default color * @param color default color
* @param text text provider * @param text text provider
*/ */
public TextPainter(GLFont font, Align align, RGB color, StringProvider text) { public TextPainter(GLFont font, AlignX align, RGB color, StringProvider text) {
this.font = new FontRenderer(font); this.font = new FontRenderer(font);
this.color = color; this.color = color;
this.align = align; this.align = align;
@ -73,7 +73,7 @@ public class TextPainter extends VisualComponent {
* @param align text align * @param align text align
* @param color default color * @param color default color
*/ */
public TextPainter(GLFont font, Align align, RGB color) { public TextPainter(GLFont font, AlignX align, RGB color) {
this(font, align, color, (StringProvider) null); this(font, align, color, (StringProvider) null);
} }
@ -125,7 +125,7 @@ public class TextPainter extends VisualComponent {
} }
public void setAlign(Align align) public void setAlign(AlignX align)
{ {
this.align = align; this.align = align;
} }

@ -1,6 +1,7 @@
package mightypork.gamecore.render.fonts; package mightypork.gamecore.render.fonts;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.rect.Rect; import mightypork.utils.math.constraints.rect.Rect;
@ -16,11 +17,6 @@ public class FontRenderer {
private GLFont font; private GLFont font;
public static enum Align
{
LEFT, CENTER, RIGHT;
}
private RGB color; private RGB color;
@ -125,7 +121,7 @@ public class FontRenderer {
* for align) * for align)
* @param align horizontal alignment (with respect to bounds) * @param align horizontal alignment (with respect to bounds)
*/ */
public void draw(String text, Rect bounds, Align align) public void draw(String text, Rect bounds, AlignX align)
{ {
this.draw(text, bounds, align, this.color); this.draw(text, bounds, align, this.color);
} }
@ -140,7 +136,7 @@ public class FontRenderer {
* @param align horizontal alignment (with respect to bounds) * @param align horizontal alignment (with respect to bounds)
* @param color drawing color * @param color drawing color
*/ */
public void draw(String text, Rect bounds, Align align, RGB color) public void draw(String text, Rect bounds, AlignX align, RGB color)
{ {
Vect start; Vect start;
@ -171,7 +167,7 @@ public class FontRenderer {
* @param height drawing height * @param height drawing height
* @param align horizontal alignment * @param align horizontal alignment
*/ */
public void draw(String text, Vect pos, double height, Align align) public void draw(String text, Vect pos, double height, AlignX align)
{ {
draw(text, pos, height, align, this.color); draw(text, pos, height, align, this.color);
} }
@ -186,7 +182,7 @@ public class FontRenderer {
* @param align horizontal alignment * @param align horizontal alignment
* @param color drawing color * @param color drawing color
*/ */
public void draw(String text, Vect pos, double height, Align align, RGB color) public void draw(String text, Vect pos, double height, AlignX align, RGB color)
{ {
final double w = getWidth(text, height); final double w = getWidth(text, height);

@ -2,7 +2,6 @@ package mightypork.gamecore.render.fonts.impl;
import mightypork.gamecore.render.fonts.GLFont; import mightypork.gamecore.render.fonts.GLFont;
import mightypork.utils.logging.Log;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.vect.Vect; import mightypork.utils.math.constraints.vect.Vect;

@ -14,6 +14,7 @@ import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.DisplaySystem; import mightypork.gamecore.render.DisplaySystem;
import mightypork.rogue.events.ActionRequest; import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.events.ActionRequest.RequestType; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.rogue.screens.main_menu.ScreenMainMenu;
import mightypork.rogue.screens.test_bouncyboxes.ScreenTestBouncy; import mightypork.rogue.screens.test_bouncyboxes.ScreenTestBouncy;
import mightypork.rogue.screens.test_cat_sound.ScreenTestCat; import mightypork.rogue.screens.test_cat_sound.ScreenTestCat;
import mightypork.rogue.screens.test_render.ScreenTestRender; import mightypork.rogue.screens.test_render.ScreenTestRender;
@ -68,7 +69,9 @@ public class App extends BaseApp {
screens.add(new ScreenTestCat(this)); screens.add(new ScreenTestCat(this));
screens.add(new ScreenTestRender(this)); screens.add(new ScreenTestRender(this));
screens.showScreen("test.render"); screens.add(new ScreenMainMenu(this));
screens.showScreen("rogue.menu");
} }

@ -2,12 +2,12 @@ package mightypork.rogue.screens;
import mightypork.gamecore.gui.Action; import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont; import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
@ -40,7 +40,7 @@ public class LayerFps extends ScreenLayer {
final RectBound constraint = root.topRight().add(-8, 8).expand(0, 0, 0, 32); final RectBound constraint = root.topRight().add(-8, 8).expand(0, 0, 0, 32);
tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, new StringProvider() { tp = new TextPainter(font, AlignX.RIGHT, RGB.WHITE, new StringProvider() {
@Override @Override
public String getString() public String getString()

@ -0,0 +1,46 @@
package mightypork.rogue.screens.main_menu;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.AlignY;
import mightypork.gamecore.gui.components.layout.VerticalFixedFlowLayout;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
class MenuLayer extends ScreenLayer {
public MenuLayer(Screen screen) {
super(screen);
init();
}
private void init()
{
Rect menuBox = root.shrink(root.height().min(root.width()).mul(0.1));
Num lineHeight = menuBox.height().min(menuBox.width()).mul(0.13);
VerticalFixedFlowLayout layout = new VerticalFixedFlowLayout(root, menuBox, lineHeight, AlignY.TOP);
root.add(layout);
GLFont f = Res.getFont("press_start");
layout.add(new TextPainter(f, AlignX.CENTER, RGB.WHITE, "Hello!"));
layout.add(new TextPainter(f, AlignX.CENTER, RGB.CYAN, "Woof Woof"));
layout.add(new TextPainter(f, AlignX.CENTER, RGB.PURPLE, "MooooOOoOO"));
layout.add(new TextPainter(f, AlignX.CENTER, RGB.GREEN, "Bye!"));
}
@Override
public int getPriority()
{
return 2;
}
}

@ -0,0 +1,23 @@
package mightypork.rogue.screens.main_menu;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.screens.LayeredScreen;
public class ScreenMainMenu extends LayeredScreen {
public ScreenMainMenu(AppAccess app) {
super(app);
addLayer(new MenuLayer(this));
}
@Override
public String getName()
{
return "rogue.menu";
}
}

@ -4,13 +4,13 @@ package mightypork.rogue.screens.test_bouncyboxes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.RowHolder; import mightypork.gamecore.gui.components.layout.RowHolder;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.num.Num; import mightypork.utils.math.constraints.num.Num;
@ -54,7 +54,7 @@ public class LayerBouncyBoxes extends ScreenLayer {
boxes.add(bbr); boxes.add(bbr);
} }
final TextPainter tp = new TextPainter(Res.getFont("default"), Align.LEFT, RGB.WHITE); final TextPainter tp = new TextPainter(Res.getFont("default"), AlignX.LEFT, RGB.WHITE);
tp.setText("Press \"C\" for \"Cat\" screen."); tp.setText("Press \"C\" for \"Cat\" screen.");
final Num shadowOffset = tp.height().div(16); final Num shadowOffset = tp.height().div(16);
tp.setShadow(RGB.RED, Vect.make(shadowOffset, shadowOffset)); tp.setShadow(RGB.RED, Vect.make(shadowOffset, shadowOffset));

@ -5,6 +5,7 @@ import java.util.Random;
import mightypork.gamecore.control.bus.events.MouseButtonEvent; import mightypork.gamecore.control.bus.events.MouseButtonEvent;
import mightypork.gamecore.control.timing.Updateable; import mightypork.gamecore.control.timing.Updateable;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.painters.ImagePainter; import mightypork.gamecore.gui.components.painters.ImagePainter;
import mightypork.gamecore.gui.components.painters.QuadPainter; import mightypork.gamecore.gui.components.painters.QuadPainter;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
@ -12,7 +13,6 @@ import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.utils.math.Easing; import mightypork.utils.math.Easing;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
@ -23,7 +23,7 @@ import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.mutable.VectAnimated; import mightypork.utils.math.constraints.vect.mutable.VectAnimated;
public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.Listener, Updateable { public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.Listener {
private final NumAnimated size = new NumAnimated(300, Easing.SINE_BOTH); private final NumAnimated size = new NumAnimated(300, Easing.SINE_BOTH);
private final VectAnimated cat_position = VectAnimated.makeVar(Easing.ELASTIC_OUT); private final VectAnimated cat_position = VectAnimated.makeVar(Easing.ELASTIC_OUT);
@ -44,7 +44,7 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List
cat_position.setDefaultDuration(3); cat_position.setDefaultDuration(3);
ImagePainter cat = new ImagePainter(Res.getTxQuad("test.kitten")); ImagePainter cat = new ImagePainter(Res.getTxQuad("test.kitten"));
cat.setRect(Rect.make(size, size).centerTo(cat_position)); cat.setRect(Rect.make(size).centerTo(cat_position));
cat.enableCaching(false); cat.enableCaching(false);
// frame around cat // frame around cat
@ -57,6 +57,7 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List
cat_shadow.setRect(cat_frame.move(Vect.make(cat.height().mul(0.05)))); cat_shadow.setRect(cat_frame.move(Vect.make(cat.height().mul(0.05))));
cat_shadow.enableCaching(false); cat_shadow.enableCaching(false);
// add to root layout
root.add(cat_shadow); root.add(cat_shadow);
root.add(cat_frame); root.add(cat_frame);
root.add(cat); root.add(cat);
@ -64,13 +65,14 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List
// Meow // Meow
TextPainter tp = new TextPainter(Res.getFont("press_start")); TextPainter tp = new TextPainter(Res.getFont("press_start"));
tp.setAlign(Align.CENTER); tp.setAlign(AlignX.CENTER);
tp.setColor(RGB.YELLOW); tp.setColor(RGB.YELLOW);
tp.setText("Meow!"); tp.setText("Meow!");
tp.setShadow(RGB.dark(0.5), Vect.make(tp.height().div(16))); tp.setShadow(RGB.dark(0.5), Vect.make(tp.height().div(16)));
tp.setRect(Rect.make(Num.ZERO, cat.height().half()).centerTo(mouse)); tp.setRect(Rect.make(cat.height().half()).centerTo(mouse));
tp.enableCaching(false); tp.enableCaching(false);
root.add(tp); root.add(tp);
/* /*
* Register keys * Register keys
*/ */
@ -90,7 +92,7 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List
{ {
if (!event.isDown()) return; if (!event.isDown()) return;
this.cat_position.setTo(event.getPos()); cat_position.setTo(event.getPos());
double newSize = root.height().perc(10 + rand.nextInt(40)).value(); double newSize = root.height().perc(10 + rand.nextInt(40)).value();

@ -6,6 +6,7 @@ import mightypork.utils.math.constraints.DigestCache;
import mightypork.utils.math.constraints.Digestable; import mightypork.utils.math.constraints.Digestable;
import mightypork.utils.math.constraints.num.Num; import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst; import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.num.mutable.NumAnimated;
import mightypork.utils.math.constraints.rect.builders.TiledRect; import mightypork.utils.math.constraints.rect.builders.TiledRect;
import mightypork.utils.math.constraints.rect.caching.RectCache; import mightypork.utils.math.constraints.rect.caching.RectCache;
import mightypork.utils.math.constraints.rect.caching.RectDigest; import mightypork.utils.math.constraints.rect.caching.RectDigest;
@ -61,6 +62,13 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
} }
@FactoryMethod
public static Rect make(Vect origin, Num width, Num height)
{
return make(origin, Vect.make(width, height));
}
@FactoryMethod @FactoryMethod
public static Rect make(final Vect origin, final Vect size) public static Rect make(final Vect origin, final Vect size)
{ {
@ -76,7 +84,22 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
return Rect.make(origin, size); return Rect.make(origin, size);
} }
public static Rect make(Num side)
{
return make(side,side);
}
public static RectConst make(NumConst side)
{
return make(side,side);
}
public static RectConst make(double side)
{
return make(side,side);
}
@FactoryMethod @FactoryMethod
public static RectConst make(NumConst x, NumConst y, NumConst width, NumConst height) public static RectConst make(NumConst x, NumConst y, NumConst width, NumConst height)
@ -289,6 +312,30 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
} }
public Rect moveX(Num x)
{
return move(x, Num.ZERO);
}
public Rect moveY(Num y)
{
return move(Num.ZERO, y);
}
public Rect moveX(double x)
{
return move(x, 0);
}
public Rect moveY(double y)
{
return move(0, y);
}
/** /**
* Add X and Y to origin * Add X and Y to origin
* *

Loading…
Cancel
Save