Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  protected void paint(Graphics g) {
  2.         long start = System.currentTimeMillis();
  3.         for (int i = 0; i < 100; i++) {
  4.             red = Math.abs(r.nextInt() % 255);
  5.             green = Math.abs(r.nextInt() % 255);
  6.             blue = Math.abs(r.nextInt() % 255);
  7.             System.out.println(red +", " + green
  8.                     + ", " + blue);
  9.             g.setColor(red, green, blue);
  10.             g.fillTriangle((int)(this.getWidth()*r.nextFloat()), (int)(this.getHeight()*r.nextFloat()), (int)(this.getWidth()*r.nextFloat()), (int)(this.getHeight()*r.nextFloat()), (int)(this.getWidth()*r.nextFloat()), (int)(this.getHeight()*r.nextFloat()));
  11.         }
  12.         long stop = System.currentTimeMillis();
  13.         napis = "Czas wykonania: " + (stop-start) + "ms";
  14.         g.setColor(255, 255, 255);
  15.         g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL));
  16.         g.drawString(napis, this.getWidth()/2, this.getHeight()/2, Graphics.BASELINE | Graphics.HCENTER);
  17.        
  18.        
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement