Group Abstract Group Abstract

Message Boards Message Boards

5
|
15.4K Views
|
4 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Updating a One-Liner Competition Winner

Posted 11 years ago
POSTED BY: Evan Ot
4 Replies

Just an idea, not sure how to make it, - I think this needs memory. Basically if we show a sequence of a few loops ( trailing ) the the visual will be much more striking. I think also after awhile this gets stuck in a short cycle of repetitive behavior. It became so dense, hard to understand. Could someone tell me - is it really just a random vector of 2D points slightly incremented by another random vector?

POSTED BY: Sam Carrettie
Posted 11 years ago

I was never the golfing sort with respect to coding, but maybe y'all might pick up something of use:

r := RandomReal[{-1, 1}, {7, 2}]; p = q = r; c = 0;
Dynamic[If[(c += .01) == 1, {p, q} = {q, r}]; c -= ?c?; 
        Graphics[{Hue[#?1,1?], BSplineCurve[#, SplineClosed -> True]} &[{1 - c, c}.{p, q}], PlotRange -> 1]]
POSTED BY: J. M.

It gets down to 164 characters if you are willing to sacrifice the fixed size of the plot and have it dynamically resizing. I made a couple of other optimisations: for example, you don't need to redefine data in the If block.

r := RandomReal[1, {7, 2}]; p = p2 = r; c = 0; d := 
 p + # (p2 - p) &; Dynamic[c += .01;
 If[c == 1, p = p2; p2 = r]; c = FractionalPart[c]; 
 Graphics[{Hue@d[c][[1]], BSplineCurve[d[c], SplineClosed -> 2 > 1]}]]
POSTED BY: Patrick Stevens

And it can be trimmed just a bit more:

r:=RandomReal[1,{7,2}];p=p2=r;c=0;d:=p+# (p2-p)&;Dynamic[If[(c+=.01)==1,p=p2;p2=r];Graphics[{Hue@d[c=FractionalPart@c][[1]],BSplineCurve[d@c,SplineClosed->2>1]}]]

by making constructs like (c+=.01)==1 and using @ and the [[ and ]] can be typed as 1 character...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard