This branch works now lol

This commit is contained in:
bronze 2017-07-26 02:02:52 -04:00
parent e8d3196e42
commit f0313d1cd9
2 changed files with 12 additions and 14 deletions

View file

@ -2,6 +2,7 @@ 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;
@ -11,10 +12,10 @@ public class Context {
static Random rng = new Random();
static Graphics g;
static BufferedImage bufferedImage = new BufferedImage(1280, 720, BufferedImage.TYPE_INT_ARGB);
static BufferedImage bufferedImage = new BufferedImage(Window.paintArea.getWidth(), Window.paintArea.getHeight(), BufferedImage.TYPE_INT_ARGB);
static RenderedImage renderedImage;
static Graphics g = bufferedImage.createGraphics();
public static void drawBorders(Graphics g)
{
@ -25,7 +26,7 @@ public class Context {
public static void draw(int x, int y)
{
g = bufferedImage.createGraphics();
//g = bufferedImage.createGraphics();
int size = Window.sizeSlider.getValue();
Color c = new Color(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256), Window.opacitySlider.getValue());
@ -34,8 +35,6 @@ public class Context {
g.fillOval(x - size / 2, y - size / 2, size, size);
g.dispose();
renderedImage = bufferedImage;
Log.print("[PAINTER] Drawn at " + "X: " + x + " Y: " + y);
@ -43,9 +42,9 @@ public class Context {
Log.print("[PAINTER] Opacity " + Window.opacitySlider.getValue());
}
public static void swapBuffers()
public static void swapBuffers(Graphics g)
{
//Window.paintArea.repaint();
Window.paintArea.print(bufferedImage.getGraphics());
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(bufferedImage, null, 0, 0);
}
}

View file

@ -1,11 +1,11 @@
package bz.bronze.painter;
public class Tick implements Runnable {
public Thread refresh = new Thread(this);
public Thread tick = new Thread(this);
public Tick()
{
refresh.start();
tick.start();
}
public void run() {
@ -25,10 +25,9 @@ public class Tick implements Runnable {
{
Log.print("[ERROR] Mouse out of bounds!");
}
Context.swapBuffers();
//Window.paintArea.repaint();
}
Context.swapBuffers(Window.paintArea.getGraphics());
}
}
}