From: tinywanda@aol.com (TinyWanda)
Newsgroups: comp.sys.hp48
Subject: SnowFlakerizer ( Mighty Fat )
Lines: 492
NNTP-Posting-Host: ladder03.news.aol.com
X-Admin: news@aol.com
Date: 30 Nov 1998 02:51:41 GMT
Organization: AOL http://www.aol.com
Message-ID: <19981129215141.05131.00000022@ng39.aol.com>
Xref: republic.btigate.com comp.sys.hp48:19160


SnowFlakizer
By TinyWanda 
TinyWanda@aol.com

SnowFlakizer draws SnowFlakes on PICT.
These may be regulation snowflakes, or modified snowflakes.
You have the option of printing them out as a continuous stream with the
Thermal Printer, or Saving them and transferring them to your big box at a
later time.

The Snow Directory has 25 Objects in it initially...

Make     The Main Program
->P.Sz   Defines the Size of PICT
Varz     Inputs all the Variables that are Needed
Save     Saves anything without Thinking
.1to1    Defines PICT with Square Pixels for the B Printer
Ptrue    Defines PICT with Square Pixels for the A Printer
Abc      Translates Decimal Numbers to Alphabet Numbers
Bep      Makes Bepping Noises
Bold     Thickens the Lines on a GROB
Cpict    Moves LCD view to the Center of PICT
~Sub     Inverse of SUB
Do.?     Does something or doesn't do something
Do.F     Sets or Clears a Flag
Pxdm     Returns the Size of one Pixel
->6?     Creates a Quantumized Semi-Random Destination
->12     Plots a Kalidoscopic Array of Pixels
P->r     Polar to Real
R->p     Real to Polar
.->a     Used with Save to define auto-names
.->e     Node Memories
.->^     Flake Facets
.->$     Pixel Facets
.->d     Deviation of Angularity
.->p     Pixel Density
PPAR     Plot Parameters

Flags                 Set           Off
2   Facet Reflection  Mirrored      Asymetrical
3   Thicker Lines     Thick         Thin
4   Colours           White Lines   Black Lines
5   Destination       Print         Save

:---------------------------:: <o>
The Objects:
:---------------------------:: <o>

Make    # 29AFh  373
Make has a double click feature which allows you to call up the Variable
assigner routine ( Varz ).
If you single click the program, it will simply begin making Snowflakes using
the currently defined Global Variables. 
 ( see Varz )
--------------------:: <
->P.Sz   # 6A03h  63
SnowFlakizer works best (!) when the PICT is defined as a Square, so this
program allows you to input a single Real Number to define both parameters...
REMEMBER! If you're going to use the line thickener, with the Thermal
printer...allow for an extra pixel to be added to the width, after plotting,
but before Printing!
Also; If you have an old A Thermal printer, the pixels are higher than
wider...So if you define the PICT width as 165 ( 166 for skinny line plots )
then set the hieght at 138 or so...???
The Ratio is .827957 of Width.
OR: (!) AND: (?) If you have a new B Thermal Printer, or are using some other
printer that uses the correct proportions...then change 'Ptrue' in 'Make' to
'.1to1'...!!!

--------------------:: <
Varz    # 52B6h  783
Varz is a separate utility to assign all the Variables that Make and some of
the other Programs use.
The INFORM window will ask for:

   Meta Snow Flake Variables

^  Flake Facets
   The number of arms/legs on the SnowFlake

v  Pixel Facets
   The number of sides to a pixel (?)
   The new pixels can only be added to old pixels
   at certain quantified angles to the old pixels.
   Use 6 for Regulation Snowflakes.

p  Pixel Density
   The length of a Snow Pixel
   Each Snow Pixel is actually a Line drawn from 
   an old pixel to a new pixel, this is how long that
   line is, in pixels.

e  Node Memory
   The number of recallable Pixel Nodes
   To provide continuity, new pixels are added to 
   old pixels, this is how many old pixels are 
   remembered.

a  Alpha Variable
   The first Saved Name; 1 = A
   The 'Save' program saves things by assigning a
   sequential name to those items, 
   that it's given, one at a time...
   1 starts with A, then the Alpha
   Variable is incremented to B, and so on...
   After Z, it goes to AA, then AB & so on...

d  Deviation of Rotation
   When you're plotting snowflakes, the horizontal
   lines will look 'stronger' than the diagonal lines...
   If this annoys you, you might set this variable
   to something to rotate the snowflake slightly...?

F2 Facet Reflection
   Set/1 Causes the SnowFlake arms to be plotted 
         as Reflections, like a Kalidoscope.
   Clr/0 Causes the Mandala's arms to be plotted 
         Asymetrically.

F3 Thicker Lines
   Set/1 After the figure is plotted,
         The entire GROB will be Bolded.
   Clr/0 The plotted figure will be left alone.

F4 White on Black or vice/versa
   Set/1 After the figure is plotted,
         The GROB will be Negatized.
   Clr/0 The plotted figure will be left alone.

F5 Print or Save
   Set/1 Will print each Snowflake, 
         then begin a new one.
   Clr/0 Will Save the Snowflake in the 
         Snow Directory.

--------------------:: <
Save     # C86Bh  53
Painlessly Saves any object on 1: using the numerical value in the alpha
variable as an alphabetic name...?
if alpha = 1  then the assigned name will be 'A'
if alpha = 27 then the assigned name will be 'AA'

--------------------:: <
.1to1  # C5CBh 141.5
Reconfigures PICT so that the pixels are Square.

--------------------:: <
Ptrue  # DFB7h 115.5
Reconfigures PICT so that the pixels are 'squished' so that when the PICT is
recalled and Printed on the A Thermal Printer, The pixels will appear squared.

--------------------:: <
Abc     # 6C77h  150
Converts a real integer number to is Alphabetic equivalent.
1       = A
26      = Z
27      = AA
343821  = SNOW
2953735 = FLAKE

--------------------:: <
Bep   # 74BFh  350.5
Makes Bepping noises.
Input may either be a single Real Integer 0<b<6
or 
A list of 2 Real Integers { n 0<b<6 }
n is the number of beps
b is the kind of bep

--------------------:: <
Bold    # DA6Ch  207
Makes all the lines and areas on a given GROB thicker by one pixel. Thus a
single pixel would then be 2 by 2 pixels.

--------------------:: <
Cpict    # 1264h  73
Moves the LCD to the Center of PICT.

--------------------:: <
~Sub     # 8BFDh  66
This is the inverse (?) of SUB
So that it removes the defined sub-set, 
leaving the original, without it...!

--------------------:: <
Do.?   # A3D1h 134.5
The Object on 2: is either Evaluated or Retained if the Probability on 1: is
met by the PsuedoRandom Generator.
1: may be either a Real Integer, in which case it's interpretted as 1 of x
chances of being Evaluated.
or, if 1: is a fractional value, then it's interpreted to be a percentage of
x...? ( .25 = 1 in 4 odds )

--------------------:: <
Do.F   # 4060h  35.5
2: is either a 1 or a 0
1: is the Flag to Set or Clear

--------------------:: <
Pxdm      # 77Ah  88
Returns the pixel dimension of one pixel on PICT.

--------------------:: <
->6?     # 2478h  79
Takes an (x,y) coordinate from PICT on 1: 
and Returns a quantified pixel near it, as defined by the variables .->p &
.->$. 
Out put is actually a list of the old pixel and the new one.
 
--------------------:: <
->12    # AC4Ch  272
Is used by Make, and requires a stack configuration unique to that
application...! (?)
4:   The Derived Position of the Pixel Set
3:   The Remembered Node Pixel Set ( List )
2:   The Pair of Pixels to be Plotted
1:   Dup of 2:
If the second pixel of the pair to be plotted falls on a black pixel, than no
pixels are plotted, and the originating pixel is deleted from the Node List!

--------------------:: <
P->r   # 83B2h  48.5
Polar to Real
( radius, angle ) is converted to ( x, y )

--------------------:: <
R->p   # FCA7h  48.5
Real to Polar
( x, y ) is converted to ( radius, angle )

--------------------:: <

:----------------------------------------:: o ::
The Snow Directory
:----------------------------------------:: o ::

Name:         Snow
CheckSum:  # E64Ch
Size:         3270
:-------------------:: o :

%%HP: T(3)A(D)F(.);
DIR
  Make
    \<< .2 WAIT KEY
      \<< DROP Varz
      \>> IFT :&:
Cpict EVAL
      DO
        IFERR { }
RAND .38 * RAND .38
* \->V2 + ERASE
          DO DUP 1
DUP 4 ROLLD GET \->6?
DUP \->12 2 GET DUP 3
ROLLD SWAP + DUP
SIZE \183\->\Ge \>= :: TAIL
IFT
          UNTIL
SWAP ABS PPAR 2 GET
RE \183\->\254 - \>=
          END
        THEN
        END RAND 60
* CEIL { 3 } + Bep
PICT RCL 3 FS? :&:
Bold IFT 4 FS? ::
NEG IFT 5 FS?
        \<< PR1 CR
        \>> 'Save'
IFTE CLEAR
      UNTIL KEY
      END DROP
    \>>
  \->P\183Sz
    \<<
"PICT Size As A Square"
"" INPUT OBJ\-> R\->B
DUP PDIM
    \>>
  Varz
    \<<
"META SNOW FLAKE VARIABLES"
{ { "\GD:"
"FLAKE FACETS" } {
"\Ga:"
"ALPHA VARIABLE" }
{ "F2"
"1:FACET REFLECTION"
} { "\.V:"
"PIXEL FACETS" } {
"\240:"
"DEVIATION OF ROTATION"
} { "F3"
"1:THICKER LINES" }
{ "\254:"
"PIXEL DENSITY" } {
} { "F4"
"1:WHITE ON BLACK"
} { "\Ge:"
"NODE MEMORY" } { }
{ "F5"
"1:PRINT OR 0:SAVE"
} } { 3 3 } { 6 1 1
6 0 1 3 1 38 1 }
\183\->\GD \183\->\Ga 2 FS? \183\->\167
\183\->\240 3 FS? \183\->\254 Pxdm
ABS / 0 RND 4 FS?
\183\->\Ge 5 FS? 10 \->LIST
INFORM
      \<< EVAL 5 Do\183F
9 ROLLD 4 Do\183F -1 1
DUP2 XRNG YRNG 5
FS? 'Ptrue' '\1831to1'
IFTE Pxdm ABS * 8
ROLLD 3 Do\183F ROT 2
Do\183F 6 \->LIST { \183\->\254
\183\->\Ge \183\->\GD \183\->\Ga \183\->\167 \183\->\240
} STO
      \>>
      \<< { 20 4 }
Bep
"Uh-Oh!!!
Run Away, Run Away!!!"
DOERR
      \>> IFTE
    \>>
  Save
    \<< \183\->\Ga Abc OBJ\->
STO '\183\->\Ga' 1 STO+
    \>>
  \1831to1
    \<< { # 1d # 0d }
PX\->C { # 0d # 1d }
PX\->C - V\-> DUP2 MAX
OVER ==
      \<< SWAP / *W
      \>>
      \<< / *H
      \>> IFTE
    \>>
  Ptrue
    \<< :&: Pxdm EVAL
OBJ\-> / DUP .83788 <
      \<< INV .83788
* *W
      \>>
      \<< 1.1936 * *H
      \>> IFTE
    \>>
  Abc
    \<< ""
      WHILE OVER 26
>
      REPEAT OVER
26 SWAP 1 - SWAP
MOD 1 + DUP 64 +
CHR ROT + 3 ROLLD -
26 / SWAP
      END SWAP 64 +
CHR SWAP +
    \>>
  Bep
    \<< DUP TYPE 5 ==
      \<< EVAL
      \>>
      \<< 1 SWAP
      \>> IFTE \-> \Ge \GD
      \<< { { 20 15
.5 } { 100 20 .1 }
{ 2000 500 .02 } {
4000 1000 .005 } {
8000 10 .04 } } \GD
GET EVAL \-> a b c
        \<< RCLF -56
CF 1 \Ge
          START
RAND a * b + c BEEP
          NEXT STOF
        \>>
      \>>
    \>>
  Bold
    \<< \-> $
      \<< $ SIZE 1 +
SWAP 1 + SWAP BLANK
{ # 0d # 0d } $
REPL { # 1d # 0d }
$ GOR { # 1d # 1d }
$ GOR { # 0d # 1d }
$ GOR
      \>>
    \>>
  Cpict
    \<< PICT SIZE 64
- 2 / SWAP 131 - 2
/ SWAP 2 \->LIST
PVIEW
    \>>
  ~Sub
    \<< ROT DUP SIZE
OVER 1 6 ROLL 1 -
SUB ROT 4 ROLL 1 +
4 ROLL SUB +
    \>>
  Do\183?
    \<<
"2: DoThis
1: Chance"
.2 WAIT KEY
      \<< DROP ""
INPUT OBJ\->
      \>> :: DROP
IFTE DUP 1 < :: INV
IFT RAND * CEIL 1
== :: EVAL :: DROP
IFTE
    \>>
  Do\183F
    \<< SWAP :: SF ::
CF IFTE
    \>>
  Pxdm
    \<< { # 1d # 0d }
PX\->C { # 0d # 1d }
PX\->C -
    \>>
  \->6?
    \<< DUP \183\->\254 RAND
\183\->\167 * CEIL 360 \183\->\167
/ * \->V2 P\->r + 2
\->LIST
    \>>
  \->12
    \<< { LINE TLINE
} RAND 2 * CEIL GET
\-> \|v
      \<< DUP 2 GET
PIX?
        \<< ROT 4
ROLL DUP ~Sub 3
ROLLD
        \>>
        \<< 4 ROLL
DROP \-> \Ga
          \<< 0 2 FS?
            FOR \191 0
359
              FOR \x-
\Ga 1
\<< R\->p \191 :: CONJ IFT
V\-> \x- + \183\->\240 + \->V2
P\->r
\>> DOLIST EVAL \|v
EVAL 360 \183\->\GD /
              STEP
            NEXT
          \>>
        \>> IFTE
      \>>
    \>>
  P\->r
    \<< V\-> -16 SF \->V2
-16 CF
    \>>
  R\->p
    \<< -16 SF V\-> -16
CF R\->C
    \>>
  \183\->\Ga 1
  \183\->\Ge 26
  \183\->\GD 6
  \183\->\167 6
  \183\->\240 7
  \183\->\254
5.17395205737E-2
  PPAR { (-1,-1)
(1,1) X 0 (0,0)
FUNCTION Y }
END

-----[ Terminus ]-----    ::




----------- :: o
.---..-..-..-..-..-..-.  .  .-. .-.  .-..-..-..   .-.  
`| |'| || .` | >  /  \ \/ \/ / /   \ | .` || | ) /   \ 
 `-' `-'`-'`-' `-'    `. ^ .' `--^--'`-'`-'`-'' `--^--'
Join The BabyNous Cult : The Friendly Neighborhood Cult