# HG changeset patch # User postspectacular # Date 1326687964 0 # Node ID 7cba972224d41034ef0a648a0985298b748fda8a # Parent 4239f3c325bf054e59ae3b72b5cfb4a33fe8e78a adding Polygon2D.scaleSize() methods diff -r 4239f3c325bf054e59ae3b72b5cfb4a33fe8e78a -r 7cba972224d41034ef0a648a0985298b748fda8a src.core/toxi/geom/Polygon2D.java --- a/src.core/toxi/geom/Polygon2D.java Mon Jan 16 04:25:43 2012 +0000 +++ b/src.core/toxi/geom/Polygon2D.java Mon Jan 16 04:26:04 2012 +0000 @@ -654,6 +654,22 @@ return scale(scale.x(), scale.y()); } + public Polygon2D scaleSize(float scale) { + return scaleSize(scale, scale); + } + + public Polygon2D scaleSize(float x, float y) { + Vec2D centroid = getCentroid(); + for (Vec2D v : vertices) { + v.subSelf(centroid).scaleSelf(x, y).addSelf(centroid); + } + return this; + } + + public Polygon2D scaleSize(ReadonlyVec2D scale) { + return scaleSize(scale.x(), scale.y()); + } + /** * Applies a laplacian-style smooth operation to all polygon vertices, * causing sharp corners/angles to widen and results in a general smoother