Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void drawRotatedRect(Graphics2D g, Vector pos, Vector up, int a, int height) {
- Vector upRot = up.rotated(Math.PI / 2);
- Vector p1 = pos.added(up.scaled(a/2)).added(upRot.scaled(a/2));
- Vector p2 = pos.added(up.scaled(a/2)).added(upRot.scaled(-a/2));
- Vector p3 = pos.added(up.scaled(-a/2).added(upRot.scaled(a/2)));
- Vector p4 = pos.added(up.scaled(-a/2).added(upRot.scaled(-a/2)));
- g.setColor(new Color(255 - a + 1, 0, a - 1));
- g.fillPolygon(new int[]{(int)p1.x, (int)p2.x, (int)p4.x, (int)p3.x}, new int[]{height - (int)p1.y, height - (int)p2.y, height - (int)p4.y, height - (int)p3.y}, 4);
- }
- public static void drawSegment(Graphics2D g, Vector pos, Vector up, int a, int height) {
- drawRotatedRect(g, pos, up, a, height);
- if (a < 3) {
- return;
- } else {
- Vector up1 = up.rotated(Math.PI / 4);
- Vector up2 = up.rotated(- Math.PI / 4);
- Vector pos1 = pos.added(up1.scaled(a / 2));
- Vector pos2 = pos.added(up2.scaled(a / 2));
- a = (int) ((double) a / Math.sqrt(2));
- drawSegment(g, pos1, up1, a, height);
- drawSegment(g, pos2, up2, a, height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement