| 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); |