0
\$\begingroup\$

Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.

Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and at all circles must fit within the window.

\$\endgroup\$

closed as unclear what you're asking by Rɪᴋᴇʀ, Nathan Merrill, Value Ink, Marv, NinjaBearMonkey May 8 '16 at 1:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ what do you mean by random sizes? what size should the window be? Can they be overlapping? Do the positions have to be random? Does it have to be filled or only have an outline? \$\endgroup\$ – Maltysen May 8 '16 at 0:18
  • 2
    \$\begingroup\$ Bash, 5 bytes. feh f Must be ran in a directory containg a file named 'f' that is an image containing 100 circles of random sizes and colors, and feh must be installed. This is technically not against the rules since their aren't any. \$\endgroup\$ – DJMcMayhem May 8 '16 at 0:23
  • \$\begingroup\$ I like the challange but as it stands, this is way to broad. As @DrGreenEggsandHamDJ said, you should definitely think about some limiting rules. \$\endgroup\$ – Marv May 8 '16 at 1:32
1
\$\begingroup\$

Mathematica 106 bytes

The code is fairly straightforward. A palette is a floating window. The 100 circles are stored in an array. The first ryields coordinates; the second r yields a radius.

CreatePalette[{Graphics[Array[{RandomColor[],Disk[99~(r=RandomReal)~{2},r@5]}&,100],Background->Black]}]

circles

\$\endgroup\$
0
\$\begingroup\$

Java, 352 Bytes

Yeah, I know, an applet, but still...

import java.applet.*;import java.awt.*;import java.util.*;public class C extends Applet{public void paint(Graphics a){Random b=new Random();int x,y,diameter;setBackground(Color.black);for(int c=1;c<=100;c++){a.setColor(new Color(b.nextInt(0xFFFFFF)));d=b.nextInt(getWidth()/10);x1=b.nextInt(getWidth());y1=b.nextInt(getHeight());a.drawOval(x,y,d,d);}}}

Ungolfed Code:

import java.applet.*;
import java.awt.*;
import java.util.*;

public class C extends Applet {
    public void paint(Graphics a) {

        Random b = new Random();

        int x, y, d;

        setBackground(Color.black);

        for (int c = 1; c <= 100; c++) {
            a.setColor(new Color(b.nextInt(0xFFFFFF)));

            d = b.nextInt(getWidth() / 10);
            x = b.nextInt(getWidth());
            y = b.nextInt(getHeight());

            a.drawOval(x, y, d, d);
        }

    }
}
\$\endgroup\$
  • \$\begingroup\$ @EᴀsᴛᴇʀʟʏIʀᴋ Nope. \$\endgroup\$ – Nic Hartley May 8 '16 at 0:11
  • \$\begingroup\$ Have you tried using Math.random()*getWidth() in place of b.nextInt(getWidth())? It may save you a few bytes (you'd remove the Random b definition too) \$\endgroup\$ – Nic Hartley May 8 '16 at 0:14
  • \$\begingroup\$ how about c<101 rather than c<=100 \$\endgroup\$ – Bald Bantha May 9 '16 at 15:39
0
\$\begingroup\$

Python 2 PIL - 199 bytes

Making some assumptions of the rules based on OP's answer. Not optimally golfed in the sense that the image could be 5 pixels across and the circles could be all the same place with grayscale colors, but goes with the spirit of the rules.

import Image,ImageDraw,random
h=999
i=Image.new('RGB',(h,h))
g=random.randint
exec"r,x,y=g(0,50),g(0,h),g(0,h);ImageDraw.Draw(i).ellipse((x-r,y-r,x+r,y+r),(g(0,255),g(0,255),g(0,255)));"*100
i.show()
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.