Message Boards Message Boards

[GIF] Random Lines (8 frames of 20,000 random lines each)

5 Replies

How did you create the GIF, I see the code and it outputs only one image... did you use Wolfram too to export a GIF consisting of 8 evaluations of that cell?

POSTED BY: Claudio Mora

I think it is as simple as generating 8 random images, putting them in a list and exporting, something like this probably:

Export["animation.gif",{img1, img2, ...}]
POSTED BY: Sam Carrettie

Yes, that will do it. For example, here's code that will do the whole thing (notice that I'm creating a $540 \times 540$ GIF, whereas the code in the original post creates a single $1080 \times 1080$ image):

RandomAngle[] := RandomVariate[UniformDistribution[{0, 2 Pi}]];
RandomDirection[] := 
  With[{\[Theta] = RandomAngle[]}, {Cos[\[Theta]], Sin[\[Theta]]}];

img = Block[{r, \[Theta], v, p, 
   cols = RGBColor /@ {"#252A34", "#FF2E63", "#08D9D6", "#EAEAEA"}},
  Table[
   Graphics[{Thickness[.0002], 
     Table[{r = RandomVariate[UniformDistribution[]];
       \[Theta] = RandomAngle[];
       v = RandomDirection[];
       p = {r Cos[\[Theta]], r Sin[\[Theta]]};
       {Blend[cols, r], InfiniteLine[p, v]}}, {20000}]}, 
    PlotRange -> 1, ImageSize -> 540],
   {8}]
  ];

Export["animation.gif", img, "DisplayDurations" -> 1/25, 
 "AnimationRepetitions" -> Infinity]

I really like that you are taking advantage of "DisplayDurations" in Export. I think that option influences a lot the visual perception of animation.

POSTED BY: Sam Carrettie

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

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

Group Abstract Group Abstract