package gui;

import java.awt.*;
import java.awt.geom.Line2D;

public class GameCanvas extends Canvas {

    public GameCanvas() {
        setBackground(Color.BLUE);
    }

    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.RED);
        g2.drawRect(12, 12, 325, 4565);
        g2.draw(new Line2D.Double(0, 0, 60, 100));
    }

}
@@ -18,159 +18,659 @@
 ort 
-java.awt.*;%0Aimport java.awt.geom.Line2D;%0A%0Apublic class GameCanvas extends Canvas %7B%0A%0A    public GameCanvas() %7B%0A        setBackground(Color.BLUE);%0A    %7D%0A
+element.Box;%0Aimport math.Vector;%0A%0Aimport java.awt.*;%0Aimport java.awt.image.BufferStrategy;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask;%0A%0Aimport static java.lang.Math.cos;%0Aimport static java.lang.Math.sin;%0A%0Apublic class GameCanvas extends Canvas %7B%0A    public BufferStrategy strategy;%0A    private Box box;%0A%0A    public GameCanvas() %7B%0A        box = new Box(new Vector(200,158),new Vector(70,100));%0A        Timer timer = new Timer();%0A        timer.schedule(new TimerTask() %7B%0A            @Override%0A            public void run() %7B%0A                box.rotation += 0.01;%0A                repaint();%0A            %7D%0A        %7D, 100, 10);%0A    %7D%0A%0A    @Override
 %0A   
@@ -682,21 +682,22 @@
 ic void 
-paint
+update
 (Graphic
@@ -714,121 +714,1168 @@
     
+ 
- Graphics2D g2 = (Graphics2D) g;%0A        g2.setColor(Color.RED);%0A        g2.drawRect(12, 12, 325, 4565
+paint(g);%0A    %7D%0A%0A    public void paint(Graphics g) %7B%0A        if(getBufferStrategy() == null)%7B%0A            createBufferStrategy(2);%0A            strategy = getBufferStrategy();%0A        %7D%0A        g = strategy.getDrawGraphics();%0A        g.setColor(Color.BLUE);%0A        g.fillRect(0,0,getWidth(),getHeight());%0A        g.setColor(Color.RED);%0A        drawBox(g, box);%0A        strategy.show();%0A    %7D%0A%0A    private void drawBox(Graphics g, Box b) %7B%0A        Vector width = b.getWidth();%0A        double x = width.y / 2.0;%0A        double y = width.x / 2.0;%0A        double c = cos(b.rotation);%0A        double s = sin(b.rotation);%0A    /*%0A    v1 - v2%0A%09l     l%0A%09v4 - v3%0A%09*/%0A        Vector v1 = new Vector(-1 * x, -1 * y);%0A        Vector v2 = new Vector(x, -1 * y);%0A        Vector v3 = new Vector(x, y);%0A        Vector v4 = new Vector(-1 * x, y);%0A%0A        Vector tv1 = new Vector(v1.x * c + v1.y * s, -1 * v1.x * s + v1.y * c);%0A        Vector tv2 = new Vector(v2.x * c + v2.y * s, -1 * v2.x * s + v2.y * c);%0A        Vector tv3 = new Vector(v3.x * c + v3.y * s, -1 * v3.x * s + v3.y * c);%0A        Vector tv4 = new Vector(v4.x * c + v4.y * s, -1 * v4.x * s + v4.y * c
 );%0A
+%0A
         
 g2.d
@@ -1874,48 +1874,443 @@
     
-g2.draw(new Line2D.Double(0, 0, 60, 100)
+drawLine(g,Vector.add(tv1, b.position), Vector.add(tv2, b.position));%0A        drawLine(g,Vector.add(tv2, b.position), Vector.add(tv3, b.position));%0A        drawLine(g,Vector.add(tv3, b.position), Vector.add(tv4, b.position));%0A        drawLine(g,Vector.add(tv4, b.position), Vector.add(tv1, b.position));%0A    %7D%0A    private void drawLine(Graphics g,Vector v1, Vector v2)%7B%0A        g.drawLine((int) v1.x, (int) v1.y, (int) v2.x, (int) v2.y
 );%0A 

apply double buffering and test