This is a graphical output challenge where the task is to give the shortest code per language.

Task

Your code should plot a single purple pixel (hex value #800080 or
rgb(128, 0, 128)), moving clockwise round a circle. It should take exactly 60 seconds to make a full journey round the circle and should continue indefinitely. Nothing else should be shown on the screen or window except for the pixel. The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white. To prevent silly solutions, the screen or window should be at least 100 pixels wide.

Your code should be a full program.

Languages and libraries

You can use any language or library you like. However, I would like to be able to test your code if possible so if you can provide clear instructions for how to run it in Ubuntu that would be very much appreciated.

Missing top twenty languages. Help needed.

The following top twenty programming languages are currently missing any solution at all.

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

\$\begingroup\$Why should the pixel be purple? I would assume some languages like TI-Basic don't have color capabilities, which means they can't be used for the challenge for a pretty abitrary reason\$\endgroup\$
– FatalizeOct 29 '15 at 14:42

1

\$\begingroup\$@Fatalize that doesn't mean you can't golf the color into the program in some clever creative way to save bytes.\$\endgroup\$
– Timothy GrooteOct 29 '15 at 14:43

3

\$\begingroup\$@TimothyGroote TI-BASIC has mainly only one color: black. Everything else is an off pixel. There are C(SE) calculators that have colors, but not everyone has one.\$\endgroup\$
– Conor O'BrienOct 29 '15 at 14:53

10

\$\begingroup\$I'm sure putting a purple cellofane over your screen does not add to your code size in bytes. i mean it worked vor the vectrex ;)\$\endgroup\$
– Timothy GrooteOct 29 '15 at 15:45

\$\begingroup\$Instructions for running: create the file pixround.tcl, paste my code and then save. Then on your graphical environment,open a console, go to the file you created's directory and type wish pixround.tcl and you should see the see pixel doing its round trip.\$\endgroup\$
– sergiolSep 29 '17 at 1:07

\$\begingroup\$I run your 168-byte code with Tk 8.6.6. I see a black pixel instead of a purple one. Your screenshot also has a black pixel. I checked by using xmag to magnify the pixel.\$\endgroup\$
– kernighNov 26 '17 at 22:35

1

\$\begingroup\$@kernigh: fixed. At the expense of some bytes.\$\endgroup\$
– sergiolNov 26 '17 at 23:23

Matlab, 104 103 102 bytes

Smallest I could get it with the colour requirements. If you had gone for magenta rather than purple it would be 12 bytes shorter :).

figure('Color','w'); %Start with a white background
while 1
3*exp(toc*pi/30i) %This bit makes the point - e^(theta/i)
plot( ,'Co',[.5 0 .5]); %This plots it
axis([-4 4 -4 4],'off'); %Make the axis 33% larger than the circle and invisible
drawnow; %Update within the loop
end

Basically it creates a figure which has a white background. Then in a forever loop it plots a figure which is a single point of a complex number which has a magnitude of 3 and an angle of the current time normalised to a 60 second circle. The colour of the plotted point is purple (#7f007f). Once plotted, the axis are set to limits of +/-4 which means the circle drawn will be 75% of the axis size. The axes are then turned off (made invisible) and the figure updated. This gives a nice point moving around a circle in real time.

I've corrected the code so that it rotates clockwise (it was going anticlockwise before) and in the process saved a byte :). The wonders of -j*n = n/j.

\$\begingroup\$If you look at the question or the other answers you will see how to set out the headers so your result can be put in the leaderboard. Having said that I think it is buggy currently. The dot jumps from one side to the other at least using the code snippet.\$\endgroup\$
– user9206Oct 30 '15 at 20:32

\$\begingroup\$You can save 4 bytes by dropping the var keyword and space. Globals are ok for golfing\$\endgroup\$
– FlambinoOct 31 '15 at 10:26

\$\begingroup\$There are a couple of other minor changes which can reduce the code size: pastebin.com/1GPCA227 (By the way, the color code should be #800080.)\$\endgroup\$
– manatworkOct 31 '15 at 12:09

\$\begingroup\$Sinclair BASIC! We are close to the source now... :)\$\endgroup\$
– user9206Nov 2 '15 at 12:18

1

\$\begingroup\$I wrote an interpreter a while ago (actually still am) and I'm always looking out for fun stuff to do with it - this site is an absolute goldmine :)\$\endgroup\$
– ZXDunnyNov 3 '15 at 13:09

This is a console application that creates a form. This saves a lot of designer generated clutter.

Add a reference to System.Drawing.dll and System.Windows.Forms.dll. Add user Imports for System.Drawing, System.Windows.Forms and System.Math namespaces.

I shamelessly ripped the position calculation from Mauris' QB64 answer (https://codegolf.stackexchange.com/a/62126/20520), but based the calculation on Date.Now.Ticks instead, which needs to be converted to seconds by dividing by 10 million!

The form is refreshed by a timer and the dot is painted directly to the form in its Paint event. This saves a lot of initialization code for any picturebox or similar.

From user12864's answer in C# (https://codegolf.stackexchange.com/a/62433/20520) I got the idea of invalidating the form in its own paint handler, which is a horrible thing to do but gets rid of any need for a timer. The timer solution looked a lot prettier due to all the flickering induced by this solution...but length over style in Code Golf I guess :-)

Unfortunately, the forms have a larger default MinimumSize than 100,100, which needs to be adjusted to fullfill the requirement. You also need to set ClientSize instead of Size to correctly scale the "active" drawing surface.

Believe it or not, GDI+ does not have a simple DrawPoint function. You draw a point by drawing a filled 1x1 rectangle.

Progress ABL, character Interface, 445 bytes

A couple of comments:

I have no way in ABL to really work with pixels. It could possibly be done by creating a rectangle that's 1 x 1 pixel and moving it around. But even that would be cumbersome. Instead I choose to use a period character (.): hence this solution is for character interface and not a graphic client. Maybe I'll come back with a graphical solution some other time...

Since the space of one character is higher than it is wide I've set the screen size to 65 columns by 20 rows. Roughly estimating a square.

Purple colour is another problem. From start I'm limited to 16 preset colors and none match the purple I need. Changing the colors in character mode is done by editing a init file used when starting the program. Therefore I instead set the period to "color 13" - 255,0,255 by default. Not the wanted purple but at least a purple color.

Another dilemma is the absence of sine and cosine functions or anything remotely like that (rotate etc). To bypass this I choose to call an external Windows DLL - meaning this specific solution only works in Windows environments. However if there are any similar Linux libraries available it should be easy enough to port.

Of course I've been "inspired" by solutions in other languages to pull this off...

My main ways of reducing size:

Shortening certain statements, ie DISP instead of DISPLAY.

Global definitions (preprocessors).

Whitespace and line breaks

This is my first attempt at Golf so I might very well be doing something wrong here - like byte count or otherwise. Please tell me if so!

settimer 1 50[ For each 50 millisecond, do:
setpixel 7 Set the color under the turtle to white (color 7). Alternatively: "white (6 bytes) or [255 255 255] (too many bytes)
arc2 .3 99 Rotate 0.3 degrees around a circle with radius 99
setpixel "purple Set the pixel under the turtle to purple (800080).
Color magenta (FF00FF, if allowed) would takes much less bytes (just 1 bytes: "5")
] End instruction-list.
ht Hide the turtle. Avoid drawing the turtle on the screen together with the pixel.
pu Pen-up. Avoid the turtle leave a trail while moving.

Ruby+RMagick+FFmpeg, 203 bytes

Run with ruby -rrmagick circle.rb; I count 193 bytes in the file, plus 10 bytes to edit ruby circle.rb into ruby -rrmagick circle.rb. This is longer than Ruby with Shoes (134 bytes).

Before running this program, you must install ImageMagick, ffmpeg, ruby, then run gem install rmagick. Ubuntu user would need some dev packages. The program takes a few minutes to save the c.gif file, then displays it in ffplay's window. It leaves c.gif in the current directory.

If I use a.animate, then RMagick displays the animation in its own window, but the timing is too slow. The circle takes about 66 seconds, not the correct 60 seconds.

To get the correct timing, I must add 36 bytes by deleting a.animate and adding code to save a .gif and display it in another program. If I run firefox c.gif or chrome c.gif, the timing is correct, but the white box of 160x160 pixels appears in the center of a much larger window, so the circle seems too small in the window. I run ffplay -loop 0 c.gif to get both the correct timing and the correct window size.

ImageMagick also comes with shell commands, so it might be possible to translate this answer into shell script, but I have not done so.

Your Answer

If this is an answer to a challenge…

…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.

…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.

…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.

More generally…

…Please make sure to answer the question and provide sufficient detail.

…Avoid asking for help, clarification or responding to other answers (use comments instead).

Post as a guest

Post as a guest

Code Golf Stack Exchange is a site for recreational programming competitions, not general programming questions. Challenges must have an objective scoring criterion, and it is highly recommended to first post proposed challenges in the Sandbox.