Skip to main content
added 124 characters in body
Source Link
Franz D.
  • 231
  • 1
  • 5

Java, 339 308 289289 287 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaintpaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but ~60 seconds for a full circle on my machine, which is OK according to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

EDIT 3: @Ajay suggested to remove the "re" from "repaint". Two bytes less. We're getting there :)

Java, 339 308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but ~60 seconds for a full circle on my machine, which is OK according to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

Java, 339 308 289 287 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)paint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but ~60 seconds for a full circle on my machine, which is OK according to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

EDIT 3: @Ajay suggested to remove the "re" from "repaint". Two bytes less. We're getting there :)

more specific on timing of new solution
Source Link
Franz D.
  • 231
  • 1
  • 5

Java, 339 308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT:EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2:EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but that~60 seconds for a full circle on my machine, which is no problem accoringOK according to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

Java, 339 308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but that is no problem accoring to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

Java, 339 308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but ~60 seconds for a full circle on my machine, which is OK according to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

updated version
Source Link
Franz D.
  • 231
  • 1
  • 5

Java, 339 bytes 308308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);try{Thread.sleep(95);}catch;for(Exceptionint ei=0;++i<62864;){}repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but that is no problem accoring to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

Java, 339 bytes 308 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);try{Thread.sleep(95);}catch(Exception e){}repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

Java, 339 308 289 bytes

import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)repaint();}public static void main(String[] x){new F();}}

Thanks to @Peter Lenkefi, whose great solution got me started, and whose for-loop I shamelessly copied!

The main saving was due to switching to pure AWT and rendering directly in the Frame -- no need for a JPanel (or Canvas). I also made the counter an integer variable, updated by simple increment, and saved a few bytes twiddling the constants to be able to strip a digit here and there.

EDIT: Thanks to @Peter Lenkefi and @tobii for their suggestions in the comments. Beating HTML would be nice -- does anyone know how to reliably pause execution in Java without using sleep() and having to catch exceptions?

EDIT 2: JAVA BEATS HTML (currently at 290 bytes!) :D Timing is now machine-dependent, but that is no problem accoring to @Lembik. Thanks again to @PeterLenkefi for his suggestion -- my answer is more than half his :)

added thanks to suggestors
Source Link
Franz D.
  • 231
  • 1
  • 5
Loading
Source Link
Franz D.
  • 231
  • 1
  • 5
Loading