(Rect f1, Rect f2, float depth1, float depth2, boolean selected)
| 338 | } |
| 339 | |
| 340 | static protected Pair<FLine, Vec3> arc(Rect f1, Rect f2, float depth1, float depth2, boolean selected) { |
| 341 | |
| 342 | // if (false) |
| 343 | // { |
| 344 | // FLine f = new FLine(); |
| 345 | // f.moveTo(f1.x+f1.w/2, f1.y+f1.h/2); |
| 346 | // f.lineTo(f2.x+f2.w/2, f2.y+f2.h/2); |
| 347 | // |
| 348 | // f.attributes.put(fillColor, selected ? new Vec4(1, 1, 1, 0.5) : new Vec4(0.0, 0.0, 0.0, 0.05f)); |
| 349 | // f.attributes.put(strokeColor, selected ? new Vec4(1, 1, 1, 0.5) : new Vec4(0.0, 0.0, 0.0, 0.05f)); |
| 350 | // f.attributes.put(color, selected ? new Vec4(1, 1, 0, 0.5) : new Vec4(0.0, 0.0, 0.0, 0.05f)); |
| 351 | // |
| 352 | // if (!selected) |
| 353 | // f.attributes.put(thicken, new BasicStroke(selected ? 13.25f : 5.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); |
| 354 | // if (selected) f.attributes.put(filled, true); |
| 355 | // |
| 356 | // return new Pair<>(f, new Vec2(f1.x+f1.w/2+f2.x+f2.w/2, f1.y+f1.h/2+f2.y+f2.h/2).mul(0.5)); |
| 357 | // } |
| 358 | |
| 359 | float inset = 0; |
| 360 | Vec2[] a = new Vec2[]{new Vec2(f1.x + inset, f1.y + inset), new Vec2(f1.x + f1.w - inset, f1.y + f1.h - inset), new Vec2(f1.x + f1.w - inset, f1.y + inset), new Vec2(f1.x + inset, |
| 361 | f1.y + f1.h - inset)}; |
| 362 | inset = 15; |
| 363 | // Vec2[] b = new Vec2[]{new Vec2(f2.x + f2.w - inset, f2.y + inset), new Vec2(f2.x + f2.w - inset, f2.y + f2.h - inset), new Vec2(f2.x + inset, f2.y + f2.h - inset), new Vec2(f2.x + |
| 364 | // inset, f2.y + inset)}; |
| 365 | Vec2[] b = new Vec2[]{new Vec2(f2.x + f2.w / 2, f2.y + f2.h / 2 - inset), new Vec2(f2.x + f2.w / 2, f2.y + f2.h / 2 + inset)};//, new Vec2(f2.x + inset, f2.y + f2.h - inset), new |
| 366 | // Vec2(f2.x + inset, f2.y + inset)}; |
| 367 | |
| 368 | float d = Float.POSITIVE_INFINITY; |
| 369 | int[] da = {0, 0}; |
| 370 | for (int x = 0; x < a.length; x++) |
| 371 | for (int y = 0; y < b.length; y++) { |
| 372 | float z = (float) a[x].distance(b[y]); |
| 373 | if (z < d) { |
| 374 | d = z; |
| 375 | da[0] = x; |
| 376 | da[1] = y; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | FLine f = new FLine(); |
| 381 | |
| 382 | Vec2 normal = Vec2.sub(b[da[1]], a[da[0]], new Vec2()); |
| 383 | |
| 384 | Vec2 tan = new Vec2(-normal.y, normal.x).normalize() |
| 385 | .mul(-d * 0.15f); |
| 386 | |
| 387 | // if (normal.x > 0) tan.mul(-1); |
| 388 | |
| 389 | Vec2 midPoint1 = new Vec2(a[da[0]].x + b[da[1]].x, a[da[0]].y + b[da[1]].y).mul(1 / 2f) |
| 390 | .add(tan.x, tan.y); |
| 391 | Vec2 midPoint2 = new Vec2(a[da[0]].x + b[da[1]].x, a[da[0]].y + b[da[1]].y).mul(1 / 2f) |
| 392 | .add(-tan.x, -tan.y); |
| 393 | |
| 394 | float d1 = 0; |
| 395 | float d2 = 0; |
| 396 | for (Vec2 vv : a) d1 += vv.distance(midPoint1); |
| 397 | for (Vec2 vv : a) d2 += vv.distance(midPoint2); |
no test coverage detected