import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import java.util.function.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;
import java.awt.geom.Path2D;
import static x30_pkg.x30_util.DynamicObject;
import java.awt.geom.*;
import java.text.*;
import java.text.NumberFormat;
import java.util.TimeZone;
class main {
static JComponent gazelle_wavySpacer() {
return gazelle_wavySpacer(gazelle_color1(), gazelle_color2());
}
static JComponent gazelle_wavySpacer(Color color1, Color color2) {
return jMinWidth(30, swing(() -> new JComponent() {
public void paintComponent(Graphics g) {
int w = getWidth(), h = getHeight();
var points = graphAsPolygon(x -> 1-sineSigmoid(x), w, h);
//printVars(+w, +h, points := takeFirst(5, points));
fillRect(((Graphics2D) g), 0, 0, w, h, color2);
fillPrecisePolygon(((Graphics2D) g), points, color1);
}
}));
}
static Color gazelle_color1() {
return awtColor("ADD8E6");
}
static Color gazelle_color2() {
return awtColor("EEEEEE");
}
static A jMinWidth(final int w, final A c) {
if (c == null) return null;
return swing(new F0() { public A get() { try {
Dimension size = c.getMinimumSize();
c.setMinimumSize(new Dimension(/*max(w, size.width) ??? */w, size.height));
return jPreferWidth(w, c);
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "Dimension size = c.getMinimumSize();\r\n c.setMinimumSize(new Dimension(/*ma..."; }});
}
static Object swing(Object f) {
return swingAndWait(f);
}
static void swing(Runnable f) {
swingAndWait(f);
}
static A swing(F0 f) {
return (A) swingAndWait(f);
}
static A swing(IF0 f) {
return (A) swingAndWait(f);
}
static int getWidth(Component c) {
return c == null ? 0 : (int) swingCall(c, "getWidth");
}
static int getHeight(Component c) {
return c == null ? 0 : (int) swingCall(c, "getHeight");
}
static List graphAsPolygon(IF1 formula, int w, int h) {
List points = new ArrayList();
points.add(new DoublePt(0, 0));
for (int x = 0; x < w; x++) {
double y = formula.get(doubleRatio(x, w))*h;
points.add(new DoublePt(x, y));
}
points.add(new DoublePt(w-1, 0));
return points;
}
static double sineSigmoid(double x) {
return 0.5 * (1 + sin(pi()*(x-.5)));
}
static void fillRect(BufferedImage image, int x, int y, int w, int h, Color color) {
Graphics2D g = imageGraphics(image);
fillRect(g, x, y, w, h, color);
g.dispose();
}
static void fillRect(Graphics g, Color color, int x, int y, int w, int h) {
fillRect(g, x, y, w, h, color);
}
static void fillRect(Graphics/*2D*/ g, int x, int y, int w, int h, Color color) {
g.setColor(color);
g.fillRect(x, y, w, h);
}
// draw on currentImage()
static void fillRect(int x, int y, int w, int h, Color color) {
fillRect(currentImage(), x, y, w, h, color);
}
static void fillRect(Rect r, Color color) {
fillRect(r.x, r.y, r.w, r.h, color);
}
static void fillRect(BufferedImage image, Rect r, Color c) {
if (r != null) fillRect(image, r.x, r.y, r.w, r.h, c);
}
static void fillRect(Graphics/*2D*/ g, Rect r, Color c) {
if (r != null) fillRect(g, r.x, r.y, r.w, r.h, c);
}
static void fillPrecisePolygon(BufferedImage g, List points, Color color) { fillPrecisePolygon(graphics(g), points, color); }
static void fillPrecisePolygon(Graphics2D g, List points, Color color) {
g.setColor(color);
g.fill(new PrecisePolygon(points));
}
static void fillPrecisePolygon(BufferedImage g, List points) { fillPrecisePolygon(graphics(g), points); }
static void fillPrecisePolygon(Graphics2D g, List points) {
g.fill(new PrecisePolygon(points));
}
static java.awt.Color awtColor(String hex) {
byte[] b = bytesFromHex(dropPrefix("#", hex));
return new Color(ubyteToInt(b[0]), ubyteToInt(b[1]), ubyteToInt(b[2]));
}
static A jPreferWidth(int w, A c) {
{ swing(() -> {
Dimension size = c.getPreferredSize();
c.setPreferredSize(new Dimension(/*max(w, size.width) ??? */w, size.height));
}); }
return c;
}
static A jPreferWidth(A c, int w) {
return jPreferWidth(w, c);
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static RuntimeException rethrow(String msg, Throwable t) {
throw new RuntimeException(msg, t);
}
static void swingAndWait(Runnable r) { try {
if (isAWTThread())
r.run();
else {
r = addThreadInfoToRunnable(r);
executingSwingCode(r);
EventQueue.invokeAndWait(r);
}
} catch (Exception __e) { throw rethrow(__e); } }
static Object swingAndWait(Object f) {
if (isAWTThread())
return callF(f);
else {
Var result = new Var();
swingAndWait(new Runnable() { public void run() { try {
result.set(callF(f));
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "result.set(callF(f));"; }});
return result.get();
}
}
static Object swingCall(final Object o, final String method, final Object... args) {
return swing(new F0