Initial Commit
This commit is contained in:
commit
45aad42c39
14 changed files with 256 additions and 0 deletions
BIN
Painter/.DS_Store
vendored
Normal file
BIN
Painter/.DS_Store
vendored
Normal file
Binary file not shown.
6
Painter/.classpath
Normal file
6
Painter/.classpath
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
Painter/.gitignore
vendored
Normal file
1
Painter/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
17
Painter/.project
Normal file
17
Painter/.project
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Painter</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
11
Painter/.settings/org.eclipse.jdt.core.prefs
Normal file
11
Painter/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
BIN
Painter/src/.DS_Store
vendored
Normal file
BIN
Painter/src/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Painter/src/bz/.DS_Store
vendored
Normal file
BIN
Painter/src/bz/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Painter/src/bz/bronze/.DS_Store
vendored
Normal file
BIN
Painter/src/bz/bronze/.DS_Store
vendored
Normal file
Binary file not shown.
37
Painter/src/bz/bronze/painter/Context.java
Normal file
37
Painter/src/bz/bronze/painter/Context.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Context {
|
||||||
|
static int rectSize = 100;
|
||||||
|
|
||||||
|
static Random rng = new Random();
|
||||||
|
|
||||||
|
public static void drawBorders(Graphics g)
|
||||||
|
{
|
||||||
|
g.drawLine(0, 0, 0, Window.height + 10);
|
||||||
|
|
||||||
|
Log.print("hit");
|
||||||
|
|
||||||
|
//g.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void draw(Graphics g, int x, int y)
|
||||||
|
{
|
||||||
|
int size = Window.sizeSlider.getValue();
|
||||||
|
Color c = new Color(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256), Window.opacitySlider.getValue());
|
||||||
|
|
||||||
|
g.setColor(c);
|
||||||
|
|
||||||
|
g.fillOval(x - size / 2, y - size / 2, size, size);
|
||||||
|
|
||||||
|
g.dispose();
|
||||||
|
|
||||||
|
Log.print("[PAINTER] Drawn at, " + "X: " + x + " Y: " + y);
|
||||||
|
Log.print("[PAINTER] Color, " + "R: " + c.getRed() + " G: " + c.getGreen() + " B: " + c.getBlue());
|
||||||
|
Log.print("[PAINTER] Opacity, " + Window.opacitySlider.getValue());
|
||||||
|
}
|
||||||
|
}
|
8
Painter/src/bz/bronze/painter/Log.java
Normal file
8
Painter/src/bz/bronze/painter/Log.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
public class Log {
|
||||||
|
public static void print(String info)
|
||||||
|
{
|
||||||
|
System.out.println(info);
|
||||||
|
}
|
||||||
|
}
|
62
Painter/src/bz/bronze/painter/Mouse.java
Normal file
62
Painter/src/bz/bronze/painter/Mouse.java
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
import java.awt.MouseInfo;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
|
public class Mouse {
|
||||||
|
static boolean isDown;
|
||||||
|
|
||||||
|
public static void listen()
|
||||||
|
{
|
||||||
|
Window.paintArea.addMouseListener(new MouseListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
isDown = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
isDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Window.clearButton.addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Window.paintArea.repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMouseX()
|
||||||
|
{
|
||||||
|
int mouseX;
|
||||||
|
|
||||||
|
return mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
||||||
|
}
|
||||||
|
public static int getMouseY()
|
||||||
|
{
|
||||||
|
int mouseY;
|
||||||
|
|
||||||
|
return mouseY = MouseInfo.getPointerInfo().getLocation().y;
|
||||||
|
}
|
||||||
|
}
|
23
Painter/src/bz/bronze/painter/Painter.java
Normal file
23
Painter/src/bz/bronze/painter/Painter.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
public class Painter {
|
||||||
|
private static String title = "Painter";
|
||||||
|
public static boolean isRunning;
|
||||||
|
|
||||||
|
|
||||||
|
public static void init()
|
||||||
|
{
|
||||||
|
Window w = new Window(title);
|
||||||
|
//Context.drawBorders(Window.paintArea.getGraphics());
|
||||||
|
Tick refresh = new Tick();
|
||||||
|
|
||||||
|
Log.print("[INIT] Done!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
isRunning = true;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
}
|
24
Painter/src/bz/bronze/painter/Tick.java
Normal file
24
Painter/src/bz/bronze/painter/Tick.java
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
public class Tick implements Runnable {
|
||||||
|
public Thread refresh = new Thread(this);
|
||||||
|
|
||||||
|
public Tick()
|
||||||
|
{
|
||||||
|
refresh.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
while(Painter.isRunning)
|
||||||
|
{
|
||||||
|
Window.opacitySliderLabel.setText("Opacity: " + Window.opacitySlider.getValue());
|
||||||
|
Window.sizeSliderLabel.setText("Size: " + Window.sizeSlider.getValue());
|
||||||
|
|
||||||
|
if(Mouse.isDown)
|
||||||
|
{
|
||||||
|
Context.draw(Window.paintArea.getGraphics(), Window.paintArea.getMousePosition().x, Window.paintArea.getMousePosition().y);
|
||||||
|
//Window.paintArea.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
Painter/src/bz/bronze/painter/Window.java
Normal file
67
Painter/src/bz/bronze/painter/Window.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package bz.bronze.painter;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JSlider;
|
||||||
|
|
||||||
|
public class Window {
|
||||||
|
public static int width = 1280;
|
||||||
|
public static int height = 720;
|
||||||
|
|
||||||
|
public static JPanel paintArea = new JPanel();
|
||||||
|
public static JPanel toolbox = new JPanel();
|
||||||
|
|
||||||
|
public static JLabel opacitySliderLabel = new JLabel();
|
||||||
|
public static JLabel sizeSliderLabel = new JLabel();
|
||||||
|
public static JLabel fpsLabel = new JLabel();
|
||||||
|
|
||||||
|
public static JSlider opacitySlider = new JSlider();
|
||||||
|
public static JSlider sizeSlider = new JSlider();
|
||||||
|
|
||||||
|
public static JButton clearButton = new JButton();
|
||||||
|
|
||||||
|
public Window(String windowName)
|
||||||
|
{
|
||||||
|
JFrame window = new JFrame(windowName);
|
||||||
|
|
||||||
|
opacitySlider.setMaximum(255);
|
||||||
|
opacitySlider.setValue(255);
|
||||||
|
opacitySlider.setPreferredSize(new Dimension(100, 50));
|
||||||
|
|
||||||
|
sizeSlider.setValue(100);
|
||||||
|
sizeSlider.setPreferredSize(new Dimension(100, 50));
|
||||||
|
|
||||||
|
clearButton.setText("Clear");
|
||||||
|
clearButton.setPreferredSize(new Dimension(100, 50));
|
||||||
|
|
||||||
|
window.setLayout(new BorderLayout());
|
||||||
|
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
window.setSize(width, height);
|
||||||
|
window.setLocationRelativeTo(null);
|
||||||
|
|
||||||
|
toolbox.add(opacitySliderLabel);
|
||||||
|
toolbox.add(opacitySlider);
|
||||||
|
toolbox.add(sizeSliderLabel);
|
||||||
|
toolbox.add(sizeSlider);
|
||||||
|
toolbox.add(clearButton);
|
||||||
|
toolbox.add(fpsLabel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
window.add(paintArea);
|
||||||
|
window.add(toolbox, BorderLayout.WEST);
|
||||||
|
|
||||||
|
paintArea.setVisible(true);
|
||||||
|
toolbox.setPreferredSize(new Dimension(200, height));
|
||||||
|
toolbox.setVisible(true);
|
||||||
|
window.setResizable(false);
|
||||||
|
window.setVisible(true);
|
||||||
|
|
||||||
|
Mouse.listen();
|
||||||
|
|
||||||
|
Log.print("[WINDOW] Created!");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue