======== Assorted ======== .. |dash| unicode:: U+2014 .. EM DASH SIGN These examples are meant to demonstrate the type of output you can expect to create with **protograf**. They are *not* meant to be exhaustive or comprehensive! Bear in mind that the images shown in these examples are lower-resolution screenshots; the original PDFs that can be generated from the source scripts will demonstrate full scalability. .. _table-of-contents-exvar: - `A Clock`_ - `Chords`_ - `Rondel`_ - `Compass Rose`_ - `Miscellaneous Things 1`_ - `Miscellaneous Things 2`_ - `Miscellaneous Things 3`_ - `Process Flow Diagram`_ - `World Clocks`_ A Clock ======= `↑ `_ =========== ================================================================== Title *A Wall Clock* ----------- ------------------------------------------------------------------ Script `clock.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to create a complex element - a clock - by combining :ref:`multiple Circles `, each with different properties. Only the first circle |dash| the clock's outline border and its title |dash| has a *fill* color set but the rest do not: .. code:: python Circle( cx=3, cy=4.5, radius=2.5, stroke_width=6, label="PROTO", label_size=6, label_my=1) The other circles - which each have a *fill* color of ``None`` so as to be transparent - make use of the *radii* property to draw some aspect of the clock, for example the hour marks: .. code:: python Circle( cx=3, cy=4.5, radius=2.3, stroke="white", fill=None, radii=steps(0, 360, 30), radii_stroke_width=1.5, radii_length=0.3, radii_offset=2.2) Here the setting of various *radii_* properties allows the marks to be generated. Of interest is the use of the :ref:`steps() ` function to create the list of angles needed to specify where the offset radii used for the hours are to be drawn. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/clock.png :width: 50% =========== ================================================================== Miscellaneous Things 1 ====================== `↑ `_ =========== ================================================================== Title *Miscellaneous Things #1* ----------- ------------------------------------------------------------------ Script `objects.py `_ ----------- ------------------------------------------------------------------ Discussion The first page of this set of examples shows how to construct various "compound" shapes by making use of special properties of different shapes. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/objects_1.png :width: 90% =========== ================================================================== Miscellaneous Things 2 ====================== `↑ `_ =========== ================================================================== Title *Miscellaneous Things #2* ----------- ------------------------------------------------------------------ Script `objects.py `_ ----------- ------------------------------------------------------------------ Discussion The second page of this set of examples shows how to construct various "compound" shapes by making use of special properties of different shapes. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/objects_2.png :width: 90% =========== ================================================================== Miscellaneous Things 3 ====================== `↑ `_ =========== ================================================================== Title *Miscellaneous Things #3* ----------- ------------------------------------------------------------------ Script `objects.py `_ ----------- ------------------------------------------------------------------ Discussion The third page of this set of examples shows how to construct various "compound" shapes by making use of special properties of different shapes. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/objects_3.png :width: 90% =========== ================================================================== Chords ====== `↑ `_ =========== ================================================================== Title *Chords (in a circle)* ----------- ------------------------------------------------------------------ Script `large_objects.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to construct a simple effect by combining a basic shape |dash| a :ref:`Chord ` |dash| with a Python loop: .. code:: python for i in range(0, 200): Chord(shape=Circle( cx=2, cy=2, radius=2, fill=None), angle=Random(360), angle1=Random(360)) Here the ``for`` loop runs for 200 times. Each time it does so, the :ref:`Random() ` command generates a random value between 1 and 360 i.e. corresponding to degrees around a circle, to assign to the Chord's start and end points; then each Chord is drawn as usual. Also see :ref:`Python loops ` for more details. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/chords.png :width: 40% =========== ================================================================== Compass Rose ============ `↑ `_ =========== ================================================================== Title *Compass Rose (circles and stars)* ----------- ------------------------------------------------------------------ Script `large_objects.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to construct the effects of a compass by overlapping :ref:`Stars ` onto :ref:`Circles ` .. code:: python Font("Times-Italic", size=14) eye = Common(cx=2, cy=3) Circle( common=eye, radius=2, stroke_width=1, fill=None, radii=steps(0, 360, 5), radii_offset=1.85, radii_length=0.1, radii_stroke_width=1, heading="N") Circle( common=eye, radius=1.2, stroke_width=1, fill=None) Star( common=eye, radius=1.4, rays=4, show_radii=True, rotation=45, stroke_width=1, slices=["black", "white"], radii_stroke_width=1, inner_fraction=0.25, ) Star(common=eye, radius=2.2, rays=4, inner_fraction=0.25, stroke_width=1, slices=["black", "white"], ) ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/compass_rose.png :width: 50% =========== ================================================================== Rondel ====== `↑ `_ =========== ================================================================== Title *Rondel (circle radii and sectors)* ----------- ------------------------------------------------------------------ Script `large_objects.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to construct a simple effect by using data from a Python loop combined with *radii labels*: .. code:: python circ = Common(cx=2, cy=3, radius=2) # information needed radii = list(range(0, 360, 60)) colrs = [ "lightsteelblue", "cyan", "gold", "chartreuse", "tomato", "white", ] labels = [ 'Build', 'Trade', 'Income', 'Plant', 'Explore', 'Harvest'] # rondel colors for colr, angle in zip(colrs, radii): Sector( common=circ, fill=colr, stroke="sienna", stroke_width=2, angle_start=angle - 30, angle_width=60) # rondel text Circle( common=circ, stroke="#A0522D", stroke_width=3, fill=None, radii=radii, radii_offset=0.75, radii_length=1, radii_stroke_width=0.01, radii_labels=labels, radii_labels_font="Times-Roman", dot=0.2) In this example, using the "offset" for the radii allows the label |dash| which is centred on the radius line |dash| to be moved further outward. Also see :ref:`Python loops ` for more details. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/rondel.png :width: 50% =========== ================================================================== Process Flow Diagram ==================== `↑ `_ =========== ================================================================== Title *Process Flow Diagram* ----------- ------------------------------------------------------------------ Script `processflow.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to construct a diagram by drawing a series of :ref:`Rectangles ` with :ref:`Text ` as part of a Python function. These Rectangles are then connected by :ref:`Lines ` via the *link* property of each line. Part of the function looks like: .. code:: python def draw_step(x, y, title, detail): box = Rectangle( x=x, y=y, width=5, height=4, stroke_width=1, rounded=True) It can be seen that the location of the Rectangle will depend on the *x* and *y* values supplied to the function when it is used. The function is used as follows: .. code:: python step1 = draw_step( x=1, y=5, title="User Details", detail="
  • Fill out form
  • Submit form
  • ") Also see :ref:`Python function ` for more details on how to construct a function. The connecting lines are drawn as follows: .. code:: python Line(links=[ (step1, "p", "e"), (step2, "p", "w")], stroke_width=1, dot=0.1, arrow=True) For more detail about links, see the :ref:`customised Line ` section. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/demo/process_flow_diagram.png :width: 80% =========== ================================================================== World Clocks ============ `↑ `_ =========== ================================================================== Title *World Clocks* ----------- ------------------------------------------------------------------ Script `world_clocks.py `_ ----------- ------------------------------------------------------------------ Discussion This example shows how to reuse a complex element |dash| a clock |dash| by means of a set of Python functions; see :ref:`Python functions ` for more details. This is a fairly complex script |dash| a mini program really |dash| which is likely only to be legible to a Python programmer! It's probably far beyond the scope of this library's intended use... The script essentially "wraps" the clock creation approach described above into a function which is accessed for each city, or place, whose clock should be displayed. The script also uses other functions to calculate the position of the clock hands based on the current time of the day; this is a bit fiddly because the hour hand angle changes in relation to the number of minutes. The clock face and the hand colors are changed depending on the day/night and light/dark cycles. Further ideas: - Wrap a call to this script via a command that gets runs each minute e.g. via ``cron`` on Linux; this will produce an updated image of times which could be displayed automatically on screen by a suitable viewer. - Add a link to an API that generates quotes; use this quote for the header text so that a new quote appears each time the script is run. ----------- ------------------------------------------------------------------ Screenshot .. image:: images/various/world_clocks.png :width: 90% =========== ==================================================================