public void drawVertArrow(Graphics g, int x1, int y1, int x2, int y2) { g.drawLine(x1, y1, x2, y2); int[] axPoints = new int[3]; int[] ayPoints = new int[3]; axPoints[0] = x2; ayPoints[0] = y2; axPoints[1] = x2 - 1; ayPoints[1] = y2 - 2; axPoints[2] = x2 + 2; ayPoints[2] = y2 - 2; g.fillPolygon(axPoints, ayPoints, 3); }
public void paint(Graphics g) { // clears the area that the pannel is on gBuffer.setColor(Color.white); gBuffer.fillRect(0, 0, 65, 415); // pannel gBuffer.setColor(Color.black); gBuffer.drawRect(5, 15, 60, 400); // color buttons gBuffer.setColor(Color.black); // first column gBuffer.fillRect(15, 20, 20, 20); gBuffer.setColor(Color.red); gBuffer.fillRect(15, 40, 20, 20); gBuffer.setColor(Color.blue); gBuffer.fillRect(15, 60, 20, 20); gBuffer.setColor(Color.green); gBuffer.fillRect(15, 80, 20, 20); gBuffer.setColor(Color.yellow); gBuffer.fillRect(15, 100, 20, 20); gBuffer.setColor(Color.gray); // second column gBuffer.fillRect(35, 20, 20, 20); gBuffer.setColor(Color.magenta); gBuffer.fillRect(35, 40, 20, 20); gBuffer.setColor(Color.cyan); gBuffer.fillRect(35, 60, 20, 20); gBuffer.setColor(Color.orange); gBuffer.fillRect(35, 80, 20, 20); gBuffer.setColor(Color.pink); gBuffer.fillRect(35, 100, 20, 20); gBuffer.setColor(Color.black); // draw first column button outlines gBuffer.drawRect(15, 20, 20, 20); gBuffer.drawRect(15, 40, 20, 20); gBuffer.drawRect(15, 60, 20, 20); gBuffer.drawRect(15, 80, 20, 20); gBuffer.drawRect(15, 100, 20, 20); gBuffer.fillRect(15, 20, 20, 20); gBuffer.drawRect(35, 20, 20, 20); // draw second column button outlines gBuffer.drawRect(35, 40, 20, 20); gBuffer.drawRect(35, 60, 20, 20); gBuffer.drawRect(35, 80, 20, 20); gBuffer.drawRect(35, 100, 20, 20); // pen button design gBuffer.setColor(Color.black); gBuffer.drawRect(23, 125, 3, 20); penta = new Polygon(); penta.addPoint(23, 145); penta.addPoint(26, 145); penta.addPoint(25, 148); gBuffer.drawPolygon(penta); // brush button design gBuffer.setColor(Color.gray); gBuffer.fillRect(45, 128, 3, 10); penta = new Polygon(); penta.addPoint(45, 138); penta.addPoint(48, 138); penta.addPoint(51, 141); penta.addPoint(42, 141); gBuffer.drawPolygon(penta); gBuffer.setColor(Color.black); gBuffer.drawRect(42, 141, 9, 5); gBuffer.drawLine(45, 146, 45, 144); gBuffer.drawLine(48, 146, 48, 143); // roller button design gBuffer.setColor(Color.black); // handle gBuffer.fillRect(23, 155, 3, 10); gBuffer.drawRect(19, 165, 9, 4); gBuffer.setColor(Color.white); // roller front gBuffer.fillOval(27, 166, 4, 4); gBuffer.setColor(Color.black); // roller round side gBuffer.drawOval(27, 166, 3, 3); // spray paint button design gBuffer.setColor(Color.black); // top of can penta = new Polygon(); penta.addPoint(43, 156); penta.addPoint(48, 160); penta.addPoint(43, 163); gBuffer.drawPolygon(penta); gBuffer.setColor(Color.blue); // spray button gBuffer.fillRect(42, 155, 2, 3); for (int n = 0; n <= 20; n++) // paint spray { x = 39 + ((int) (3 * Math.cos((rnd.nextDouble() * 2 * Math.PI)))); y = 157 + ((int) (3 * Math.sin((rnd.nextDouble() * 2 * Math.PI)))); gBuffer.fillRect(x, y, 1, 1); } penta = new Polygon(); // can penta.addPoint(43, 163); penta.addPoint(48, 160); penta.addPoint(53, 172); penta.addPoint(48, 177); gBuffer.fillPolygon(penta); gBuffer.setColor(Color.black); gBuffer.drawPolygon(penta); // rubber band drawing button design (20,185,30,205); gBuffer.setColor(Color.black); for (int a = 18, b = 200; a <= 35; a += 4, b += 2) { gBuffer.drawLine(18, 183, a, b); } // eraser button design gBuffer.setColor(Color.yellow); // top penta = new Polygon(); penta.addPoint(45, 185); penta.addPoint(50, 185); penta.addPoint(45, 200); penta.addPoint(40, 200); gBuffer.fillPolygon(penta); gBuffer.setColor(Color.black); // outline gBuffer.drawPolygon(penta); gBuffer.setColor(Color.yellow); // side penta = new Polygon(); penta.addPoint(50, 185); penta.addPoint(45, 200); penta.addPoint(48, 204); penta.addPoint(52, 189); gBuffer.fillPolygon(penta); gBuffer.setColor(Color.black); // outline gBuffer.drawPolygon(penta); penta = new Polygon(); // front penta.addPoint(40, 200); penta.addPoint(45, 200); penta.addPoint(48, 204); penta.addPoint(43, 204); gBuffer.drawPolygon(penta); // clear button design gBuffer.setColor(Color.black); gBuffer.setFont(new Font("Arial", Font.BOLD, 20)); gBuffer.drawString("Clear", 10, 239); gBuffer.drawRect(10, 220, 50, 25); gBuffer.setColor(Color.cyan); switch (numSize) { case 1: gBuffer.drawRect(15, 120, 20, 30); break; case 2: gBuffer.drawRect(35, 120, 20, 30); break; case 3: gBuffer.drawRect(15, 150, 20, 30); break; case 4: gBuffer.drawRect(35, 150, 20, 30); break; case 5: gBuffer.drawRect(15, 180, 20, 30); break; case 6: gBuffer.drawRect(35, 180, 20, 30); break; } if ((numSize == 4) || (numSize == 6)) { // draw different size buttons for spray paint, eraser, and rubber band gBuffer.setColor(Color.white); gBuffer.fillRect(20, 265, 35, 75); gBuffer.setColor(Color.cyan); switch (size) { case 1: gBuffer.drawRect(26, 271, 18, 18); break; case 2: gBuffer.drawRect(26, 291, 18, 18); break; case 3: gBuffer.drawRect(26, 311, 18, 18); } gBuffer.setColor(Color.black); gBuffer.drawRect(20, 265, 30, 70); // size pannel gBuffer.drawRect(25, 270, 20, 20); // small gBuffer.drawRect(25, 290, 20, 20); // medium gBuffer.drawRect(25, 310, 20, 20); // large if (numSize == 4) { for (int n = 0; n <= 20; n++) { x = 35 + ((int) (4 * Math.cos((rnd.nextDouble() * 2 * Math.PI)))); y = 280 + ((int) (4 * Math.sin((rnd.nextDouble() * 2 * Math.PI)))); gBuffer.fillRect(x, y, 1, 1); } for (int n = 0; n <= 40; n++) { x = 34 + ((int) (6 * Math.cos((rnd.nextDouble() * 2 * Math.PI)))); y = 300 + ((int) (6 * Math.sin((rnd.nextDouble() * 2 * Math.PI)))); gBuffer.fillRect(x, y, 1, 1); } for (int n = 0; n <= 70; n++) { x = 35 + ((int) (8 * Math.cos((rnd.nextDouble() * 2 * Math.PI)))); y = 319 + ((int) (8 * Math.sin((rnd.nextDouble() * 2 * Math.PI)))); gBuffer.fillRect(x, y, 1, 1); } switch (size) { case 1: s = 4; break; case 2: s = 6; break; case 3: s = 8; } } else if (numSize == 6) { gBuffer.drawRect(33, 278, 4, 4); gBuffer.drawRect(32, 297, 7, 7); gBuffer.drawRect(30, 315, 10, 10); switch (size) { case 1: s = 4; break; case 2: s = 7; break; case 3: s = 10; } } } else { gBuffer.setColor(Color.white); gBuffer.fillRect(20, 265, 35, 75); } // draw pannel and buttons g.drawImage(virtualMem, 0, 0, this); // changing what color it draws with switch (numColor) { case 1: gBuffer.setColor(Color.black); break; case 2: gBuffer.setColor(Color.red); break; case 3: gBuffer.setColor(Color.blue); break; case 4: gBuffer.setColor(Color.green); break; case 5: gBuffer.setColor(Color.yellow); break; case 6: gBuffer.setColor(Color.gray); break; case 7: gBuffer.setColor(Color.magenta); break; case 8: gBuffer.setColor(Color.cyan); break; case 9: gBuffer.setColor(Color.orange); break; case 10: gBuffer.setColor(Color.pink); break; case 11: gBuffer.setColor(Color.white); break; default: gBuffer.setColor(Color.black); } // changing how it draws switch (numDraw) { case 1: // clear drawing gBuffer.setColor(Color.white); gBuffer.fillRect(0, 0, appletWidth, appletHeight); g.drawImage(virtualMem, 0, 0, this); numDraw = 0; repaint(); break; default: switch (numSize) { case 1: // draw with pen if (!first) { gBuffer.drawLine(oldX, oldY, newX, newY); g.drawImage(virtualMem, 0, 0, this); } else first = false; break; case 2: // draw with brush if (!first) { gBuffer.fillRect(oldX, oldY, 4, 4); g.drawImage(virtualMem, 0, 0, this); } else first = false; break; case 3: // draw with roller if (!first) { gBuffer.fillRect(oldX, oldY, 10, 10); g.drawImage(virtualMem, 0, 0, this); } else first = false; break; case 4: // draw with spray paint if (!first) { for (int n = 0; n <= 20; n++) { x = oldX + ((int) (s * Math.cos((rnd.nextDouble() * 2 * Math.PI)))); y = oldY + ((int) (s * Math.sin((rnd.nextDouble() * 2 * Math.PI)))); gBuffer.fillRect(x, y, 1, 1); g.drawImage(virtualMem, 0, 0, this); } } else first = false; break; case 5: // draw with rubber band style if (!first) { gBuffer.drawLine(startX, startY, endX, endY); g.drawImage(virtualMem, 0, 0, this); } else first = false; break; case 6: // eraser drawer if (!first) { gBuffer.fillRect(oldX, oldY, s, s); g.drawImage(virtualMem, 0, 0, this); } else first = false; break; default: // default to drawing with pen if (!first) { gBuffer.drawLine(oldX, oldY, newX, newY); g.drawImage(virtualMem, 0, 0, this); } else first = false; } } }
public void paint(Graphics g) { // Draw Grid g.drawRect(10, 10, 780, 580); g.drawLine(400, 10, 400, 590); g.drawLine(10, 300, 790, 300); Random rnd = new Random(1234); for (int k = 10; k <= 400; k += 10) { // The first box lines g.drawLine(k, 20, k, 290); } // The dimentions of the lines for (int k = 10; k <= 290; k += 10) { // The second box lines g.drawLine(420, k, 770, k); // The dimestions int red = rnd.nextInt(256); // The colors int green = rnd.nextInt(256); int blue = rnd.nextInt(256); g.setColor(new Color(red, green, blue)); // The randomness of colors } for (int k = 1; k <= 100; k++) { // The 3rd circles int x = rnd.nextInt(330); // the random of x lo int y = rnd.nextInt(230); // the randm of y int red = rnd.nextInt(256); // the random of colors int green = rnd.nextInt(256); int blue = rnd.nextInt(256); g.setColor(new Color(red, green, blue)); g.fillOval(x + 10, y + 300, 50, 50); } // the place of all the ovals Polygon side1 = new Polygon(); // blue side of cube side1.addPoint(600, 410); side1.addPoint(635, 410); side1.addPoint(635, 480); side1.addPoint(600, 445); g.setColor(Color.blue); g.fillPolygon(side1); Polygon side2 = new Polygon(); // green side of cube side2.addPoint(510, 380); side2.addPoint(550, 410); side2.addPoint(550, 495); side2.addPoint(510, 455); g.setColor(Color.green); g.fillPolygon(side2); Polygon side3 = new Polygon(); // yellow side of cube side3.addPoint(550, 445); side3.addPoint(600, 445); side3.addPoint(635, 480); side3.addPoint(550, 495); g.setColor(Color.yellow); g.fillPolygon(side3); Polygon side4 = new Polygon(); // red side of cube side4.addPoint(510, 380); side4.addPoint(550, 410); side4.addPoint(635, 410); side4.addPoint(600, 380); g.setColor(Color.red); g.fillPolygon(side4); // TODO Auto-generated method stub // TODO Auto-generated method stub }
public void paint(Graphics g) { // Draw Grid g.drawRect(0, 0, 780, 580); g.drawLine(400, 0, 400, 580); g.drawLine(0, 300, 780, 300); Random rndInt = new Random(1234); // Draw Random Squares for (int k = 1; k <= 1000; k++) { int x = rndInt.nextInt(385); int y = rndInt.nextInt(275); int red = rndInt.nextInt(256); int green = rndInt.nextInt(120); int blue = rndInt.nextInt(120); g.setColor(new Color(red, green, blue)); g.fillRect(x, y, 15, 15); } // Draw Random Lines for (int k = 1; k <= 1000; k++) { int x1 = rndInt.nextInt(350); int y1 = rndInt.nextInt(300); int x2 = rndInt.nextInt(370); int y2 = rndInt.nextInt(300); g.drawLine(x1 + 400, y1, x2 + 400, y2); int red = rndInt.nextInt(100); int green = rndInt.nextInt(100); int blue = rndInt.nextInt(100); g.setColor(new Color(red, green, blue)); } // Draw Random Circles for (int k = 1; k <= 1000; k++) { int x3 = rndInt.nextInt(385); int y3 = rndInt.nextInt(272); int red = rndInt.nextInt(240); int green = rndInt.nextInt(255); int blue = rndInt.nextInt(255); g.setColor(new Color(red, green, blue)); g.drawOval(x3, y3 + 300, 11, 11); } // Draw 3-D Box { g.setColor(Color.blue); int x[] = {575, 675, 675, 575}; int y[] = {425, 425, 525, 525}; g.drawPolygon(x, y, 4); g.fillPolygon(x, y, 4); } { g.setColor(Color.yellow); int x1[] = {525, 575, 575, 525}; int y1[] = {375, 425, 525, 475}; g.drawPolygon(x1, y1, 4); g.fillPolygon(x1, y1, 4); } { g.setColor(Color.green); int x2[] = {525, 625, 625, 575}; int y2[] = {375, 375, 425, 425}; g.drawPolygon(x2, y2, 4); g.fillPolygon(x2, y2, 4); } { g.setColor(Color.red); int x3[] = {625, 625, 675}; int y3[] = {375, 425, 425}; g.drawPolygon(x3, y3, 3); g.fillPolygon(x3, y3, 3); } }