diff --git a/src/mightypork/gamecore/gui/AlignX.java b/src/mightypork/gamecore/gui/AlignX.java new file mode 100644 index 0000000..07e3f00 --- /dev/null +++ b/src/mightypork/gamecore/gui/AlignX.java @@ -0,0 +1,11 @@ +package mightypork.gamecore.gui; + +/** + * Horizontal align sides + * + * @author MightyPork + */ +public enum AlignX +{ + LEFT, CENTER, RIGHT; +} \ No newline at end of file diff --git a/src/mightypork/gamecore/gui/AlignY.java b/src/mightypork/gamecore/gui/AlignY.java new file mode 100644 index 0000000..7c8f4cb --- /dev/null +++ b/src/mightypork/gamecore/gui/AlignY.java @@ -0,0 +1,11 @@ +package mightypork.gamecore.gui; + +/** + * Vertical align sides + * + * @author MightyPork + */ +public enum AlignY +{ + TOP, CENTER, BOTTOM; +} \ No newline at end of file diff --git a/src/mightypork/gamecore/gui/components/InputComponent.java b/src/mightypork/gamecore/gui/components/InputComponent.java index 85f9bf8..37e55d3 100644 --- a/src/mightypork/gamecore/gui/components/InputComponent.java +++ b/src/mightypork/gamecore/gui/components/InputComponent.java @@ -7,7 +7,7 @@ import mightypork.gamecore.gui.Action; 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 Action action; diff --git a/src/mightypork/gamecore/gui/components/LayoutComponent.java b/src/mightypork/gamecore/gui/components/LayoutComponent.java index 9d1cf34..12e2eba 100644 --- a/src/mightypork/gamecore/gui/components/LayoutComponent.java +++ b/src/mightypork/gamecore/gui/components/LayoutComponent.java @@ -15,7 +15,7 @@ import mightypork.gamecore.render.DisplaySystem; 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; diff --git a/src/mightypork/gamecore/gui/components/VisualComponent.java b/src/mightypork/gamecore/gui/components/VisualComponent.java index 6249d9b..6d19dd7 100644 --- a/src/mightypork/gamecore/gui/components/VisualComponent.java +++ b/src/mightypork/gamecore/gui/components/VisualComponent.java @@ -67,7 +67,7 @@ public abstract class VisualComponent extends AbstractRectCache implements Compo if (!visible) return; renderComponent(); - }; + } @Override diff --git a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java index bb3a8ee..b7295c2 100644 --- a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java @@ -26,7 +26,7 @@ public class ColumnHolder extends LayoutComponent { */ public ColumnHolder(AppAccess app, RectBound context, int cols) { super(app, context); - this.tiler = getRect().columns(cols).zeroBased(); + this.tiler = columns(cols).zeroBased(); } diff --git a/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java b/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java new file mode 100644 index 0000000..fd9bf83 --- /dev/null +++ b/src/mightypork/gamecore/gui/components/layout/HorizontalFixedFlowLayout.java @@ -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.
+ * 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); + } + +} diff --git a/src/mightypork/gamecore/gui/components/layout/RowHolder.java b/src/mightypork/gamecore/gui/components/layout/RowHolder.java index 5ef0238..92fb6bd 100644 --- a/src/mightypork/gamecore/gui/components/layout/RowHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/RowHolder.java @@ -38,7 +38,7 @@ public class RowHolder extends LayoutComponent { */ public RowHolder(AppAccess app, RectBound context, int rows) { super(app, context); - this.tiler = getRect().rows(rows).zeroBased(); + this.tiler = rows(rows).zeroBased(); } diff --git a/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java b/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java new file mode 100644 index 0000000..30f7872 --- /dev/null +++ b/src/mightypork/gamecore/gui/components/layout/VerticalFixedFlowLayout.java @@ -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.
+ * 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); + } + +} diff --git a/src/mightypork/gamecore/gui/components/painters/TextPainter.java b/src/mightypork/gamecore/gui/components/painters/TextPainter.java index 1166bf8..db454da 100644 --- a/src/mightypork/gamecore/gui/components/painters/TextPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/TextPainter.java @@ -1,9 +1,9 @@ package mightypork.gamecore.gui.components.painters; +import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.components.VisualComponent; import mightypork.gamecore.render.fonts.FontRenderer; -import mightypork.gamecore.render.fonts.FontRenderer.Align; import mightypork.gamecore.render.fonts.GLFont; import mightypork.utils.math.color.RGB; import mightypork.utils.math.constraints.rect.Rect; @@ -23,7 +23,7 @@ public class TextPainter extends VisualComponent { private final FontRenderer font; private RGB color; - private Align align; + private AlignX align; private StringProvider text; private boolean shadow; @@ -35,7 +35,7 @@ public class TextPainter extends VisualComponent { * @param font font to use */ 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 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)); } @@ -60,7 +60,7 @@ public class TextPainter extends VisualComponent { * @param color default color * @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.color = color; this.align = align; @@ -73,7 +73,7 @@ public class TextPainter extends VisualComponent { * @param align text align * @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); } @@ -125,7 +125,7 @@ public class TextPainter extends VisualComponent { } - public void setAlign(Align align) + public void setAlign(AlignX align) { this.align = align; } diff --git a/src/mightypork/gamecore/render/fonts/FontRenderer.java b/src/mightypork/gamecore/render/fonts/FontRenderer.java index a0d5b57..d7ca285 100644 --- a/src/mightypork/gamecore/render/fonts/FontRenderer.java +++ b/src/mightypork/gamecore/render/fonts/FontRenderer.java @@ -1,6 +1,7 @@ package mightypork.gamecore.render.fonts; +import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.render.Render; import mightypork.utils.math.color.RGB; import mightypork.utils.math.constraints.rect.Rect; @@ -16,11 +17,6 @@ public class FontRenderer { private GLFont font; - public static enum Align - { - LEFT, CENTER, RIGHT; - } - private RGB color; @@ -125,7 +121,7 @@ public class FontRenderer { * for align) * @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); } @@ -140,7 +136,7 @@ public class FontRenderer { * @param align horizontal alignment (with respect to bounds) * @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; @@ -171,7 +167,7 @@ public class FontRenderer { * @param height drawing height * @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); } @@ -186,7 +182,7 @@ public class FontRenderer { * @param align horizontal alignment * @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); diff --git a/src/mightypork/gamecore/render/fonts/impl/NullFont.java b/src/mightypork/gamecore/render/fonts/impl/NullFont.java index f0ef8c4..a3fc34a 100644 --- a/src/mightypork/gamecore/render/fonts/impl/NullFont.java +++ b/src/mightypork/gamecore/render/fonts/impl/NullFont.java @@ -2,7 +2,6 @@ package mightypork.gamecore.render.fonts.impl; import mightypork.gamecore.render.fonts.GLFont; -import mightypork.utils.logging.Log; import mightypork.utils.math.color.RGB; import mightypork.utils.math.constraints.vect.Vect; diff --git a/src/mightypork/rogue/App.java b/src/mightypork/rogue/App.java index ba780ed..90fc2b2 100644 --- a/src/mightypork/rogue/App.java +++ b/src/mightypork/rogue/App.java @@ -14,6 +14,7 @@ import mightypork.gamecore.input.Keys; import mightypork.gamecore.render.DisplaySystem; import mightypork.rogue.events.ActionRequest; 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_cat_sound.ScreenTestCat; import mightypork.rogue.screens.test_render.ScreenTestRender; @@ -68,7 +69,9 @@ public class App extends BaseApp { screens.add(new ScreenTestCat(this)); screens.add(new ScreenTestRender(this)); - screens.showScreen("test.render"); + screens.add(new ScreenMainMenu(this)); + + screens.showScreen("rogue.menu"); } diff --git a/src/mightypork/rogue/screens/LayerFps.java b/src/mightypork/rogue/screens/LayerFps.java index c745607..59d4d29 100644 --- a/src/mightypork/rogue/screens/LayerFps.java +++ b/src/mightypork/rogue/screens/LayerFps.java @@ -2,12 +2,12 @@ package mightypork.rogue.screens; import mightypork.gamecore.gui.Action; +import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.Keys; -import mightypork.gamecore.render.fonts.FontRenderer.Align; import mightypork.gamecore.render.fonts.GLFont; import mightypork.rogue.Res; 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); - tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, new StringProvider() { + tp = new TextPainter(font, AlignX.RIGHT, RGB.WHITE, new StringProvider() { @Override public String getString() diff --git a/src/mightypork/rogue/screens/main_menu/MenuLayer.java b/src/mightypork/rogue/screens/main_menu/MenuLayer.java new file mode 100644 index 0000000..9d45e44 --- /dev/null +++ b/src/mightypork/rogue/screens/main_menu/MenuLayer.java @@ -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; + } + +} diff --git a/src/mightypork/rogue/screens/main_menu/ScreenMainMenu.java b/src/mightypork/rogue/screens/main_menu/ScreenMainMenu.java new file mode 100644 index 0000000..f11a514 --- /dev/null +++ b/src/mightypork/rogue/screens/main_menu/ScreenMainMenu.java @@ -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"; + } + +} diff --git a/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java b/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java index 2aea338..9b3e459 100644 --- a/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java +++ b/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java @@ -4,13 +4,13 @@ package mightypork.rogue.screens.test_bouncyboxes; import java.util.ArrayList; import java.util.List; +import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.components.layout.RowHolder; import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.input.KeyStroke; 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.num.Num; @@ -54,7 +54,7 @@ public class LayerBouncyBoxes extends ScreenLayer { 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."); final Num shadowOffset = tp.height().div(16); tp.setShadow(RGB.RED, Vect.make(shadowOffset, shadowOffset)); diff --git a/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java b/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java index 140aac4..0929cac 100644 --- a/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java +++ b/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java @@ -5,6 +5,7 @@ import java.util.Random; import mightypork.gamecore.control.bus.events.MouseButtonEvent; import mightypork.gamecore.control.timing.Updateable; +import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.components.painters.ImagePainter; import mightypork.gamecore.gui.components.painters.QuadPainter; 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.input.KeyStroke; import mightypork.gamecore.input.Keys; -import mightypork.gamecore.render.fonts.FontRenderer.Align; import mightypork.rogue.Res; import mightypork.utils.math.Easing; 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; -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 VectAnimated cat_position = VectAnimated.makeVar(Easing.ELASTIC_OUT); @@ -44,7 +44,7 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List cat_position.setDefaultDuration(3); 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); // 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.enableCaching(false); + // add to root layout root.add(cat_shadow); root.add(cat_frame); root.add(cat); @@ -64,13 +65,14 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List // Meow TextPainter tp = new TextPainter(Res.getFont("press_start")); - tp.setAlign(Align.CENTER); + tp.setAlign(AlignX.CENTER); tp.setColor(RGB.YELLOW); tp.setText("Meow!"); 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); root.add(tp); + /* * Register keys */ @@ -90,7 +92,7 @@ public class LayerFlyingCat extends ScreenLayer implements MouseButtonEvent.List { 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(); diff --git a/src/mightypork/utils/math/constraints/rect/Rect.java b/src/mightypork/utils/math/constraints/rect/Rect.java index f4ca2ed..e5ec8f5 100644 --- a/src/mightypork/utils/math/constraints/rect/Rect.java +++ b/src/mightypork/utils/math/constraints/rect/Rect.java @@ -6,6 +6,7 @@ import mightypork.utils.math.constraints.DigestCache; import mightypork.utils.math.constraints.Digestable; import mightypork.utils.math.constraints.num.Num; 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.caching.RectCache; import mightypork.utils.math.constraints.rect.caching.RectDigest; @@ -61,6 +62,13 @@ public abstract class Rect implements RectBound, Digestable { } + @FactoryMethod + public static Rect make(Vect origin, Num width, Num height) + { + return make(origin, Vect.make(width, height)); + } + + @FactoryMethod public static Rect make(final Vect origin, final Vect size) { @@ -76,7 +84,22 @@ public abstract class Rect implements RectBound, Digestable { 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 public static RectConst make(NumConst x, NumConst y, NumConst width, NumConst height) @@ -289,6 +312,30 @@ public abstract class Rect implements RectBound, Digestable { } + 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 *