This commit is contained in:
2022-10-26 11:13:11 +02:00
parent 768f122da4
commit ca5a8516fd
15 changed files with 409 additions and 4 deletions

View File

@@ -6,7 +6,6 @@ public class LumListener implements MouseListener {
public void mouseClicked(MouseEvent e) {
LumPanel p = (LumPanel)e.getSource();
p.removeParralel(e.getX(), e.getY());
}
@Override

View File

@@ -1,17 +1,20 @@
import javax.swing.JPanel;
import java.awt.*;
import java.util.LinkedList;
import java.util.Random;
public class LumPanel extends JPanel {
private ListChain<Color> l;
private LinkedList<Color> l;
int width = 30;
int offset = 30;
int height = 60;
int spacing = 5;
int mx, my = 0;
public LumPanel() {
l = new ListChain<Color>();
l = new LinkedList<Color>();
Random r = new Random();
for (int i = 0; i < 10; i++) {
@@ -41,6 +44,18 @@ public class LumPanel extends JPanel {
}
}
public void setMCoords(int x, int y) {
double dx = (double)x;
double dy = (double)y;
dx -= lerp(offset, 0, dy / (double)height);
dx -= spacing * Math.floor(dx / width);
this.mx = (int)dx;
this.my = (int)dy;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
Graphics gg = g.create();
@@ -61,6 +76,9 @@ public class LumPanel extends JPanel {
p.addPoint(x + width, getY() + height);
p.addPoint(x, getY() + height);
gg.setColor(Color.BLACK);
gg.fillOval(mx-3, my-3, 6, 6);
gg.setColor(c);
gg.fillPolygon(p);
gg.setColor(Color.BLACK);

View File

@@ -1,5 +1,5 @@
import javax.swing.JFrame;
import java.awt.*;
/**
* Luminance
*/
@@ -21,5 +21,10 @@ public class Luminance {
f.setVisible(true);
lm.addMouseListener(new LumListener());
while (true) {
Point p = MouseInfo.getPointerInfo().getLocation();
lm.setMCoords(p.x - lm.getLocationOnScreen().x, p.y - lm.getLocationOnScreen().y);
}
}
}