@Test public void testAxisClamp () { Axis axis = checkCoords(Scale9.clamp(new Axis(1), 1)); assertEquals(1f/3, axis.size(0), DELTA); assertEquals(1-2f/3, axis.size(1), DELTA); assertEquals(1f/3, axis.size(2), DELTA); axis = checkCoords(Scale9.clamp(new Axis(2).resize(1, 1.5f), 1)); assertEquals(.25f, axis.size(0), DELTA); assertEquals(.5f, axis.size(1), DELTA); assertEquals(.25f, axis.size(2), DELTA); axis = checkCoords(Scale9.clamp(new Axis(1), .5f)); assertEquals(.25f, axis.size(0), DELTA); assertEquals(0, axis.size(1), DELTA); assertEquals(.25f, axis.size(2), DELTA); }
public static Axis clamp (Axis axis, float length) { float left = axis.size(0); float middle = axis.size(1); float right = axis.size(2); if (left + middle + right > length && middle > 0 && left + right < length) { axis.set(1, left, length - left - right); axis.set(2, length - right, right); } else if (left + right > length) { float remove = (left + right - length) / 2; axis.set(0, 0, left - remove); axis.set(1, left - remove, 0); axis.set(2, left - remove, right - remove); } return axis; }
Scale9 { public static Axis clamp (Axis axis, float length) { float left = axis.size(0); float middle = axis.size(1); float right = axis.size(2); if (left + middle + right > length && middle > 0 && left + right < length) { axis.set(1, left, length - left - right); axis.set(2, length - right, right); } else if (left + right > length) { float remove = (left + right - length) / 2; axis.set(0, 0, left - remove); axis.set(1, left - remove, 0); axis.set(2, left - remove, right - remove); } return axis; } }
Scale9 { public static Axis clamp (Axis axis, float length) { float left = axis.size(0); float middle = axis.size(1); float right = axis.size(2); if (left + middle + right > length && middle > 0 && left + right < length) { axis.set(1, left, length - left - right); axis.set(2, length - right, right); } else if (left + right > length) { float remove = (left + right - length) / 2; axis.set(0, 0, left - remove); axis.set(1, left - remove, 0); axis.set(2, left - remove, right - remove); } return axis; } Scale9(float width, float height);  Scale9(float width, float height, Scale9 source); }
Scale9 { public static Axis clamp (Axis axis, float length) { float left = axis.size(0); float middle = axis.size(1); float right = axis.size(2); if (left + middle + right > length && middle > 0 && left + right < length) { axis.set(1, left, length - left - right); axis.set(2, length - right, right); } else if (left + right > length) { float remove = (left + right - length) / 2; axis.set(0, 0, left - remove); axis.set(1, left - remove, 0); axis.set(2, left - remove, right - remove); } return axis; } Scale9(float width, float height);  Scale9(float width, float height, Scale9 source); static Axis clamp(Axis axis, float length); }
Scale9 { public static Axis clamp (Axis axis, float length) { float left = axis.size(0); float middle = axis.size(1); float right = axis.size(2); if (left + middle + right > length && middle > 0 && left + right < length) { axis.set(1, left, length - left - right); axis.set(2, length - right, right); } else if (left + right > length) { float remove = (left + right - length) / 2; axis.set(0, 0, left - remove); axis.set(1, left - remove, 0); axis.set(2, left - remove, right - remove); } return axis; } Scale9(float width, float height);  Scale9(float width, float height, Scale9 source); static Axis clamp(Axis axis, float length); final Axis xaxis; }