MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / arc

Method arc

src/main/java/fieldcef/plugins/PadsBox.java:138–159  ·  view source on GitHub ↗
(Rect from, Rect to)

Source from the content-addressed store, hash-verified

136
137
138 static public FLine arc(Rect from, Rect to) {
139
140 FLine f = new FLine();
141
142 Vec2 a = new Vec2(from.x + from.w / 2, from.y + from.h / 2);
143 Vec2 b = new Vec2(to.x + to.w / 2, to.y + to.h / 2);
144
145 float d = (float) b.distance(a);
146
147 Vec2 normal = Vec2.sub(b, a, new Vec2());
148
149 Vec2 tan = new Vec2(-normal.y, normal.x).normalize().mul(d * 0.15f);
150 if (normal.x > 0) tan.mul(-1);
151
152 Vec2 c1 = new Vec2(a.x + normal.x * 1 / 3f + tan.x, a.y + normal.y * 1 / 3f + tan.y);
153 Vec2 c2 = new Vec2(a.x + normal.x * 2 / 3f + tan.x, a.y + normal.y * 2 / 3f + tan.y);
154
155 f.moveTo(a.x, a.y);
156 f.cubicTo(c1.x, c1.y, c2.x, c2.y, b.x, b.y);
157
158 return f;
159 }
160
161 public Vec2 middleOf(FLine f) {
162 FLine.MoveTo m = (FLine.MoveTo) f.nodes.get(0);

Callers 3

defaultdrawsLinesMethod · 0.95
updateFrameToMiddleMethod · 0.95
tFunction · 0.45

Calls 6

distanceMethod · 0.95
subMethod · 0.95
mulMethod · 0.95
moveToMethod · 0.95
cubicToMethod · 0.95
normalizeMethod · 0.45

Tested by

no test coverage detected