Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
baaeb429cb | ||
![]() |
3133ae8457 | ||
![]() |
8ba36e12d4 | ||
![]() |
9d8a28fb25 | ||
![]() |
d53c104c4c | ||
![]() |
f0313d1cd9 | ||
![]() |
e8d3196e42 |
12 changed files with 108 additions and 275 deletions
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Painter/Painter.iml" filepath="$PROJECT_DIR$/Painter/Painter.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
182
.idea/workspace.xml
generated
182
.idea/workspace.xml
generated
|
@ -1,182 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fd1a9908-c0fb-4a3f-837b-f4d438ae24b4" name="Default Changelist" comment="" />
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<ignored path="$PROJECT_DIR$/Painter/bin/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="DefaultGradleProjectSettings">
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="delegatedBuild" value="true" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/Painter/src/bz/bronze/painter/Painter.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectConfigurationFiles">
|
||||
<option name="files">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/.idea/vcs.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="260" />
|
||||
<option name="y" value="53" />
|
||||
<option name="width" value="1400" />
|
||||
<option name="height" value="1000" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="painter" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="Painter" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="painter" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="Painter" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="painter" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="Painter" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="painter" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Painter" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="bz.bronze.painter.Painter" />
|
||||
<module name="Painter" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="bz.bronze.painter.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.Painter" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="fd1a9908-c0fb-4a3f-837b-f4d438ae24b4" name="Default Changelist" comment="" />
|
||||
<created>1558577828706</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1558577828706</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
|
||||
<layout>
|
||||
<window_info id="Image Layers" />
|
||||
<window_info id="Designer" />
|
||||
<window_info id="UI Designer" />
|
||||
<window_info id="Capture Tool" />
|
||||
<window_info id="Favorites" side_tool="true" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2497332" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Version Control" />
|
||||
<window_info anchor="bottom" id="Terminal" />
|
||||
<window_info anchor="bottom" id="Event Log" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Messages" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.32901832" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="right" id="Palette" />
|
||||
<window_info anchor="right" id="Theme Preview" />
|
||||
<window_info anchor="right" id="Maven" />
|
||||
<window_info anchor="right" id="Capture Analysis" />
|
||||
<window_info anchor="right" id="Palette	" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/Painter/src/bz/bronze/painter/Painter.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>11</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/bin" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -2,7 +2,9 @@ package bz.bronze.painter;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.util.Random;
|
||||
|
||||
public class Context {
|
||||
|
@ -10,28 +12,38 @@ public class Context {
|
|||
|
||||
static Random rng = new Random();
|
||||
|
||||
static BufferedImage bufferedImage = new BufferedImage(Window.paintArea.getWidth(), Window.paintArea.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
static RenderedImage renderedImage;
|
||||
|
||||
static Graphics g = Window.paintArea.getGraphics();
|
||||
|
||||
public static void drawBorders(Graphics g)
|
||||
{
|
||||
g.drawLine(0, 0, 0, Window.height + 10);
|
||||
{
|
||||
g.fillRect(0, 0, 3, Window.height + 10);
|
||||
|
||||
Log.print("hit");
|
||||
|
||||
//g.dispose();
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
public static void draw(Graphics g, int x, int y)
|
||||
public static void draw(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());
|
||||
renderedImage = bufferedImage;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public static void swapBuffers(Graphics g)
|
||||
{
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.drawImage(bufferedImage, null, 0, 0);
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
public class Mouse {
|
||||
static boolean isDown;
|
||||
public class Input {
|
||||
static boolean mouseIsDown;
|
||||
|
||||
public static void listen()
|
||||
{
|
||||
|
@ -19,13 +19,12 @@ public class Mouse {
|
|||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
isDown = true;
|
||||
|
||||
mouseIsDown = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
isDown = false;
|
||||
mouseIsDown = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,12 +38,22 @@ public class Mouse {
|
|||
});
|
||||
|
||||
Window.clearButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Window.paintArea.repaint();
|
||||
}
|
||||
});
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Window.paintArea.repaint();
|
||||
Context.bufferedImage.flush();
|
||||
|
||||
Log.print("[PAINTER] Cleared!");
|
||||
}
|
||||
});
|
||||
Window.saveButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Save.saveImage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getMouseX()
|
|
@ -3,12 +3,11 @@ 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());
|
||||
Context.drawBorders(Window.paintArea.getGraphics());
|
||||
Tick refresh = new Tick();
|
||||
|
||||
Log.print("[INIT] Done!");
|
||||
|
|
20
Painter/src/bz/bronze/painter/Save.java
Normal file
20
Painter/src/bz/bronze/painter/Save.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package bz.bronze.painter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class Save {
|
||||
public static void saveImage()
|
||||
{
|
||||
Window.filePicker.showSaveDialog(Window.paintArea);
|
||||
|
||||
try
|
||||
{
|
||||
ImageIO.write(Window.paintArea.getGraphics(), "png", Window.filePicker.getSelectedFile());
|
||||
Log.print("[INFO] Image Saved!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,46 @@
|
|||
package bz.bronze.painter;
|
||||
|
||||
public class Tick implements Runnable {
|
||||
public Thread refresh = new Thread(this);
|
||||
public Thread tick = new Thread(this);
|
||||
long taskTime = 0;
|
||||
long sleepTime = 1000/60;
|
||||
|
||||
public Tick()
|
||||
{
|
||||
refresh.start();
|
||||
tick.start();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while(Painter.isRunning)
|
||||
{
|
||||
taskTime = System.currentTimeMillis();
|
||||
|
||||
Window.opacitySliderLabel.setText("Opacity: " + Window.opacitySlider.getValue());
|
||||
Window.sizeSliderLabel.setText("Size: " + Window.sizeSlider.getValue());
|
||||
|
||||
if(Mouse.isDown)
|
||||
Context.drawBorders(Window.paintArea.getGraphics());
|
||||
|
||||
if(Input.mouseIsDown)
|
||||
{
|
||||
Context.draw(Window.paintArea.getGraphics(), Window.paintArea.getMousePosition().x, Window.paintArea.getMousePosition().y);
|
||||
//Window.paintArea.repaint();
|
||||
try
|
||||
{
|
||||
Context.draw(Window.paintArea.getMousePosition().x, Window.paintArea.getMousePosition().y);
|
||||
} catch (Exception e)
|
||||
{
|
||||
Log.print("[ERROR] Mouse out of bounds!");
|
||||
}
|
||||
}
|
||||
|
||||
Context.swapBuffers(Window.paintArea.getGraphics());
|
||||
|
||||
taskTime = System.currentTimeMillis()-taskTime;
|
||||
if (sleepTime-taskTime > 0 ) {
|
||||
try {
|
||||
Thread.sleep(sleepTime-taskTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,10 +4,12 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
public class Window {
|
||||
public static int width = 1280;
|
||||
|
@ -24,6 +26,10 @@ public class Window {
|
|||
public static JSlider sizeSlider = new JSlider();
|
||||
|
||||
public static JButton clearButton = new JButton();
|
||||
public static JButton saveButton = new JButton();
|
||||
|
||||
public static JFileChooser filePicker = new JFileChooser();
|
||||
public static FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "png");
|
||||
|
||||
public Window(String windowName)
|
||||
{
|
||||
|
@ -36,9 +42,16 @@ public class Window {
|
|||
sizeSlider.setValue(100);
|
||||
sizeSlider.setPreferredSize(new Dimension(100, 50));
|
||||
|
||||
clearButton.setEnabled(false);
|
||||
clearButton.setToolTipText("Clearing machine broke!");
|
||||
clearButton.setText("Clear");
|
||||
clearButton.setPreferredSize(new Dimension(100, 50));
|
||||
|
||||
saveButton.setText("Save");
|
||||
saveButton.setPreferredSize(new Dimension(100, 50));
|
||||
|
||||
//filePicker.setFileFilter(filter);
|
||||
|
||||
window.setLayout(new BorderLayout());
|
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
window.setSize(width, height);
|
||||
|
@ -49,7 +62,8 @@ public class Window {
|
|||
toolbox.add(sizeSliderLabel);
|
||||
toolbox.add(sizeSlider);
|
||||
toolbox.add(clearButton);
|
||||
toolbox.add(fpsLabel, BorderLayout.SOUTH);
|
||||
toolbox.add(saveButton);
|
||||
//toolbox.add(fpsLabel, BorderLayout.SOUTH);
|
||||
|
||||
window.add(paintArea);
|
||||
window.add(toolbox, BorderLayout.WEST);
|
||||
|
@ -60,7 +74,7 @@ public class Window {
|
|||
window.setResizable(false);
|
||||
window.setVisible(true);
|
||||
|
||||
Mouse.listen();
|
||||
Input.listen();
|
||||
|
||||
Log.print("[WINDOW] Created!");
|
||||
}
|
||||
|
|
29
README.md
29
README.md
|
@ -1,29 +0,0 @@
|
|||
# README #
|
||||
|
||||
This README would normally document whatever steps are necessary to get your application up and running.
|
||||
|
||||
### What is this repository for? ###
|
||||
|
||||
* Quick summary
|
||||
* Version
|
||||
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
||||
|
||||
### How do I get set up? ###
|
||||
|
||||
* Summary of set up
|
||||
* Configuration
|
||||
* Dependencies
|
||||
* Database configuration
|
||||
* How to run tests
|
||||
* Deployment instructions
|
||||
|
||||
### Contribution guidelines ###
|
||||
|
||||
* Writing tests
|
||||
* Code review
|
||||
* Other guidelines
|
||||
|
||||
### Who do I talk to? ###
|
||||
|
||||
* Repo owner or admin
|
||||
* Other community or team contact
|
Loading…
Add table
Add a link
Reference in a new issue