App-GUI-Harmonograph
view release on metacpan or search on metacpan
lib/App/GUI/Harmonograph.pm view on Meta::CPAN
Our third pendulum W moves (wobbles) the paper in circulating manner around
its center (but not rotating, so a dot in the left corner will always left).
If both circular movements (of X, Y and the one of W) are concurrent -
the pen just stays at one point over the paper and paints only a dot.
If both are countercurrent - we get a circle.
Interesting things start to happen, if we alter the speed of of X, Y and W.
Than famous harmonic pattern appear.
And for even more complex drawings I added R, which is not really
a pendulum and not part of the original Harmonograph,
but an additional rotary movement of the paper around its center.
I added even 2 more pendula (E and F which are also lateral like X and Y),
which draw an epicycle around the point where the dot would be normally drawn.
The pendula out of metal do of course fizzle out over time,
which you can see in the drawing as a spiraling movement toward the center.
We emulate this with two damping factors: one for amplitude/radius and one
for the frequency (speed). The radius or ampitude of Pendulum R is special
and allows you to zoom in or out in case you wish to do so. Normally this
is not necessary, since the program autoadjusts to the settings, so that
the picture is always fully visible and as big as possible.
=head1 GUI
The general layout of the program has three parts:
=over 4
=item 1
In the left upper corner is the drawing board - showing the result of the Harmonograph.
=item 2
The whole right half of the window contains the settings, which guide the drawing operation.
These are divided into six tabs, which will be explained in detail below.
=item 3
In the lower left corner are two rows of buttons. The first row contains
only the progress bar and the I<Draw> button for drawing a full picture.
The progress bar remains white whily previe sketches are shown. But when
a full picture is drawn, then it gets filled with colors that reflect
the color flow used while drawing.
The second row of buttons allow the mass production of graphic files
without using the menu. That is explained in detail under L</Commands>.
=back
Please mind the tool tips - short help texts which appear if the mouse
stands still over a widgets. Also helpful are messages in the
status bar at the bottom - on bottom left regarding current state of the image
and bottom right about state of the settings. Settings are all the
parameters that guide the drawing. You change them via widgets controls
on the right side. They can be saved and loaded from a file via the
settings menu. Configuration are the general settings of this program,
which are mostly saved colors and paths were to store images and settings.
When browsing the main menu, help texts about the highlighted item
also appears in the status bar. The Menu can be completely navigated with
the keyboard. Just hold Alt and use the direction keys (up, down, left
and right) or the highlighted letters. When holding the Alt key you can
also see which Alt + letter combinations trigger which button.
=head2 Pendulum
=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Harmonograph/main/examples/POD/Tab_Pendulum.png" alt="" width="85%" height="85%">
</p>
Each of the first three tabs contains the settings of two pendula.
The first tab holds the lateral or linear pendula: X (left right movement)
and Y (up and down). The second tab shows settings of the epicycle pendula
E (left right) and F (up down). They also just move in x or y direction,
but they swing not around the center of the image but around the point,
where the pencil would have been. The third tab allows you to tweak
the pendula W (wobble) and R (rotation). W moves the center of the paper
beneath the pencil in a rotating manner whereas R rotates the paper
around its center. Each of these 6 pendula have the exact same settings
which behave all the same, except radius of R, which works as a zoom.
In the left upper corner of each pendulum settings is a checkbox to
activate or deactivate the pendulum - good to see the pendulums part
in the pen movement. The rest is organized in 8 rows, which can be divided
into 3 parts. Row 1 - 4 are about the pendulum frequency in Hertz.
Row five allows you set the starting point (offset) and the last 3 rows
are about the radius or amplitude of the pendulum mirroring the rows
1, 3 and 4 because the work exactly the same way just not for the
frequency but the radius parameter.
Row one sets the whole number part of the frequency. This is the part you
need to generate to generate the famous images which are based on integer
rations. You can either use the slider the + an - buttons or insert a
number into the text field (which is true off all slider combo widgets).
Behind the slider combo in row one is a drop down menu which lets you
choose a natural constant like Pi or Phi. It gets multiplied with the
frequency. This allows you to explore the nature of these famous constants.
Among the constants are also the natural numbers 1, 2 and 3 in case you
need to crank up the frequency up to 300.
The second row enables you to set values with three decimals. If you for
instance choose a base frequency of 5 and dial in 15 in the second row,
the actual frequency will be 5.015 times the natural constant. Behind the
slider are two checkboxes. One to additionally invert (1/x) the frequency
value and one to flip the pendulum direction (f = -f).
The third row lets you dial in a damping value which makes the pendulum
each round slower (bigger value -> more damping). Behind it is a selector.
If its on minus the damping will be same each round but set on "*" the
damping will be proportional to the frequency. Still behind it is a
checkbox. When selected the frequency is allowed to become negative by
damping.
The fourth row is about daming acceleration or with other words, how much
the damping changes from dot to dot. Beside the c value you have
this time four types of acceleration. Minus and times work as before
and plus and divided by are just their opposite.
The fifth row has a slider that sets the starting position of the
lib/App/GUI/Harmonograph.pm view on Meta::CPAN
around.
The third section below that displays the colors than can be used to draw
the picture. They are ten colors, numbered from left to right. Below
each color field there is a second rectangle showing the status of the
color. If this rectangle is empty, the status is normal (used). If it's
crossed out, them the color is inactive because in the visual settings
you choose to use less than ten colors. The third option is selected
color. To select a color, just click on the rectangle displaying that
color or the status rectangle below. Then the status will show an arrow
down.
This means the section below displays the values of this color.
And the values can also be changed there. First your have the I<red> (R),
I<green> (G) and I<blue> (B) values of the RGB color space. below that
are ones of HSB: I<hue>, I<saturation> and I<lightness>. These are more
meaningful to the human mind. At the right end of each row that shows
amd changes one color value is a button with a question mark. Push
that to randomize this one value.
The last and fifth section is analogous to the first one. It is a store
for your favorite single colors. Just load and safe the currently selected
color via the buttons. Be again cautious with the C<Del> button.
=head2 Commands
In the lower left corner are two rows of command buttons. All other
commands are in the menu.
The lower left part of the window contains buttons in two rows.
The upper row is just for drawing the complete image. It has a progress
bar and the draw button. If the progress bar is white, you see just a sketch
drawing - a preview of the full image that can be computed fast enought
to react to all setting changes. If you push the draw button (or <Ctrl>+<S>),
you will get a full image and the progress bar has the color of the drawing
and also can show you the color progression over time, so you can see,
which are the early and the later parts of the drawing.
The second button row is for easy mass production of drawings.
The three text fields are combined the parts of the file path.
The first text field is naturally the directory where the files get saved.
You can change it by pushing the I<Dir> in front (left) of the text button
and use the then opening Dir-Dialog to select another directory.
The second text field holds the base file name, which has to be inserted
by clicking on in and typing. The third text field is the file number and
is readonly. That counter increments automatically when a file is generated.
The complete file path is <dir>+<base name>+'_'+<counter>+<file ending>.
The file ending is I<.ini> for setting files and I<.jpg> or I<.png> or I<.svg>
for image files. The exact ending depends on what is the current configuration
set in the image > format menu. Lets say your directory is
"/home/user/images/h" and the base file name is beauty. If there is already
a file "/home/user/images/h/beauty_4.png" - the program will detect that
and set the counter to 5. You can play with the settings and than (no matter
if there is currently a complete drawing or not) push the I<Save> button
to produce a complete drawing into "/home/user/images/h/beauty_5.png".
If you push the I<INI> button you safe the current settings into
"/home/user/images/h/beauty_5.ini". This file can later be loaded via
settings menu to restore the current state of all buttons in the tabs.
=head2 Menu
The upmost menu bar has only three very simple menus.
Please not that each menu shows which key combination triggers the same
command and while hovering over an menu item you see a short help text
the left status bar field.
The first menu is for loading and storing setting files with arbitrary
names. I recommend giving them the file ending C<.ini> for transparency
reasons. A submenu allows a quick load of the recently used files.
The first entry lets you reset the whole program to the starting state
and the last is just to exit (safely with saving the configs).
The second menu has only two commands for drawing an complete image
and saving it in an arbitrary named PNG, JPG or SVG file (the file ending decides).
The submenu above only sets the preferred format, which is the format
of the serially save images by the command buttons in the left lower corner.
The preferred file format is also the first wild card in the save dialog.
Above that is another submenu for setting the image size.
The third menu has only one item to oben the I<about> - dialog,
where you can see which perl, Wx and other versions you are currently using.
=head1 SEE ALSO
L<App::GUI::Cellgraph>
L<App::GUI::Juliagraph>
L<App::GUI::Sierpingraph>
L<App::GUI::Spirograph>
=head1 AUTHOR
Herbert Breunung (lichtkind@cpan.org)
=head1 COPYRIGHT & LICENSE
Copyright(c) 2022-25 by Herbert Breunung
All rights reserved.
This program is free software and can be used, changed and distributed
under the GPL 3 licence.
=cut
( run in 1.821 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )