📜 ⬆️ ⬇️

Purple squiggles

“And a bad PSCH generator works for something”



Crescent with retort
Crescent with retort
In the process of working on one task, an unexpected side effect arose. Visualizing a good pseudo-random number generator is noise and / or confusion. Obviously bad nobody wants to apply even for tests. I didn’t care, the very simple generator I was completely satisfied with, and with careful handling it produced an acceptable result. And suddenly, if someone with a sure stroke began to produce elegant abstract drawings.
Only 22 points are connected by Bezier curves and such an amusing result. Squiggles can be infinitely generated and for them, as for the clouds, does not bother to watch. You can come up with an interesting game - to unravel what this time gave us an accident, what is the pattern in it and come up with a name for it.
But these curves have more practical significance. The generator is the product of the lower and upper parts of the processor tick counter, from which an unsigned remainder is taken. If you generate numbers quite rarely, randomness turns out to be tolerable. Here numbers are generated frequently, randomness is bad, as can be seen from the forms zagogulin. Despite the potential number of 200 to 22 degrees of different squiggles, certain elements most often recur.
Presumably, the degree of “shaggyness” of the figure depends on the load on the system during those microseconds when the numbers were generated. The diagonal line, aka "traveler", speaks of an almost linear dependence of a random number on time and a small load on the system. "Scalar" - about more randomness, which means quite a high load ...
For those who want to have fun with purple squiggles, below is the code and a few bright representatives.




Some code
  ~ yz / lib / winctl.f
 REQUIRE WINDOWS ... ~ yz / lib / winlib.f

 0 VALUE win
 0 VALUE times
 0 VALUE hdc
 0 VALUE myrect
 0 VALUE mypen2
 22 VALUE dots
 0 VALUE fid
 CREATE 0d0a 0xD C, 0xA C, 

 CREATE * dots dots CELLS 3 * ALLOT

 : rnd TIMER @ * 200 UMOD;

 : rndxy dots 2 * 0 DO rnd 2 * 25 + I CELL * * dots +!  rnd 3 * 25 + I CELL * * dots + CELL +!  LOOP;

 : tre rndxy 
 S "X:" fid WRITE-FILE THROW 
 dots 2 * 0 DO I CELL * * dots + @ S> D (D.) fid WRITE-FILE THROW S "" fid WRITE-FILE THROW LOOP
 0d0a 2 fid WRITE-FILE THROW

 S "Y:" fid WRITE-FILE THROW
 dots 2 * 0 DO I CELL * * dots + CELL + @S> D (D.) fid WRITE-FILE THROW S "" fid WRITE-FILE THROW LOOP
 0d0a 2 fid WRITE-FILE THROW
 0d0a 2 fid WRITE-FILE THROW

  ;
 
  rndxy
 
 WINAPI: CreatePen GDI32.dll
 WINAPI: PolyBezier GDI32.dll


 PROC: paint
   mypen2 windc SelectObject DROP
   dots * dots windc PolyBezier DROP
   rndxy
 PROC;

 MESSAGES: my

 M: wm_lbuttondblclk
     rndxy 
     win winhide
     win winshow 
   TRUE
 M;
 MESSAGES;

 : run 
   WINDOWS ...
 S "warps.txt" R / W CREATE-FILE THROW TO fid

 0x00F00599 2 0 CreatePen TO mypen2

 0 create-window to win
  win TO winmain
  "Bezheshki" win -text!
 420 430 0 button place 
 this TO myrect
 10 10 myrect ctlresize
   ['] tre myrect -command!

 120 130 win winmove
 500 500 win winresize
    paint win -painter!
   my win -wndproc!
 win winshow

 ... WINDOWS
 fid CLOSE-FILE THROW
 BYE
 ;

 TRUE TO? GUI
 'run MAINX!
 S "warpy.exe" SAVE
 run


')
This code, running in the SPF console, will create the warpy.exe executable, which can already be run by itself. Double click (left button) on the picture changes it. A button in the lower right corner saves a set of X, Y coordinates to the warps.txt file


More pictures
Paraparabola

Sparrow

Scalar

Plectors

Flower, top view

Tulip

Traveler

Decanter with two bottles

Lasso

Kandinsky

Source: https://habr.com/ru/post/211709/


All Articles