From 41ceec5955e198ba71fb94bdfd0b6702347c67b7 Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Fri, 11 Dec 2015 22:16:50 +0100 Subject: [PATCH] Updating documentation and examples with new core namespaces --- doc/build/html/Makefile.am | 1 + doc/parts/bindings/{predicates.sxml => 3D.sxml} | 24 +- .../{predicates.sxml => constructors.sxml} | 25 +- .../bindings/{predicates.sxml => functions.sxml} | 27 +- doc/parts/bindings/{predicates.sxml => hot.sxml} | 26 +- doc/parts/bindings/{predicates.sxml => misc.sxml} | 23 +- doc/parts/bindings/predicates.sxml | 17 - .../bindings/{predicates.sxml => simple.sxml} | 24 +- .../bindings/{predicates.sxml => syntax.sxml} | 23 +- doc/parts/bindings/types.sxml | 31 - .../predicates.sxml => dynamic/continuations.sxml} | 26 +- .../predicates.sxml => dynamic/graphic.sxml} | 23 +- doc/parts/dynamic/handlers.sxml | 8 - .../predicates.sxml => dynamic/misc.sxml} | 23 +- .../predicates.sxml => dynamic/text.sxml} | 23 +- .../Applications-Blockdraw-blockdraw.sxml | 6 +- .../extensions/Shapes-Graphics3D-arrowheads.sxml | 2 +- doc/parts/index/chap-notation.sxml | 2 +- doc/parts/namespace-toc/index.sxml | 1 + doc/parts/namespace/Shapes-Data-Type.sxml | 36 + doc/parts/namespace/Shapes-Data.sxml | 229 +++++ doc/parts/namespace/Shapes-Debug.sxml | 115 ++- doc/parts/namespace/Shapes-Geometry.sxml | 1045 +++++++++++++++++++- doc/parts/namespace/Shapes-Geometry3D.sxml | 234 +++++ doc/parts/namespace/Shapes-Graphics-Tag.sxml | 165 ++++ doc/parts/namespace/Shapes-Graphics.sxml | 374 +++++++ doc/parts/namespace/Shapes-Graphics3D.sxml | 163 +++ doc/parts/namespace/Shapes-IO.sxml | 3 + doc/parts/namespace/Shapes-Layout.sxml | 64 ++ doc/parts/namespace/Shapes-Numeric-Math.sxml | 420 ++++++++ doc/parts/namespace/Shapes-Numeric-Random.sxml | 11 + doc/parts/namespace/Shapes-String.sxml | 41 + doc/parts/namespace/Shapes-Text-Font.sxml | 117 +++ doc/parts/namespace/Shapes-Text.sxml | 213 ++++ doc/parts/namespace/Shapes-Traits-BW.sxml | 30 + doc/parts/namespace/Shapes-Traits-Blend.sxml | 125 +++ doc/parts/namespace/Shapes-Traits-Cap.sxml | 29 + doc/parts/namespace/Shapes-Traits-Device.sxml | 29 + doc/parts/namespace/Shapes-Traits-Join.sxml | 29 + doc/parts/namespace/Shapes-Traits-Light.sxml | 2 +- doc/parts/namespace/Shapes-Traits-RGB.sxml | 69 ++ doc/parts/namespace/Shapes-Traits.sxml | 240 ++++- doc/parts/namespace/Shapes.sxml | 171 +++- doc/parts/state-types/containers.sxml | 38 +- doc/parts/states/index.sxml | 2 - .../{bindings/predicates.sxml => states/misc.sxml} | 22 +- doc/parts/syntax/atoms.sxml | 2 +- doc/parts/syntax/compound.sxml | 8 +- doc/parts/syntax/misc.sxml | 2 +- doc/parts/syntax/namespaces.sxml | 2 +- doc/parts/tutorial/chap-basics.sxml | 12 +- doc/parts/tutorial/chap-hello.sxml | 4 +- doc/parts/tutorial/chap-paths.sxml | 10 +- doc/parts/types/composite.sxml | 2 +- doc/parts/types/index.sxml | 2 +- doc/parts/types/text.sxml | 8 +- examples/applications/double-pendulum.shape | 38 +- examples/applications/doughnut.shape | 25 +- examples/applications/droo.shape | 22 +- examples/applications/logo.shape | 44 +- examples/applications/pinhole.shape | 99 +- examples/applications/single-pendulum.shape | 18 +- examples/applications/spacebase-cross.shape | 35 +- examples/applications/spacebase.shape | 35 +- examples/applications/vild.shape | 6 +- examples/doc/blockdraw-blocks.shape | 26 +- examples/doc/blockdraw-con-points.shape | 116 +-- examples/doc/blockdraw-connections-connect.shape | 18 +- .../doc/blockdraw-connections-intermediate.shape | 40 +- examples/doc/blockdraw-connections-primitive.shape | 26 +- examples/doc/blockdraw-labels.shape | 38 +- examples/doc/blockdraw-layout.shape | 38 +- examples/doc/blockdraw-tutorial-conpoint.shape | 10 +- examples/doc/blockdraw-tutorial-hello.shape | 2 +- examples/doc/blockdraw-tutorial-labels.shape | 32 +- examples/doc/blockdraw-tutorial-layout.shape | 70 +- examples/doc/blockdraw-tutorial-relative.shape | 4 +- examples/doc/bondgraph-bonds.shape | 14 +- examples/doc/bondgraph-junctions.shape | 22 +- examples/doc/bondgraph-labels.shape | 16 +- examples/doc/bondgraph-termbonds.shape | 20 +- examples/doc/clip-text.shape | 30 +- examples/doc/clip-winding-rule.shape | 4 +- examples/doc/clipodd-winding-rule.shape | 4 +- examples/doc/encapsulation-namespace.blank | 6 +- examples/doc/fill-winding-rule.shape | 2 +- examples/doc/fillodd-winding-rule.shape | 4 +- examples/doc/lexiographicSort.shape | 42 +- examples/doc/namespace-aliases.blank | 16 +- examples/doc/private-namespace.blank | 16 +- examples/doc/remainders.shape | 166 ++++ examples/doc/schur.blank | 39 +- examples/doc/single-file-module.shext | 4 +- examples/doc/structure-oneliner.shape | 2 +- examples/doc/structure-text.shape | 2 +- examples/doc/structure-typical.shape | 6 +- examples/doc/tex-quotes.shape | 6 +- .../doc/tutorial-approximator-intersection.shape | 16 +- examples/doc/tutorial-approximator.shape | 14 +- examples/doc/tutorial-bezier-connected.shape | 100 +- examples/doc/tutorial-graphics-params.shape | 38 +- examples/doc/tutorial-intersection.shape | 21 +- examples/doc/tutorial-maximizer.shape | 20 +- examples/doc/tutorial-one-segment.shape | 22 +- examples/doc/tutorial-path-approximator.shape | 16 +- examples/doc/tutorial-path-painting.shape | 10 +- examples/doc/tutorial-slider-use.shape | 114 +-- examples/doc/tutorial-subpath-intersection.shape | 18 +- examples/doc/tutorial-transforms.shape | 4 +- examples/doc/tutorial-view.shape | 111 +-- examples/doc/winding-numbers.shape | 12 +- examples/doc/winding-rule-paths.shext | 37 +- examples/features/amb.blank | 36 +- examples/features/annotations.shape | 19 +- examples/features/approximators.shape | 30 +- examples/features/approximators3d.shape | 65 +- examples/features/arclength.shape | 25 +- examples/features/argument.shape | 24 +- examples/features/array.shape | 12 +- examples/features/arrowdemo.shape | 28 +- examples/features/asymmetric-notation.shape | 12 +- examples/features/basic3d.shape | 21 +- examples/features/bendtext.shape | 14 +- examples/features/bleed.shape | 10 +- examples/features/blend.shape | 22 +- examples/features/boxedeq.shape | 2 +- examples/features/characters.shape | 16 +- examples/features/clipping.shape | 6 +- examples/features/colorinterpolator.shape | 18 +- examples/features/cond-impl.blank | 28 +- examples/features/cornerpoint.shape | 18 +- examples/features/curry.blank | 8 +- examples/features/curvature.shape | 10 +- examples/features/data-strings.blank | 2 +- examples/features/distance.shape | 8 +- examples/features/distance3d.shape | 13 +- examples/features/dynamic.blank | 42 +- examples/features/error.blank | 16 +- examples/features/escape.blank | 12 +- examples/features/evalorder.blank | 18 +- examples/features/facefun.shape | 27 +- examples/features/folds.blank | 32 +- examples/features/fontmeterdemo.shape | 20 +- examples/features/formresources.shape | 19 +- examples/features/glyph-outline.shape | 14 +- examples/features/hulls.shape | 14 +- examples/features/if.blank | 6 +- examples/features/imports.shape | 6 +- examples/features/intersections-other.shape | 26 +- examples/features/intersections.shape | 58 +- examples/features/latin1.shape | 2 +- examples/features/lightdemo.shape | 15 +- examples/features/lightdemo2.shape | 19 +- examples/features/lightdemo3.shape | 19 +- examples/features/lightdemo3b.shape | 19 +- examples/features/multipage.shape | 29 +- examples/features/myfontdemo.shape | 20 +- examples/features/namespaces.blank | 36 +- examples/features/needs.blank | 2 +- examples/features/opacity.shape | 6 +- examples/features/orthogonal.blank | 13 +- examples/features/paint3d.shape | 7 +- examples/features/pathconstruction.shape | 6 +- examples/features/png_array.shape | 90 +- examples/features/random.shape | 17 +- examples/features/ranges.blank | 14 +- examples/features/raster_jpeg.shape | 10 +- examples/features/raster_png.shape | 18 +- examples/features/remove.shape | 20 +- examples/features/rotations.shape | 19 +- examples/features/rotlabel.shape | 13 +- examples/features/scopes.blank | 12 +- examples/features/shapesarrow-parameters.shape | 202 ++-- examples/features/shortcut.blank | 12 +- examples/features/show.blank | 29 +- examples/features/sidepaths.shape | 39 +- examples/features/sliders.shape | 31 +- examples/features/softmask.shape | 20 +- examples/features/speedtest.shape | 12 +- examples/features/states.blank | 20 +- examples/features/static_errors.blank | 6 +- examples/features/streams.blank | 22 +- examples/features/strokes.shape | 6 +- examples/features/subpaths.shape | 21 +- examples/features/svg_path.shape | 6 +- examples/features/tagtest.shape | 8 +- examples/features/textmodes.shape | 8 +- examples/features/tiebreakers.shape | 13 +- examples/features/transforms.blank | 10 +- examples/features/unicode.blank | 4 +- examples/features/units.shape | 4 +- examples/features/upsample.shape | 253 ++--- examples/features/values.blank | 48 +- examples/features/warm.blank | 16 +- examples/features/warm2D.shape | 18 +- examples/features/winding-numbers-color.shape | 14 +- examples/features/zbufdemo.shape | 17 +- examples/features/zbuflightdemo.shape | 19 +- examples/features/zbuflines.shape | 21 +- examples/features/zsorterdemo.shape | 17 +- examples/misc/crazy.shape | 2 +- examples/misc/gustafblend.shape | 12 +- examples/misc/sphere.shape | 3 +- examples/problems/choose.shape | 4 +- examples/showcase/blendarrows.shape | 8 +- examples/showcase/blockdrawdemo.shape | 54 +- examples/showcase/bonddemo.shape | 120 +-- examples/showcase/bracedemo.shape | 8 +- examples/showcase/circuitdemo.shape | 28 +- examples/showcase/fig2_11.shape | 32 +- examples/showcase/fig2_2a.shape | 38 +- examples/showcase/fourcolordie.shape | 21 +- examples/showcase/kjmrobot.shape | 121 +-- examples/showcase/koch.shape | 12 +- examples/showcase/mergepaths.shape | 34 +- examples/showcase/stereo.shape | 8 +- examples/showcase/valve.shext | 10 +- .../Applications/Blockdraw/blockdraw.shext | 36 +- .../Applications/Blockdraw/bondgraph.shext | 40 +- .../extensions/Applications/Circuit/parts.shext | 12 +- resources/extensions/Shapes/Control/cond.shext | 4 +- resources/extensions/Shapes/Geometry/circle.shext | 6 +- .../extensions/Shapes/Geometry/pathmapping.shext | 8 +- .../extensions/Shapes/Geometry3D/circle.shext | 4 +- .../extensions/Shapes/Graphics/arrowheads.shext | 6 +- resources/extensions/Shapes/Graphics/braces.shext | 14 +- .../extensions/Shapes/Graphics/elementary.shext | 6 +- .../extensions/Shapes/Graphics/metapostarrow.shext | 12 +- .../extensions/Shapes/Graphics/shapesarrow.shext | 22 +- .../extensions/Shapes/Graphics3D/arrowheads.shext | 44 +- .../extensions/Shapes/Graphics3D/elementary.shext | 26 +- .../Shapes/Graphics3D/metapostarrow.shext | 12 +- .../Shapes/Graphics3D/revolutionbody.shext | 40 +- .../extensions/Shapes/Layout/basic-layout.shext | 23 +- .../extensions/Shapes/Layout/centering-X.shext | 2 +- resources/extensions/Shapes/Layout/shiftoff.shext | 20 +- .../Shapes/Numeric/Constant/constants.shext | 2 +- source/astvar.cc | 2 +- source/consts.cc | 6 +- source/consts.h | 2 +- source/coreast.cc | 2 +- source/coreconstruct.cc | 6 +- source/coredecomp.cc | 2 +- source/coremisc.cc | 6 +- source/globals.cc | 6 +- source/hottypes.cc | 2 +- source/testers/dist.cc | 4 +- test/graphics/approximate2d.shape | 10 +- test/graphics/bad.shape | 2 +- test/graphics/dyn-thunk.shape | 144 +-- test/graphics/hello.shape | 2 +- test/graphics/texlabel.shape | 10 +- test/text/bad.shape | 2 +- test/text/dynamic.shape | 4 +- test/text/scopes.shape | 10 +- 255 files changed, 6551 insertions(+), 2703 deletions(-) copy doc/parts/bindings/{predicates.sxml => 3D.sxml} (70%) copy doc/parts/bindings/{predicates.sxml => constructors.sxml} (67%) copy doc/parts/bindings/{predicates.sxml => functions.sxml} (67%) copy doc/parts/bindings/{predicates.sxml => hot.sxml} (67%) copy doc/parts/bindings/{predicates.sxml => misc.sxml} (70%) copy doc/parts/bindings/{predicates.sxml => simple.sxml} (70%) copy doc/parts/bindings/{predicates.sxml => syntax.sxml} (69%) copy doc/parts/{bindings/predicates.sxml => dynamic/continuations.sxml} (65%) copy doc/parts/{bindings/predicates.sxml => dynamic/graphic.sxml} (67%) copy doc/parts/{bindings/predicates.sxml => dynamic/misc.sxml} (70%) copy doc/parts/{bindings/predicates.sxml => dynamic/text.sxml} (67%) create mode 100644 doc/parts/namespace/Shapes-Graphics-Tag.sxml copy doc/parts/{bindings/predicates.sxml => states/misc.sxml} (70%) rewrite examples/doc/blockdraw-con-points.shape (60%) create mode 100644 examples/doc/remainders.shape rewrite examples/features/upsample.shape (68%) rewrite examples/showcase/bonddemo.shape (66%) rewrite test/graphics/dyn-thunk.shape (88%) diff --git a/doc/build/html/Makefile.am b/doc/build/html/Makefile.am index 5aae5f13..d5b196ca 100644 --- a/doc/build/html/Makefile.am +++ b/doc/build/html/Makefile.am @@ -74,6 +74,7 @@ EXTRA_html_FILES = \ Shapes-Geometry3D.html \ Shapes-Graphics.html \ Shapes-Graphics-PDF.html \ + Shapes-Graphics-Tag.html \ Shapes-Graphics3D.html \ Shapes-IO.html \ Shapes-Layout.html \ diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/3D.sxml similarity index 70% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/3D.sxml index 77a89ed4..45b1bb64 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/3D.sxml @@ -15,27 +15,13 @@ -
-Predicates +
+<str-3D /> related stuff -

Predicates are simple functions that test certain conditions.

+

The bindings that are related to are kept aside in this section, so that users not interested in graphics can safely choose not to read this section.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
+ +
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/constructors.sxml similarity index 67% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/constructors.sxml index 77a89ed4..8592ee1b 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/constructors.sxml @@ -13,29 +13,12 @@ - + -
-Predicates +
+Constructors -

Predicates are simple functions that test certain conditions.

+

This section contains simple functions that are essential for the creation of values of certain types.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/functions.sxml similarity index 67% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/functions.sxml index 77a89ed4..ec5d9aac 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/functions.sxml @@ -13,29 +13,16 @@ - + -
-Predicates +
+Functions -

Predicates are simple functions that test certain conditions.

+

These are the functions!

+ +

After all, is a special-purpose language aimed at the production of graphics. Hence, functions for path drawing, creation of affine transforms, and path computations are a very important part of the language.

+
- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/hot.sxml similarity index 67% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/hot.sxml index 77a89ed4..de10be21 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/hot.sxml @@ -13,29 +13,15 @@ - + -
-Predicates +
+Hot values -

Predicates are simple functions that test certain conditions.

+

States stem from hot values. The system provides a few, all of which are important because the efficiency enhancements they bring. What you find here is basically just a bunch of links to where the corresponding state types are described.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
+
+ diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/misc.sxml similarity index 70% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/misc.sxml index 77a89ed4..03516c74 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/misc.sxml @@ -15,27 +15,10 @@ -
-Predicates +
+Miscellaneous -

Predicates are simple functions that test certain conditions.

+

Standard stream objects, null objects, mathematical constants, and more…

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/predicates.sxml index 77a89ed4..a939e5b1 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/predicates.sxml @@ -21,21 +21,4 @@

Predicates are simple functions that test certain conditions.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/simple.sxml similarity index 70% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/simple.sxml index 77a89ed4..61d8ae9f 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/simple.sxml @@ -15,27 +15,11 @@ -
-Predicates +
+Simple values -

Predicates are simple functions that test certain conditions.

+

These bindings give access to many named constants that either serve as special tokens in certain situations, or simply deserve a binding due to their common use or special meaning.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
-
+ diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/bindings/syntax.sxml similarity index 69% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/bindings/syntax.sxml index 77a89ed4..199e88da 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/bindings/syntax.sxml @@ -15,27 +15,6 @@ -
-Predicates - -

Predicates are simple functions that test certain conditions.

-
- - - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
+
diff --git a/doc/parts/bindings/types.sxml b/doc/parts/bindings/types.sxml index 82859f08..bc37cb86 100644 --- a/doc/parts/bindings/types.sxml +++ b/doc/parts/bindings/types.sxml @@ -18,37 +18,6 @@
Types -

At the time of writing, only a few types are directly accessible to the user; while other types are hidden, knowledge of them will still help understanding the language. When, a binding exist, it will have the same identifier as is used to refer to the type abstractly in the documentation. Types in the list below are represented with a global binding:

-
    -
  • -
  • - -
  • -
  • -
  • -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • -
  • -
  • -
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/dynamic/continuations.sxml similarity index 65% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/dynamic/continuations.sxml index 77a89ed4..5bda2aa7 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/dynamic/continuations.sxml @@ -13,29 +13,5 @@ - + -
-Predicates - -

Predicates are simple functions that test certain conditions.

-
- - - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
- -
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/dynamic/graphic.sxml similarity index 67% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/dynamic/graphic.sxml index 77a89ed4..2e2e8f3c 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/dynamic/graphic.sxml @@ -13,29 +13,12 @@ - + -
-Predicates +
+Graphics -

Predicates are simple functions that test certain conditions.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
diff --git a/doc/parts/dynamic/handlers.sxml b/doc/parts/dynamic/handlers.sxml index 5e611b78..5c188c0e 100644 --- a/doc/parts/dynamic/handlers.sxml +++ b/doc/parts/dynamic/handlers.sxml @@ -21,12 +21,4 @@

The bindings in this section provide a way of controlling the behavior in error situations; a function may call a dynamically bound function bound function when an error is detected instead of returning with a nonsense result.

- - - -

To be called when the intersection between two paths cannot be found.

-

Shall take the two objects as arguments.

-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/dynamic/misc.sxml similarity index 70% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/dynamic/misc.sxml index 77a89ed4..94b096a9 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/dynamic/misc.sxml @@ -15,27 +15,10 @@ -
-Predicates +
+Other -

Predicates are simple functions that test certain conditions.

+

Any dynamic variable not mentioned so far goes here.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
-
diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/dynamic/text.sxml similarity index 67% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/dynamic/text.sxml index 77a89ed4..f9c58d5a 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/dynamic/text.sxml @@ -13,29 +13,12 @@ - + -
-Predicates +
+Text -

Predicates are simple functions that test certain conditions.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
diff --git a/doc/parts/extensions/Applications-Blockdraw-blockdraw.sxml b/doc/parts/extensions/Applications-Blockdraw-blockdraw.sxml index fc5e2122..5d8097b9 100644 --- a/doc/parts/extensions/Applications-Blockdraw-blockdraw.sxml +++ b/doc/parts/extensions/Applications-Blockdraw-blockdraw.sxml @@ -98,7 +98,7 @@

Depending on the relative layout of blocks, a varying degree of manual effort is needed to get the connecting paths right. In this example, all paths but the feed-back path can be deduced automatically using . The constructed path is both painted and returned. Most of the time the return value is ignored (by means of ), but it is useful when we want to place a label along the path. See for the complete set of functions for the purpose of making connections.

Putting a label along the connection is easy. To make the source code readable, it is a good idea to bind the connection path to a variable, and then use this variable when placing the label. Special purpose functions are provided to ensure a consistent layout of labels; the user need only select a point on the path (preferably using ) and a side of that point (by using the “putlabel-function” named accordingly), and how the label should be aligned.

-

Putting a label at a terminal point is similar to labeling a connection, the only difference is how the point to be labeled is selected. Note that for a , all connection point functions will return the same point.

+

Putting a label at a terminal point is similar to labeling a connection, the only difference is how the point to be labeled is selected. Note that for a , all connection point functions will return the same point.

This example also shows how to place signs at connection points, and how to indicate a point where a signal splits by a small dot.

This is a comparatively simple figure, containing three different kinds of objects: blocks, connections and annotations along the connections. This example also follows the good habit to let preferences that might be shared by several figures be extracted into a separate file ("$(BASE)$(EXAMPLES)doc/blockdraw-tutorial-tut-prefs.shext">link).

@@ -299,7 +299,7 @@ - [stroke head:ShapesArrow ...] + [..Shapes..Graphics..stroke head:..Shapes..Graphics..ShapesArrow ...] @@ -317,7 +317,7 @@ - + diff --git a/doc/parts/extensions/Shapes-Graphics3D-arrowheads.sxml b/doc/parts/extensions/Shapes-Graphics3D-arrowheads.sxml index 5c5fa5ca..cf168120 100644 --- a/doc/parts/extensions/Shapes-Graphics3D-arrowheads.sxml +++ b/doc/parts/extensions/Shapes-Graphics3D-arrowheads.sxml @@ -23,7 +23,7 @@ ..Shapes..Graphics3D arrowheads -

Functions that define arrowheads for use with .

+

Functions that define arrowheads for use with .

diff --git a/doc/parts/index/chap-notation.sxml b/doc/parts/index/chap-notation.sxml index 6918571a..225bafdc 100644 --- a/doc/parts/index/chap-notation.sxml +++ b/doc/parts/index/chap-notation.sxml @@ -30,7 +30,7 @@ Example code [stroke pth head:someArrow] No syntax highlighting of code elements. - Binding (a “variable”) or state , + Binding (a “variable”) or state , Formal parameter , Filename hello.shape Replacable dito filename.shape diff --git a/doc/parts/namespace-toc/index.sxml b/doc/parts/namespace-toc/index.sxml index 875b8be2..70c6c907 100644 --- a/doc/parts/namespace-toc/index.sxml +++ b/doc/parts/namespace-toc/index.sxml @@ -28,6 +28,7 @@ + diff --git a/doc/parts/namespace/Shapes-Data-Type.sxml b/doc/parts/namespace/Shapes-Data-Type.sxml index 296f14d2..6c2454a0 100644 --- a/doc/parts/namespace/Shapes-Data-Type.sxml +++ b/doc/parts/namespace/Shapes-Data-Type.sxml @@ -37,6 +37,42 @@

The language reflection of the core type system is incomplete, and the plan is to not develop it further. Instead, will be equipped with a proper type system and object-oriented features in the future. When these arrive, the content of this namespace is expected to change completely.

+

Anyway, the values that are currently found in this namespace are language reflections of types described in . For example, to check whether the value x is of type , do +

+      [typeof x] = ..Shapes..Data..Type..§Float
+    
+

+

Only a few types are directly accessible to the user; while other types are hidden, knowledge of them will still help understanding the language. When, a binding exists, it will have the same identifier as is used to refer to the type abstractly in the documentation. Types in the list below are represented with a binding:

+
    +
  • +
  • + +
  • +
  • +
  • +
  • +
  • +
  • +
  • + +
  • +
  • +
  • +
  • +
  • + +
  • +
  • +
  • +
  • + +
  • +
  • +
  • +
  • +
  • +
  • +
diff --git a/doc/parts/namespace/Shapes-Data.sxml b/doc/parts/namespace/Shapes-Data.sxml index de27b171..5b247933 100644 --- a/doc/parts/namespace/Shapes-Data.sxml +++ b/doc/parts/namespace/Shapes-Data.sxml @@ -39,4 +39,233 @@

It is not entirely clear at the moment how this namespace should be organized. Currently, there is not too much in here, but the plan is to equip with a type system and object-oriented features in the future, and then it may be more natural to use types rather than namespaces for organization. So, take this as a notice of subject to change, and read on!

+
+ Lists + + + + + + + + + + +

Constructs a list of the arguments.

+

The value created when called with no arguments is recognized by , and should be used as a null marker for lists.

+
+ +
+
+
+ + + + + + + + + + +

Converts a list to a structure, being the inverse of in the sense that +

+[unlist lst] )]]>
+
+is the identity for values, and +
+struct )]]]>
+
+is the identify for values without named parts.

+

Note how this function may be used to define a Scheme-like apply function: +

+[unlist args] )]]>
+
+

+
+ +
+
+
+ + + + + + + + + + + + + +

True if the argument is the empty .

+
+
+
+ + +
+ + +
+ Vectors + + + + + + + + + + +

Constructs a vector of the arguments.

+

The value created when called with no arguments is recognized by , and should be used as a null marker for lists.

+
+ +
+
+
+ + + + + + + + + +
+ + +
+ Miscellaneous + + + + + + + + + + +

Constructs a cons pair. The arguments are not forced, which allows infinite data structures to be defined.

+
+
+
+
+ + + + + + + + + + + + + + + + + + + +

Constructs a range of values. One of the arguments must be omitted, and it is forbidden to provide , , and at the same time. It is allowed to omit both and , in which case defaults to (a positive) 1.

+

See the case for the semantics of the various argument combinations, and notes on efficiency.

+
+
+ + + + + + + + + + + + + + + + +

Constructs a range of values. One of the arguments must be omitted. It is allowed to omit both and , in which case defaults to (a positive) 1.

+

If is provided, it determines the step length. If is provided, it determines the number of elements in the constructed range, which will begin at if is provided, and end at if is provided (note that achieving this using may be inconvenient or even difficult due to problems with numeric precision). If neither nor is provided, defaults to 1.

+

When both and are provided, the range starts at , and ends at a value with is not past . This is not like in , where end refers to a point in a range which itself is past the end of the range.

+

Note on efficiency: The result is constructed in constant time and space, and is particularly efficient for left folds. Semantically, it is as if the whole range was stored element by element in a long list, but the kernel just stores the first element, the step, and the total number of elements. During a left fold, at two values in the range are stored in memory at the same time. A right fold, on the other hand, will require all elements to be constructed before they can be destructed again. Hence, when possible, right folds should be avoided in favor of left folds over a range constructed with elements in the reverse order.

+
+
+ + + + + + + + + + + + + + + + +

Constructs a range of values. One of the arguments must be omitted, and it is forbidden to omit both and .

+

See the case for the semantics of the various argument combinations, and notes on efficiency.

+
+
+ + + +]]> + + +]]> + + + + +
+
+ + + + + + + + + + + +

Calling is like calling , except that the arguments may use the special expression to refer to the last position in a container. Since the container will generally not be known at the time of the call, the arguments are not evaluated immediately, but stored as thunks inside value.

+

Since a should be used to select ranges of valid container positions, there are more defaults available when calling compared to . For instance, a span including all but the first two positions in a container can be constructed as +

+
+
+and a span including all but the last two positions as +
+
+
+

+

Note that a value is not automatically expanded to whenever a is expected, so it is up to the methods of the container types to accept values and expand them.

+
+ + + +
+
+
+ + +
+ diff --git a/doc/parts/namespace/Shapes-Debug.sxml b/doc/parts/namespace/Shapes-Debug.sxml index 2d0c3348..47109091 100644 --- a/doc/parts/namespace/Shapes-Debug.sxml +++ b/doc/parts/namespace/Shapes-Debug.sxml @@ -22,7 +22,7 @@ ..Shapes..Debug -

Debugging utilities.

+

Debugging utilities and source code reflection.

<self /> @@ -39,4 +39,117 @@

Didn't get the result you expected? Maybe it's time to set a break point or add some debug prints. This is where you find the tools.

+
+ Source code reflection + + + + + + + + + + + + + + + + +

Mutates the value in order to associate it with the abstract syntax tree node of the argument passed to this function.

+
+ + + +
+
+
+ + + + + + + + + + + +

Returns the source code string determined by the abstract syntax tree node associated with the argument. The value needs to be properly prepared using .

+
+
+
+
+ + +
+ + +
+ Profiling + + + + + + + +

When the timer is frozen, it returns the time in seconds since its creation.

+
+
+
+ + +
+ + +
+ Interactive mode + +

The escape continuations in are not treated as dynamic variables, but they are nevertheless dynamically bound, which is why they are listed among the global dynamic variables. In the non-interactive mode of the compiler, there is only one globally available escape continuation, but there are some more available in the interactive mode.

+

See for more information on escape continuations in general.

+ + + + + +

Quit compiler.

+ + + + + + +

Described in . Only available in interactive mode.

+ + + +

The read-evaluate-print loop of the interactive mode.

+ + + +

Described in . Only available in interactive mode.

+ + + +

Resume program after break during interactive debugging.

+ depends on context +

Described in . Only available in debug context in interactive mode.

+ + + + + +

There is no global state. This piece of documentation is just here to guide readers to the documentation in .

+ + + + + + + +
+ + diff --git a/doc/parts/namespace/Shapes-Geometry.sxml b/doc/parts/namespace/Shapes-Geometry.sxml index 127ba8fb..68c87c6a 100644 --- a/doc/parts/namespace/Shapes-Geometry.sxml +++ b/doc/parts/namespace/Shapes-Geometry.sxml @@ -39,27 +39,1032 @@

The geometric objects in are coordinates and paths. This namespace is for operations within this class of objects. Once the geometric objects are painted (typically stroked or filled), they become graphical objects and are no longer under the topic of this namespace. Compare .

- +
+ Syntax equivalents + +

This section contains one dynamic variable, and a couple of functions which correspond directly to syntactic constructs. While most users should generally not use the functions directly, users interested in graphic design are strongly encouraged to get familiar with the dynamic variable.

+
+ - - - - - + + + 50cm + +

Default unit of unspecified radii of polar coordinates used in path construction. Typically, the unit is set to a special length rather than a fixed distance. See for details on special lengths.

+

It is not possible to refer to directly to the value of — the dynamic variable can be bound like any other dynamic variable, but will only be used implicitly during path construction.

+ + + + + + + + + + + + + + + + +

Implements .

+
+
+ + + + + + + + + + + +

Implements .

+

One of the arguments is allowed to be the special value zero, which is interpreted as a zero absolute length.

+
+
+
+
+ + + + + + + + + + + + + + + + + +

Implements .

+
+
+
+
+ + + + + + + + + + + +

Implements in the case when the modulus of the handle is not specified.

+
+
+
+
+ + + + + + + + +

Implements in the case when neither modulus nor angle of the handle is not specified.

+
+
+
+
+ + +
+ + +
+ Functions of points + + + + Angle to point from origin + + + + + + + + + + + +

Angle to the point from the origin, measured counter-clockwise from the positive x axis.

+
+ + + + + + + + + + +

Analogous to the case.

+
+
+
+ + + Unit vector with given angle + + + + + + + + - - + + +

Unit vector with given angle.

+
+
+
+ + + Scaling to unit length + + +

Scaling to unit length is closely related to computing the norm, compare . While the norm preserves physical units, scaling to unit norm will cancel the unit so that the produced unit vector is always unit-less.

+
+ + + + + + + - - - - - - -

Construct transform from multiplier for x and y coordinates, followed by a shift.

-
-
-
- - + + +

Scaling to unit length. The argument must not have zero length.

+ + + + + + + + + + + +

Scaling to unit length. The argument must not have zero length.

+
+ + + + + + + + + + +

Scaling to unit length. The argument must not have zero length.

+
+ + + + + + + + + + +

Scaling to unit length. The argument must not have zero length.

+
+ + + + + + + + + + +

Scaling to unit length, resulting in either plus or minus one. The argument must not be zero.

+
+ + + + + + + + + + +

Scaling to unit length, resulting in either plus or minus one. The argument must not be zero.

+
+ + + + + + + + + + +

Scaling to unit length, resulting in either plus or minus one. The argument must not be the zero length.

+
+ + + + + Orthogonal vector + + + + + + + + + + + + +

Produces vector which is orthogonal to the given one, by rotating 90° counter-clockwise.

+
+
+
+
+ + +
+ + +
+ Functions of paths + + + + + + +

An empty path. Useful in folds, for instance.

+
+ + + +
+
+ + + + + + + + + + + +

Construct path where the order of pathpoints in the representation is reversed. The constructed path looks identical to the original.

+
+
+ + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + + + + + + + +

Counts the number of counter-clockwise turns that makes about . It is required that be closed.

+

The winding number is used to define filling and clipping.

+ + + +]]> + + +

Winding numbers computed by .

+ +
+ + + +]]> + + +

Using to compute the argument variation integral for open paths.

+ +
+
+ + + +
+
+
+ + +
+ + +
+ Affine transforms + + + + + + + + + + + + + + + + + +

Construct transform from multiplier for x and y coordinates, followed by a shift.

+
+
+
+ + + + + + + + + + +

Construct transform.

+
+ + + + + + + +

Construct transform.

+
+
+
+ + + + + + + + + + +

Construct transform.

+
+
+
+ + + + + + + + 1 + + + + 1 + + + + 1 + + + +

Construct transform that scales x by , and y by .

+
+
+
+ + + + + + + + + + +

Constructs the inverse of a transform. This is only possible if the linear part of the transform is non-singular.

+
+ + + + + + + +

Constructs the inverse of a transform. This is only possible if the linear part of the transform is non-singular.

+
+
+
+ + +
+ + +
+ Means + + + + + + + + + + + + +

Mean point of the path.

+

Note that this is not the same as the mean of the area that would be painted when filling the path.

+
+
+ + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + +

Mean of the path points of the path.

+
+
+ + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + +
+ + +
+ Extremes + + + + + + + + + + + + + + + +

Finds the first point on the path where the global maximum in the given direction is attained.

+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + + + + +

Finds the first path point on the path where the global maximum in the given direction is attained.

+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + + + + +

Finds the a point among the control points of the path, where the global maximum in the given direction is attained.

+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + +
+ + +
+ Proximity and intersection + + + + + + + + + + + + + + + +

Finds the first point on the first path where it intersects with the second path.

+

If no intersection is found, the error handler is called with the two paths as argumets.

+

Additional information from the computation is stored in the field of the returned . This structure, in turn, has fields accordning to the following table.

+ + The <field name="info" /> <named-type name="Structure" /> returned by <value name="intersection" /> + + + The “time” of the intersection according to the second path. + + +
+
+
+
+ + + + +

To be called when the intersection between two paths cannot be found.

+

Shall take the two objects as arguments.

+
+
+ + + + + + + + + + + + + + +

Finds the first point on the path where the global minimum in distance to the given point is attained.

+

The algorithm and related tolerances are described in .

+ + + + + + + + + + + + + +

Finds a point on the first path where the global minimum in distance to the second path is attained. If there are intersections, the earliest of these is returned

+

The algorithm and related tolerances are described in .

+

Additional information from the computation is stored in the field of the returned . This structure, in turn, has fields accordning to the following table.

+ + The <field name="info" /> <named-type name="Structure" /> returned by <value name="approximator" /> + + + Distance between paths at optimum. + + + + The “time” along the second path at optimum. + + + + + + + + + + + + + + + +

Analogous to the the case.

+
+
+ + + + + + + + + + + +

Analogous to the the case. However, note that the meaning of intersection is not quite clear in the case, and hence we shall not be precise regarding among which times the earliest is taken if there are several “intersections”.

+
+
+ + + + + + + + + + + + + + + + +

Finds the first path point on the path where the global minimum in distance to the given point is attained.

+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + +
+ + +
+ Path-producing functions + + + + + + + + + + + + + + +

Constructs a rectangular path with the given points as opposite corners. The path starts at the first of the given points, and if the points are given as bottom-left and upper-right (in that order), the path is oriented counter-clockwise.

+
+
+
+ + + + + + + + + + + + + + +

Merge the two paths by merging the point of the first path with the point of the second path. It is not required for the two paths to intersect; the merge operation is defined anyway by replacing the two merged points with one at the mean, taking one interpolation point form each path. Use this to avoid vanishing spline segments when joining two consecutive paths.

+

Hopefully, the example below expresses the idea more clearly.

+ + + +]]> + + +

Application of . Note that the interesting stuff is found in .

+ +
+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + 1bp + + + + 1bp + + + + + + + + + + + +

Interpret the string as an description of a path. Generally, converting coordinates from the model to is cumbersome, as it basically requires a drawing area in the world to be defined and related to coordinates. However, by disregarding the shift part of the true coordinate transform, only scaling remains to be determined, and for this there is and .

+

The argument is optional. If provided, means that a will be returned (generally containing several sub paths of type ), and means that there must be exactly one sub path, which will be returned as a .

+

If is false, paths with zero duration are ignored.

+

Use this function when you'd rather use a graphical tool to define paths than writing the code by hand. For instance, paths can be created with Gimp, and exported in format.

+

Note that graphics is typically located below the origin, while (and ) programs typically locate graphics above the origin. When determining how to shift the returned path, and this is done using information, it must be remembered that the y coordinate is increasing downwards.

+ + + + + + +
+ + +
+ Upsamling of paths + +

While most operations on paths only depend on the geometry of the path, there are some operations that operate on the spline representation. Generally, such operations give a more precise result for smaller spline segments, and fortunately, a spline can be divided into smaller segments without changing its geometry. This is referred to as upsampling of the path, and provides some variants on how this can be done.

+
+ + + + + + + + + + + + + +

Divide each spline segment in two such that the velocity is continuous at the new path point. This will make the distance to the two interpolation points at the new path point equal, hence the name. It turns out that this happens at spline time 0.5, so the implementation is very cheap.

+
+
+ + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + + + + + + + + + + +

Add samples at inflection points.

+
+
+
+
+ + + + + + + + + + + + + + +

Add samples at inflection points, and so that each segment bends at most . Segments that need upsampling (after inflections have been removed) are sampled evenly with respect to direction.

+
+
+
+
+ + + + + + + + + + + + + + +

Add sample points such that each segment is at most long. Segments that need upsampling are sampled evenly with respect to arc length.

+
+
+ + + + + + + + + + + +

Analogous to the the case.

+
+
+
+
+ + +
+ + +
+ Numerical tolerance + +

Generally, programs should not directly refer to the low level tolerance parameters described in . Therefore, most of these parameters are not even exposed with a binding. This section gives the exceptions.

+
+ + + + + + +

The value controlled by .

+
+
+
+ + +
+ + diff --git a/doc/parts/namespace/Shapes-Geometry3D.sxml b/doc/parts/namespace/Shapes-Geometry3D.sxml index 261ad412..4366227d 100644 --- a/doc/parts/namespace/Shapes-Geometry3D.sxml +++ b/doc/parts/namespace/Shapes-Geometry3D.sxml @@ -38,4 +38,238 @@

The geometric objects in are coordinates and paths. This namespace is for operations within this class of objects. Once the geometric objects are painted (typically stroked or filled), they become graphical objects and are no longer under the topic of this namespace. Compare . This namespace is also used for the border between the and geometry worlds, so that doesn't get disturbed by the things that only concern those that think in .

+ + + + + + + + + + + + + +

Apply pin-hole camera projection. The geometry of the projection is documented under .

+

Exactly how objects, if they can at all, behave when being projected, depend on the exact object type. objects will result in objects, the operation is generally very complicated if occlusions are to be taken into account. (What makes it difficult is that deals with scalable graphics, and cannot resort to a pixel z-buffer.) There are three graphics container types with different behaviors. First, takes no consideration of occlusions, and just puts the projections of its part on top of each other in the order in which they appear in the data structure. The two remaining types tries to respect occlusions, and the reader is referred to the documentation of these types to find out more about their algorithms, see and .

+
+ +
+
+
+ + + + > 0bp or = + 50cm + +

When a world is viewed through a pin-hole camera to obtain image, the pin-hole camera (the eye) is located at ( 0, 0, zeye ), and the image plane is z = 0. The special float value can be used to place the eye at infinity, which will make the projection independent of z coordinates.

+
+
+ + + + + + + + + + + +

Move object from to by equipping it with a z = 0 coordinate. The operation is reversed by .

+
+
+
+ +
+ + + + + + + + + + + + + +

Construct rotation transform about given direction.

+
+
+
+ + + + + + + + 1 + + + + 1 + + + + 1 + + + + 1 + + + +

Construct transform that scales x by , and similarly with y and z.

+
+
+
+ + + + + + + + + + + + + + + + + + + +

Construct transform from multiplier for x, y, and z coordinates, followed by a shift.

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +

Computes a rigid body coordinate transform that brings the transform into a simple form. The linear part of the coordinate transform is given by the real Schur decomposition, ensuring that a real eigenvalue is associated with the third basis vector. (Hence, if there is a 2 by 2 block in the Schur form, it will be in the upper left part.) The translational part of the coordinate transform is computed to make the translational part in the new coordinates small. The parameter determines how many equation to use when the translational part is computed. If is not provided, it is determined automatically from singular values. A of zero means that the translational part of the coordinate transform shall not be used at all. If is set, the coordinate transform is made special (that is, it preserves orientation), and if there is an extra degree of freedom in the coodinate transform due to complex eigenvalues in the linear part of , it is used to minimize the angle of rotation in the coordinate transform.

+

Note that the rank shall not be selected full (that is, 3) if is a rigid body transformation; use 2 if the rotation is not close to zero, and 0 otherwise (or use the automatic selection). Compare Chasles' theorem, which says that the new transform will in general have a non-trivial translational part.

+

This function may be used to find a rotation's eigenvector (that is, the direction of the rotation), as the eigenvector will be in the third column of the linear part of the change of coordinates. +

+tf: [rotate3D angle:25° dir:(1,2,3)]
+•stdout << [Schur_decomp tf].Q.Lz
+
+

+ + +]]> + + +]]> + + +

The generalization of real Schur decomposition to also include a translation. It can be seen that rank 2 is selected for a rigid body transform with non-trivial rotation. It is also seen that, whithout setting the flag, the coordinate transform may not preserve orientation.

+ +
+
+
+
+
+ + + + + +

The analogue of , but in instead of .

+
+
+
+ + + + + + + + + + + + + + + + + +

Implements .

+
+
+ + + + + + + + + + + + + + +

Implements .

+

Note that all arguments must be , with no exception.

+
+
+
+
+ + + Orthogonal vector + + + + + + + + + + + + +

Produces vector which is orthogonal to the given one. The funciton preserves norm, but the argument must not have zero length.

+

The direction of the result is computed as a cross product with either the x or the y basis vector, depending on which one is less parallel to the argument.

+
+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Graphics-Tag.sxml b/doc/parts/namespace/Shapes-Graphics-Tag.sxml new file mode 100644 index 00000000..51333d98 --- /dev/null +++ b/doc/parts/namespace/Shapes-Graphics-Tag.sxml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + ..Shapes..Graphics..Tag + +

Tagged values inside graphics.

+
+ + <self /> + + "$(BASE)" /> + "$(EXAMPLES)" /> + "$(SHAPES_VERSION)" /> + + + + + + +

Graphics in both and may hold tagged values. Unlike just having an ordinary map from keys to values, tagged values have the advantage that they can transform with the graphics in which they are contained.

+
+ + + + + + + + + + + + + + + true + + + + true + + + + + + + +

Creates a tagged object by attaching key to .

+

The result is either a or a , depending on the type of and the values of and . Non-geometric values result in .

+

means the tagged object shall try to preserve the geometric nature of , while means that the drawable nature should be preserved. Note that a drawable object is also geometric.

+

Tagged objects are useful for many purposes. At the lowest level, they may be retrieved later by their key, and they can be referred to for removal from a group state.

+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + +

Retrieves one value tagged with . It is an error if the key is not present in .

+
+ + + +
+ + + + + + + + + + + + + + +

See the case.

+
+
+
+
+ + + + + + + + + + + + + + + + + +

Retrieves all values tagged with .

+
+ + + +
+ + + + + + + + + + + + + + +

See the case.

+
+
+
+
+ + + +
diff --git a/doc/parts/namespace/Shapes-Graphics.sxml b/doc/parts/namespace/Shapes-Graphics.sxml index 91bc2c93..525499f5 100644 --- a/doc/parts/namespace/Shapes-Graphics.sxml +++ b/doc/parts/namespace/Shapes-Graphics.sxml @@ -39,4 +39,378 @@

A graphical object in is basically something thay can be drawn on a canvas. Many of these objects get created by first working out their geometry using things in , and then stroking or filling to get the graphics.

+ +
+ Elementary <str-2D /> + + + + + + +

An empty graphics value. Useful in folds, for instance.

+
+ + + +
+
+ + + + + + + + + +
+ +
+ Empty and pointlike graphics + + + + + + +

An invisible graphics value with a point-like bounding box as the origin.

+
+
+
+ + + + + + + + + + + +

Paints a round spot at the given coordinates. The width and color of the spot is as if the spot was a stroke, see .

+

Note that spots can also be made by stroking a closed singelton path with a round cap style. That is, +

+[spot pt]
+
+is equivalent to +
+@cap:CAP_ROUND | [stroke emptypath--pt--cycle]
+
+

+

Also note that using is much more efficient than using on a circular path.

+

Rather than making the origin the default value for the argument, the dynamic variable is provided to make the dynamic nature of the expression more obvious compared to [spot].

+

Some viewers fail to do the obvious thing when a singleton path is painted with a stroke, and if you are targeting such viewers you could either change the implementation of using the command line option --spot-pair=yes, or use on a path between two points at the same location instead of using , like so: +

+@cap:CAP_ROUND | [stroke pt--(+(0m,0m))]
+
+

+ + + + + + + + + + + dynamic [spot (0m,0m)] + Cannot be changed! + +

A function call with fixed arguments (or no arguments at all) is like a dynamic variable, and then a dynamic variable is generally preferred over the function call since using a dynamic variable emphasizes the dynamic nature of the expression. Since the need for a spot at the origin (which can then be transformed to any desired position) is so frequent, this dynamic variable is simply an alternative to calling with the origin as argument.

+

The value of this dynamic variable will depend on other dynamic variables, compare .

+
+
+ + +
+ +
+ Clipping + + + + + + + + + + + + + + + +

Clips according to .

+

When is a , the nonzero winding rule is used.

+

When is a , follows with respect to the interpreation of the captured in . That is, the text will be painted as usual as a background to the clipped . Hence, if one is interested in pure clipping, the corresponding rendering mode is obtained by [textmode] (see ). Since clipping with respect to a text is assumed to be a way of painting that text, the bounding box becomes that of in this case, no matter what parts of this mask that acutally has any content.

+

If the goal is to crop to control the size of the end result, then should be used instead.

+

At the moment, we refrain from including an example of clipping with a since the implementation of this feature seems buggy in most viewers. (At least it would be good if the tool we use to generate bitmap images for this documentation was able to produce correct results before we include an example.)

+ + + +]]> + + +

When clipping a path with , the nonzero winding rule is applied.

+ +
+ + + +]]> + + +

Clipping with respect to a text is typically a way of painting that text. Clipping is combined with the effect of painting the text as usual, but as the topmost part of this figure shows, the none rendering mode can be used to do pure clipping.

+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + +

Clips according to , applying the even-odd winding rule.

+ + + +]]> + + +

When clipping a path with , the even-odd winding rule is applied.

+ +
+
+ +
+
+
+ + +
+ +
+ Painting paths + + + + + + + + + + + + + + + + + + + + +

Paints the argument by stroking it. Properties such as color (), width, are taken from the dynamic environment.

+

The arguments and define arrowheads at the corresponding ends of the stroke. An arrowhead is defined by a function that takes the path as argument, and returns a tuple with fields and . Here, shall be the grahpics that is the actual arrowhead, while tells how much the stroke shall be shortened to not interfere with the arrowhead. Note that the arrowhead and the stroke usually overlap, but that it is not desirable that the stroke goes all the way to the point of the arrowhead.

+
+
+ + + + + + + + + + + + + + + + +

Compare with the case.

+

Note that defining arrow heads is much more intricate in than in , and generally requires knowledge of from what angle the arrowhead will later be viewed. If one is really eager to work around this “problem”, then what one is typically looking for is a way to delay the definition of the arrowhead until the viewing angle is known. The key to the solution is .

+
+
+
+
+ + + + + + + + + + + +

Paints the (that shall be closed) argument by filling it using the nonzero winding rule. The fill color is taken from .

+ + + +]]> + + +

When filling a path with , the nonzero winding rule is applied. This example is a reconstruction of the corresponding example in the reference.

+ +
+
+ + + +
+ + + + + + + 0 + + + + + +

Paints the (that shall be closed) argument by filling it nonzero winding rule. The fill color is taken from .

+

Note that although winding rules don't really make any sense in , some rule must nevertheless be applied to the path once it has been projected to . Then, the nonzero winding rule is the simplest and hence most reasonable choice.

+
+
+
+
+ + + + + + + + + + + +

Paints the (that shall be closed) argument by filling it with the color , using the even-odd rule.

+ + + +]]> + + +

When filling a path with , the even-odd rule is applied. This example is a reconstruction of the corresponding example in the reference.

+ +
+
+ + + +
+
+
+ + +
+ +
+ Externally created content + + + + + + + + + + + + +

Sends the string to and returns the resulting piece of typeset text.

+

The origin of the produced label is the same as in ; at the leftmost point of the baseline. Unfortunately, fonts lie about their bounding boxes to make them look smaller, and this will cause the produced label to be slightly cropped when imported. At the moment, I can't think of a good way to get around this problem, since a tight bounding box is important for layout purposes. By controlling the size of the bleed box using , you can at least try to avoid the problem of the final result getting cropped too tight.

+

If the expression is a string literal, it is handled more efficiently than if the string must be obtained by evaluation.

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +

The given string should name a file, and the pages of the file will be returned as a vector-function, mapping 0 to the first page in the document, 1 to the second page, and so forth.

+

Vector functions have a field called size which will give the page count in the document.

+
+
+
+
+ + + + + + + + + + + 1bp + + + + + + + + + + + + +

The argument should name file with raster image data. If is , the file type is inferred from the filename extension. Currently, the only supported formats are and , which may be selected using the symbols 'PNG or 'JPEG.

+

The length is the size of each pixel, both horizontally and vertically, unless is false and the imported file specifies the resolution instead. If is false, but a file only specifies the aspect ratio of the pixels, the resolution will be computed such that the area of each pixel equals the area of a square pixel with side .

+

The origin is at the lower left corner of the image. The physical dimensions of the image will be the product of the density and the number of pixels in the corresponding dimensions of the image.

+
+
+
+
+ + +
+ diff --git a/doc/parts/namespace/Shapes-Graphics3D.sxml b/doc/parts/namespace/Shapes-Graphics3D.sxml index adedf3eb..1cbe64c7 100644 --- a/doc/parts/namespace/Shapes-Graphics3D.sxml +++ b/doc/parts/namespace/Shapes-Graphics3D.sxml @@ -39,4 +39,167 @@

A graphical object in is basically something that ca be projected to , and then results in a graphical object. This namespace is also used for the border between the and graphical worlds, so that doesn't get disturbed by the things that only concern those that work with scenes.

+
+ Elementary <str-3D /> + + + + + + +

The analogue of , but in instead of .

+
+
+
+ + + + + + + + + +
+ +
+ Facets + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + +

The only required argument is , which must be a flat polygon. The three arguments of type will be described shortly. The parameter has the same meaning as for , and tells whether the surface should be visible when viewed from the back. Surfaces that are not visisble when viewed from the back allow more efficient rendering when they cover a solid body, so that one knows that the inside of the body surface should never be visible. The default value for depends on the presence of surface normals; if there are none, it defaults to true, otherwise it defaults to false unless the surface normals disagree on which is the visible side.

+

Up to three surface normals may be provided (provide before and so forth). A surface normal has a location on the surface and specifies both a normal direction to be used in light computations (although the surface is physically flat, it can be treated as if curved in the light model), and a color. See for more details on how to construct surface normals. If no facet normal is provided, one is computed by using the physical normal direction of , with color determined by . If just one facet normal is provided, it defines a constant normal direction and color over the whole facet. If more than one is provided, normal direction and color are interpolated over the facet.

+

Please refer to the documentation on the many dynamic variables accessed by this function, to learn how these affect the light computations.

+
+
+
+
+ + +
+ +
+ Scenes and light + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ Quasi <str-3D /> + + + + + + + + + + + + false + + + + false + + + +

Make a special kind of object at z = 0, which will always face the viewer even after transforms. It is useful for labels and other annotations that need to be positioned in terms of objects in a world.

+

When the object is viewed after being transformed in , it will just be transformed by a transform, so the object never has to go truly . The object will be shifted according to how its origin moved by the transform. The arguments and determine how the linear part of the transform is obtained from the transform. If is set, the object will be scaled according to the z coordinate of its transformed origin. If is set, the linear (x,y) part of the transform will be used.

+
+
+ + + + + + + + + + + + + + + +

Gives the user full control of how to display the object when being viewed through a transform. The dynamic state is captured, and will be in scope later when the embedded function is invoked.

+ + +

The evaluation order is quite non-standard for the objects created here. Viewing an object is generally an atomic operation from a continuation passing point of view. Hence, when the function is applied to the transform to obtain the result, this will take place in an evaluation loop of its own. This is very likely to render generated error messages rather useless when it comes to localizing the problem.

+

Since the object created here only has a meaning when being viewed, it cannot be searched (see and ) for tags as long as it remains in .

+
+ +

If you ever considered solving the intricate problem of generating nice arrowheads for paths in by simply treating the path as if it was in , think again, as the example below shows!

+ + + + +]]> + + +
+
+
+ +
+ + +
+ diff --git a/doc/parts/namespace/Shapes-IO.sxml b/doc/parts/namespace/Shapes-IO.sxml index 5f8fed99..b12a2b43 100644 --- a/doc/parts/namespace/Shapes-IO.sxml +++ b/doc/parts/namespace/Shapes-IO.sxml @@ -53,6 +53,9 @@

Note the conceptual difference between programs that produce many pages of output (and it may happen to be just one), and programs that produce just one piece of graphics; a “book” with just one page is still a book, and hence not something which should be included on a page of another document. If the output is something to be placed on a page of an external document, then there is only one logical page to paint, namely .

+ +

Most core states represent various aspects of the changing world outside a program, and have to be provided in the initial environment since they cannot be spawned deterministically from a hot value. On the other hand, (and ) can be replaced by user-defined states, but are provided to make a program easier to read, as not every user will have to invent its own name for a state with the same purpose.

+
diff --git a/doc/parts/namespace/Shapes-Layout.sxml b/doc/parts/namespace/Shapes-Layout.sxml index a61ca0c9..37c1b75b 100644 --- a/doc/parts/namespace/Shapes-Layout.sxml +++ b/doc/parts/namespace/Shapes-Layout.sxml @@ -39,4 +39,68 @@

The namespace is on the border between and . It is concerned with operations on both geometrical and graphical objects, but with particular focus on graphical layout.

+ + + + + + + + + + + + 'bounding + + + + +

Returns the bounding box or the bleed box of , depending on the parameter .

+

The allowed values for are { 'bounding, 'bleed }.

+
+ +
+
+
+ + + + + + + + + + + + + + 'bounding + + + + +

Creates an object with the same content as , but with different boxes (note that, here, box refers to a convex path — not necessarily a rectangle). One or both of the new objects boxes is set to , depending on the parameter .

+

The allowed values for are { 'bounding, 'bleed, 'both }.

+ +

Generally, the bounding box is the convex path used for layout of an object. The bleed box is used by the compiler to determine where to crop the final contents of a page. Making the bleed box slightly bigger than the bounding box can be a good idea for content that may look squeezed (or even get cropped) if appearing by the border of a page.

+
+
+ +
+
+
+ + + + 1bp + +

The bounding boxes computed by are generally too small to completely contain the glyph marks. The reason appears to be that font designers tend to intentionally lie about the bounding box in order to achieve better type setting given existing type setting algorithms.

+

This causes a problem when such objects are at the boundary of the bounding box of page, since the page will then be slightly too small. While perhaps just mildly irritating when the page is the end media, but when the output is included as a picture in a bigger document, the cropped glyphs become really disturbing.

+

The solution to this is to define a bleed box which is larger than the bounding box. The bounding box will be used for layout as usual, but the bleed box is used when determining the crop box for the page. To keep things simple, the size of the bleed box is controlled using this dynamic variable alone, which specifies how much the bleed box extends outside the bounding box in the x and y directions.

+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Numeric-Math.sxml b/doc/parts/namespace/Shapes-Numeric-Math.sxml index b6cf97c8..e37fb0e8 100644 --- a/doc/parts/namespace/Shapes-Numeric-Math.sxml +++ b/doc/parts/namespace/Shapes-Numeric-Math.sxml @@ -64,13 +64,433 @@ + + Cosine + + +

Elementary math library function.

+
+ + + + + + + + + + +

Cosine of argument in radians.

+
+
+
+ + + Tangent + + +

Elementary math library function.

+
+ + + + + + + + + + +

Tangent of argument in radians.

+
+
+
+ + + Cotangent + + +

Elementary math library function.

+
+ + + + + + + + + + +

Coangent of argument in radians.

+
+
+
+ + + Inverse of sine + + +

Elementary math library function.

+
+ + + + + + + + + + +

Inverse of sine, with result in radians.

+
+
+
+ + + Inverse of cosine + + +

Elementary math library function.

+
+ + + + + + + + + + +

Inverse of cosine, with result in radians.

+
+
+
+ + + Inverse of cosine + + +

Elementary math library function.

+
+ + + + + + + + + + +

Inverse of tangent, with result in radians.

+
+ +
+
+
+ +
+ Extreme values + +

TODO: Documentation of min and max.

+ +
+ + +
+ Rounding + + + + Rounding towards negative infinity + + +

Elementary math library function.

+
+ + + + + + + + + + + +

Rounding towards negative infinity, giving the largest integer which is not greater than the argument.

+

With the range of being larger than the range of , there is risk of overflow, in case of which the behavior is undefined.

+
+
+
+
+ + + Rounding towards positive infinity + + +

Elementary math library function.

+
+ + + + + + + + + + + +

Rounding towards positive infinity, giving the smallest integer which is not less than the argument.

+

With the range of being larger than the range of , there is risk of overflow, in case of which the behavior is undefined.

+
+
+
+
+ + + Rounding to nearest integer + + +

Elementary math library function.

+
+ + + + + + + + + + + +

Rounding to nearest integer, with half-way cases rounded away from zero.

+

With the range of being larger than the range of , there is risk of overflow, in case of which the behavior is undefined.

+
+
+
+
+ + +
+ + +
+ Remainders of division + +

comes with three different remainder functions, each characterized by how the sign of the result is determined. Each function is defined for both , , and . The difference between the three functions is illustrated by the following example.

+ + + +]]> + + +

The three remainder functions, illustrated for both and cases, and for both positive (left column) and negative (right column) divisors. Lines show the case, with unattained limit values indicated with empty circles. Spots show the case. It is seen that the case coincides with the case at integer points.

+

The illustration is included just for fun — when determining which remainder function to use, it is strongly recommended to do that based on the mathematical characterizations rather than this illustration.

+ +
+ + + Remainder of division, with non-negative sign + + + + + + + + + + + + + + + +

Remainder consistent with Euclidean division, always being non-negative. That is, let z denote the result of [modulo x y], where x is the divident and y is the divisor. Then z is the unique number that satisfies both 0 ≤ z < |y| and n y + z = x for some integer n.

+

Equivalently, z can be compuated as x - [abs y] * [floor (1.0 * x) / [abs y]]..

+
+
+ + + + + + + + + + + + + +

Generalization of the case to real values.

+
+ + + + + + + + + + + + + +

Analogous to the case.

+
+
+
+ + + Remainder of division, with sign of divisor + + + + + + + + + + + + + + + +

Remainder induced by floored division. That is, let z denote the result of [mod x y], where x is the divident and y is the divisor. Then z solves the equation n y + z = x, where the integer n is the fraction x / y rounded towards negative infinity.

+

Since n y ≤ x if y > 0 and vice versa, the definition implies that z will have the same sign as y and magnitude less than that of y.

+
+
+ + + + + + + + + + + + + +

Generalization of the case to real values.

+
+ + + + + + + + + + + + + +

Analogous to the case.

+
+
+
+ + + Remainder of division, with sign of divident + + + + + + + + + + + + + + + +

Remainder induced by division rounded towards zero. That is, let z denote the result of [rem x y], where x is the divident and y is the divisor. Then z solves the equation n y + z = x, where the integer n is the fraction x / y rounded towards zero.

+

Since the magnitude of n y will be no greater than that of x, the definition implies that z will have the same sign as x, and the magnitude of z will be less than that of y.

+
+
+ + + + + + + + + + + + + +

Generalization of the case to real values.

+
+ + + + + + + + + + + + + +

Analogous to the case.

+
+
+
+ + +
+ +
Miscellaneous functions + + Square root + + +

Elementary math library function.

+
+ + + + + + + + + + + +

Square root of non-negative number.

+
+
+
+
+ Modulus of scalar values, norm of vectors, and length of paths diff --git a/doc/parts/namespace/Shapes-Numeric-Random.sxml b/doc/parts/namespace/Shapes-Numeric-Random.sxml index f306abee..6da6457e 100644 --- a/doc/parts/namespace/Shapes-Numeric-Random.sxml +++ b/doc/parts/namespace/Shapes-Numeric-Random.sxml @@ -39,4 +39,15 @@

Desides the most elementary things such as initializing the random state and then sampling uniformly from a huge range of integer values, also comes with some more interesting distributions to sample from. Distributions are not represented explicitly, only implicitly as the non-pure functions that return an object of some kind while acting on a random state.

+ + + + + +

Source of high quality random seeds.

+
+
+ + + diff --git a/doc/parts/namespace/Shapes-String.sxml b/doc/parts/namespace/Shapes-String.sxml index 07524fa0..0de9daeb 100644 --- a/doc/parts/namespace/Shapes-String.sxml +++ b/doc/parts/namespace/Shapes-String.sxml @@ -40,4 +40,45 @@

This namespace also covers operations on individual characters, even though the namespace name suggests otherwise.

+ + + + + + + + + + + + + + + + + + +

The functional alternative to using the form of based on code points. Using the syntax is more efficient when the argument is known beforehand.

+
+
+
+
+ + + + + + + + + + +

The functional alternative to using the form of based on glyph names. Using the syntax is more efficient when the argument is known beforehand.

+
+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Text-Font.sxml b/doc/parts/namespace/Shapes-Text-Font.sxml index dbd61d13..e9758809 100644 --- a/doc/parts/namespace/Shapes-Text-Font.sxml +++ b/doc/parts/namespace/Shapes-Text-Font.sxml @@ -39,4 +39,121 @@

These are the pre-defined fonts available in . Other fonts may be loaded or created with utilities in .

+ + + + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + + +

Access to built-in font.

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Text.sxml b/doc/parts/namespace/Shapes-Text.sxml index cb157b79..d43d6ddc 100644 --- a/doc/parts/namespace/Shapes-Text.sxml +++ b/doc/parts/namespace/Shapes-Text.sxml @@ -37,6 +37,219 @@

Graphical rendering of test is a complex matter with lots of parameters to be controlled. By having a separate namespace for these things, the gets less content and will be easier to apprehend.

+ +

The bindings in this section are closely related to the text state parameters in .

+
+ Typeset text + + + + + + + + + + + + + + + + + + + + + + + + +

Constructs a value that specifies a text rendering mode, which can be assigned to .

+

If both arguments are false, the rendering mode will cause the text not to display at all, which is useful when clipping.

+
+ +
+
+
+ + + + + + + + + + + +

Manual kerning. Each value between values will subtract horizontal distance between the adjacent glyphs when the text is added to a object. The distance is interpreted in units of the font size.

+
+ +
+
+
+ + + + + + + + + + + +

Interleaves automatically kerned text with manual kernings.

+

Automatic kerning needs support by the metrics of the current font must, and it is forbidden to call this function unless the current font indicates that kern pairs supported by having its field set to .

+
+ +
+
+
+ + + + FONT_HELVETICA + +

Intended to be used when creating text using the built-in mechanisms of .

+
+
+ + + + 10bp + > 0bp + +

Intended to be used as the size of text.

+
+
+ + + + 1 + > 0 + +

Horizontal scaling of the font.

+
+
+ + + + +

Text rendering mode.

+ +

Design note: It would have been possible to split the rendering mode into two separate dynamic variables; one for stroking, and one for filling. One obvious benefit of this would have been that the special type would not have been necessary. However, the rendering mode is usually perceived as one entity; controlling one of the two flags while not caring about the other seems very unlikely. This is why the two are kept together.

+
+
+ + + +
+ + + + + +

The text knockout mode. Refer to the reference for details.

+
+
+ + + + 0bp + +

Extra space to add between characters.

+

A is interpreted as a scaling of .

+
+
+ + + + 0bp + +

Extra space to add at each space character.

+

A is interpreted as a scaling of .

+
+
+ + + + 1 + +

The vertical distance between lines of text.

+

A is interpreted as a scaling of .

+
+
+ + + + 1 + +

Vertical offset of the text from the normal baseline.

+

A is interpreted as a scaling of .

+
+
+ + +
+ + +
+ Glyphs and fonts + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Locates and loads a font, which can be assigned to . Currently, the only supported font format is TrueType. This function requires the compiler to be built with both FreeType and FontConfig.

+

The two arguments and are used to point out a particular font. If is , the font will not produce text that references glyphs inside a font program stored in the file, but the glyphs will be drawn as filled paths without any connection to characters. Outlining the font has the advantage that no font program needs to be stored in the file, but there are several drawbacks: +

    +
  • It will not be possible for viewing applications to search or copy the text.
  • +
  • Outlining each glyph may produce bigger files when there is a lot of text.
  • +
  • Outlining may slow down display of the , and rules out font-rendering techniques that are normally used to enhance the visual appearance of text.
  • +
+ Besides these differences, there result should look the same no matter whether fonts are outlined or not. This implies that bounding boxes of outlined fonts are computed exactly as for non-outlined fonts, even though the glyph outlines would allow more “accurate” boxes to be computed.

+

The font is located using FontConfig, so if fails to find your font, this is most likely an issue with FontConfig, and not with . To check what fonts FontConfig knows about, one can use the command line utility fc-list. For instance, calling with equal to Santa Fe LET, and not passing anything for , should correspond to the command line call + +fc-list 'Santa Fe LET':font-format=TrueType + +and if was set to Regular (which Santa Fe LET does not provide; the only style is called Plain), that would correspond to + +fc-list 'Santa Fe LET':style=Regular:font-format=TrueType + +This way, you can experiment with font families and styles in the terminal before trying to select the font in your program.

+
+ +
+
+
+ + +
+ diff --git a/doc/parts/namespace/Shapes-Traits-BW.sxml b/doc/parts/namespace/Shapes-Traits-BW.sxml index d2d16afc..fd4bd11b 100644 --- a/doc/parts/namespace/Shapes-Traits-BW.sxml +++ b/doc/parts/namespace/Shapes-Traits-BW.sxml @@ -39,4 +39,34 @@

Color constants for the black and white color space.

+ + + + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Color value with special interpretation. If used as a color, it is the same as . In a z-sorter (see ), however, this color causes the surface not to be drawn at all.

+

This is useful when one wants to draw a picture where lines are drawn on a surface, and one is not interested in filling the surface with any color, but the surface is needed never the less to occlude lines. Not filling the surface with any color allows the lines to be drawn on any background, and will also generate an output with much smaller memory footprint.

+

Note that a z-buffer always draws all visible line segments on top of the filled areas.

+
+
+
+ + diff --git a/doc/parts/namespace/Shapes-Traits-Blend.sxml b/doc/parts/namespace/Shapes-Traits-Blend.sxml index 541941ca..5aea331b 100644 --- a/doc/parts/namespace/Shapes-Traits-Blend.sxml +++ b/doc/parts/namespace/Shapes-Traits-Blend.sxml @@ -39,4 +39,129 @@

Blend mode constants.

+ + + + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + + +

Access to blend mode constant.

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Traits-Cap.sxml b/doc/parts/namespace/Shapes-Traits-Cap.sxml index ff6acb8d..d82d914a 100644 --- a/doc/parts/namespace/Shapes-Traits-Cap.sxml +++ b/doc/parts/namespace/Shapes-Traits-Cap.sxml @@ -39,4 +39,33 @@

Line stroke cap style constants.

+ + + + + + +

Value for .

+
+
+
+ + + + +

Value for .

+
+
+
+ + + + +

Value for .

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Traits-Device.sxml b/doc/parts/namespace/Shapes-Traits-Device.sxml index 1a510d8c..6813e7e0 100644 --- a/doc/parts/namespace/Shapes-Traits-Device.sxml +++ b/doc/parts/namespace/Shapes-Traits-Device.sxml @@ -39,4 +39,33 @@

Color space constants for device color spaces.

+ + + + + + +

Uncalibrated color space.

+
+
+
+ + + + +

Uncalibrated color space.

+
+
+
+ + + + +

Uncalibrated color space.

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Traits-Join.sxml b/doc/parts/namespace/Shapes-Traits-Join.sxml index 026976d3..4396c047 100644 --- a/doc/parts/namespace/Shapes-Traits-Join.sxml +++ b/doc/parts/namespace/Shapes-Traits-Join.sxml @@ -39,4 +39,33 @@

Line stroke join style constants.

+ + + + + + +

Value for .

+
+
+
+ + + + +

Value for .

+
+
+
+ + + + +

Value for .

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Traits-Light.sxml b/doc/parts/namespace/Shapes-Traits-Light.sxml index f5d78d44..78f436d1 100644 --- a/doc/parts/namespace/Shapes-Traits-Light.sxml +++ b/doc/parts/namespace/Shapes-Traits-Light.sxml @@ -36,7 +36,7 @@ -

Not much to say here…

+

The content of this namespace is not documented yet.

diff --git a/doc/parts/namespace/Shapes-Traits-RGB.sxml b/doc/parts/namespace/Shapes-Traits-RGB.sxml index 9d09a93c..6fdf387e 100644 --- a/doc/parts/namespace/Shapes-Traits-RGB.sxml +++ b/doc/parts/namespace/Shapes-Traits-RGB.sxml @@ -39,4 +39,73 @@

Color constants for the red-green-blue color space.

+ + + + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + + +

Predefined color value.

+
+
+
+ + + diff --git a/doc/parts/namespace/Shapes-Traits.sxml b/doc/parts/namespace/Shapes-Traits.sxml index aa467092..ffff30ec 100644 --- a/doc/parts/namespace/Shapes-Traits.sxml +++ b/doc/parts/namespace/Shapes-Traits.sxml @@ -37,26 +37,244 @@

The namespace is organized with basic and general things directly at the top, while constants are grouped inside nested namespaces. There is also the namespace that gathers the more advanced features of light and reflections.

+ +

The bindings in this namespace are closely related to the graphics state parameters in .

+

Many of these dynamic variables can be set to a value, which means that painted objects do not specify the property for themselves, but inherit the property from the context where they appear. This feature is a low-level trick, and the effects may be (or at least seem) unpredictable.

+ +
- Stroke properties + Strokes - - Stroke width - - 1bp - 0bp - -

Intended to be used as the width when paths are stroked. A value of 0bp has a special meaning in , being that the stroke shall be as thin as possible without dissappearing on the rendering device. On high resolution printers, this may result in a line which is very hard to read, while such a line shall allways be clearly visible on a computer screen.

-

Note that if the width is inherited from the context, it will not be possible to compute a correct bounding box of a stroked object.

-
-
+ + + 1bp + 0bp + +

Intended to be used as the width when paths are stroked. A value of 0bp has a special meaning in , being that the stroke shall be as thin as possible without dissappearing on the rendering device. On high resolution printers, this may result in a line which is very hard to read, while such a line shall allways be clearly visible on a computer screen.

+

Note that if the width is inherited from the context, it will not be possible to compute a correct bounding box of a stroked object.

+
+
+ + + + + +

Color used when paths are stroked.

+
+ + + +
+ + + + + +

Line cap style.

+
+
+ + + + + +

Line join style.

+
+ + + +
+ + + + 10 + 1 + +

Miter limit value to use when is .

+
+
+ + + + [dashpattern] + +

Dash pattern to use for strokes. (The default value gives solid lines.)

+
+ + + +
+ + + + + + + + + + + +

Creates a dash pattern from a sequence of lengths, to be used with .

+

If called with no arguments, the constructed pattern gives a solid line. Otherwise, the lengths determine where along a stroked line the pen shall be switched between on and off, with the pen initially being on.

+

Note that a dash pattern can be scaled and shifted by means of operators, see .

+
+
+
+
+ + + + [shape 1] + +

Alpha settings for stroking operations.

+
+ + + +
+ + + + + +

Value that can be passed to to indicate that no arrowhead shall be drawn. This special value will be recognized, and handled efficiently.

+
+
+
+
+ Fills + + + + + + +

Color used when paths are filled (or, more generally, anything but stroked). (The name is inherited from .)

+
+ + + +
+ + + + [shape 1] + +

Alpha settings for nonstroking operations.

+
+ + + +
+ + +
+ + +
+ Color and transparency + + + + + + +

Blend mode.

+
+
+ + + + (inherited) + +

Color space for blending.

+
+
+ + + + + + + + + + + +

Creates a shape alpha value (refer to the reference for details), to be used with .

+
+ + + +
+
+
+ + + + + + + + + + + +

Creates an opacity alpha value (refer to the reference for details), to be used with .

+
+ + + +
+
+
+ + + + + + + + + +
+ + +
+ Miscellaneous + + + + + + +

Value for and that indicates that the transparent imaging shall not be used.

+
+
+
+ + + + + +

Value that can be passed to to indicate that no arrowhead shall be drawn. This special value will be recognized, and handled efficiently.

+
+
+
+ + +
+ + + diff --git a/doc/parts/namespace/Shapes.sxml b/doc/parts/namespace/Shapes.sxml index 4c7c22ae..d1711ed3 100644 --- a/doc/parts/namespace/Shapes.sxml +++ b/doc/parts/namespace/Shapes.sxml @@ -34,7 +34,176 @@ -

This namespace is just an organizational unit. Other top level namespaces include , , and .

+

This top level namespace is reserved for the project itself. Only the most generic and essential things belong in this namespace. However, at the moment, there are also some things that are only generic but not essential here, and the plan is to move these inside some nested namespace in the future.

+

Other top level namespaces include , , and .

+
+ Essentials + + + + + + +

A value used to symbolize the absence of a value.

+

The value plays a special role in , where it is the only allowed value of all but the last expression.

+

Often used as the default value for an optional function argument, when the actual value being used by default is derived from other arguments.

+
+ +
+
+ + + + + +

A convenient function of one argument, that simply returns the argument.

+

The core has some optimizations that recognize this function, so, when possible, prefer to use over any user-defined function with the same behavior.

+
+
+
+ + + + + + + + + + +

Conditional evaluation. If holds, evaluates to , otherwise evaluates to .

+ +

The current design with an optional does not play well with types. When is equipped with a type system in the future, the design of is likely to change so that there is one function with mandatory of the same type as , and one function with optional and optional return type.

+
+
+
+
+
+ + + + +

Represents the ever-changing state being the current time. It's main characteristic is nothing but that; one can be sure that it will change from one peek of it to the next.

+

So what's the use of it? For semantic reasons, it shall be required by the kernel's non-pure functions that interact with the outside world in such a way that the result may be different from one invocation to another (and would otherwise not have any state parameters).

+

Another obvious use of is to simply ask for the time. Please refer to for details.

+
+
+ + + + + + + + +

Returns the most specific type of the argument.

+
+
+
+
+ + + + + + + + + + + + +

Constructs an located to the point where was called, and passes it to . For most values of , is not used; when used, it provides additional information used to format .

+

The values of used by the core (see ) affect how is formatted, and the value of must be in agreement with how it is used by the core (with some exceptions explained below).

+

If is 'type_mismatch, the expected type shall be described in , and the value causing the error (not a description of its type!) shall be passed in .

+
+
+
+
+ + +

General-purpose error-handling.

+ + + +

Abort program evaluation, providing the message and backtrace to the compiler for display.

+ +

By using a dedicated escape continuation rather than an immediatly aborting construct, it is possible to detect and recover in some error situations.

+
+
+ + +
+ +
+ Ignoring + + + + + + +

Swallow anything and return instead.

+

If an impure function has both side effects and a return value, may be used to only get the side effects when the impure call is not at the end of a code bracket.

+
+
+
+ + + + +

To be used when a state parameter is required by a non-pure function, but one does not care about the result.

+
+
+ + + + + + + + + +
+ +
+ Convenience + + + + + + + + + + + + + + + + + + +

Combines dynamic bindings. Can be used instead of repeating the operator .

+
+
+
+
+ + + + + +

May be used when combinding several dynamic bindings, and one would like — for clarity of notation — to use exactly one operator for each dynamic binding; not having the operator for the first (or last, depending on how you see things) will break symmetry and make it difficult to indent source code nicely.

+
+
+
+ + +
+ diff --git a/doc/parts/state-types/containers.sxml b/doc/parts/state-types/containers.sxml index 206fec89..431197f0 100644 --- a/doc/parts/state-types/containers.sxml +++ b/doc/parts/state-types/containers.sxml @@ -125,7 +125,7 @@ will not remove the stroke from the page, since the value being tacked

States of type are used to fill containers of type .

- + @@ -231,11 +231,11 @@ will not remove the stroke from the page, since the value being tacked

Don't expect the lista of dynamic references to be complete, and don't expect any of the listed references to actually be used.

- - - - - + + + + +
@@ -332,7 +332,7 @@ will not remove the stroke from the page, since the value being tacked

States of type are used to combine font properties with strings to paint text.

- + @@ -354,16 +354,16 @@ will not remove the stroke from the page, since the value being tacked - - - - - - - - - - + + + + + + + + + +

Append text without kerning.

@@ -398,10 +398,10 @@ will not remove the stroke from the page, since the value being tacked - + -

Append newline command followed by relative move, interpreting the move in units of .

+

Append newline command followed by relative move, interpreting the move in units of .

diff --git a/doc/parts/states/index.sxml b/doc/parts/states/index.sxml index 89e323ee..20ab5388 100644 --- a/doc/parts/states/index.sxml +++ b/doc/parts/states/index.sxml @@ -28,8 +28,6 @@ "$(EXAMPLES)" /> "$(SHAPES_VERSION)" /> -

only defines a few states in the initial environment. Some of these are merely a matter of convenience, while other have a stronger reason for being defined globally — while it would make perfect sense to let the output of the program be defined by the last expression in the source (after all, the whole program is just a code bracket without visible delimiters, so this would be to say that the output is defined by the value of the program), states representing communication with the outside world must be defined globally (or else they could not be allowed to change at will).

-

The reason (and ) is defined after all, is that it makes a program easier to read since not every user will have to invent its own name for a state with the same purpose.

diff --git a/doc/parts/bindings/predicates.sxml b/doc/parts/states/misc.sxml similarity index 70% copy from doc/parts/bindings/predicates.sxml copy to doc/parts/states/misc.sxml index 77a89ed4..30a4eb72 100644 --- a/doc/parts/bindings/predicates.sxml +++ b/doc/parts/states/misc.sxml @@ -15,27 +15,11 @@ -
-Predicates +
+Everything else -

Predicates are simple functions that test certain conditions.

+

Well, the states here do not have much in common except that they are generally not needed for basic applications.

- - - - - - - - - - - - -

True if the argument is the empty .

-
-
-
diff --git a/doc/parts/syntax/atoms.sxml b/doc/parts/syntax/atoms.sxml index 0136a593..5ea2b677 100644 --- a/doc/parts/syntax/atoms.sxml +++ b/doc/parts/syntax/atoms.sxml @@ -144,7 +144,7 @@ Here, new_unit has to be a simple identifier. T

Special units of lengths are used when constructing smooth paths. Then, it is often desirable not to have to provide the distance to control points in terms of absolute distances, but one would rather specify the distance relative to the distance between the first and final interpolation point, and the angles from the first and final interpolation points to the intermediate control points.

-

The most frequent use of special units of lengths is to assign the dynamic variable , see path construction.

+

The most frequent use of special units of lengths is to assign the dynamic variable , see path construction.

Special lengths can be viewed as a function taken from a particular (parameterized) set of functions. There are only eight special units of lengths, and currently, there is no support for defining new ones. Here is the list of them all: diff --git a/doc/parts/syntax/compound.sxml b/doc/parts/syntax/compound.sxml index f394cd57..4bb8d2c2 100644 --- a/doc/parts/syntax/compound.sxml +++ b/doc/parts/syntax/compound.sxml @@ -129,10 +129,10 @@

-

When the distance is missing, it may fall back on , so be prepared to have a binding for in dynamic scope unless you really know that it won't be needed.

+

When the distance is missing, it may fall back on , so be prepared to have a binding for in dynamic scope unless you really know that it won't be needed.

-

A polar handle will store the distance part as a thunk, thereby capturing the current lexical and dynamic environments. Hence, it is not when the polar handles are used to build paths, that may be required, but when the polar handles themselves are constructed.

+

A polar handle will store the distance part as a thunk, thereby capturing the current lexical and dynamic environments. Hence, it is not when the polar handles are used to build paths, that may be required, but when the polar handles themselves are constructed.

@@ -143,8 +143,8 @@ ( 5cm ^ 60° ) Yes, equivalent to (+ 5cm*[dir 60°]) ( 1%C ^ 60° ) Yes, but cannot be rewritten as above - ( ^ 0.5 ) Yes, angle in radians, may require a binding for - ( ^ ) Yes, may require a binding for + ( ^ 0.5 ) Yes, angle in radians, may require a binding for + ( ^ ) Yes, may require a binding for ( 1%C ^ ) Yes ( 1 ^ ) No, 1 is not a length ( ^ 1cm ) No, 1cm is not a float diff --git a/doc/parts/syntax/misc.sxml b/doc/parts/syntax/misc.sxml index 6c520ab7..a51c2892 100644 --- a/doc/parts/syntax/misc.sxml +++ b/doc/parts/syntax/misc.sxml @@ -160,7 +160,7 @@

  • Compute remaining angles based on the path point's position relative its neighboring path points.

    Fill in details!

  • Compute all distances to handles that are given explicitly. Note that this requires all angles to be known.

  • Propagate known distances to any free distances on the other side of a path point.

  • -
  • Use to find one value per remaining free distance. At path points where only one such value is computed, use it as it is. At path points where two such values are computed, use the smalles of these values on both sides.

  • +
  • Use to find one value per remaining free distance. At path points where only one such value is computed, use it as it is. At path points where two such values are computed, use the smalles of these values on both sides.

  • Note that the rules above means that there is a subtle difference between the following two path points: diff --git a/doc/parts/syntax/namespaces.sxml b/doc/parts/syntax/namespaces.sxml index fd4ae188..6769b442 100644 --- a/doc/parts/syntax/namespaces.sxml +++ b/doc/parts/syntax/namespaces.sxml @@ -121,7 +121,7 @@ dynamic @z identity 1 /** Introduces a binding for a dynamic variable in namespa They ways in which bindings can be introduced is discussed in detail in . In this section, we will look at how the bindings are referred to.

    -

    The different kinds of references are recognized by looking at the prefix of the identifier. For example, a lexical variable uses no special prefix, and may look like stroke or Shapes..stroke. A dynamic variable uses the prefix @, and may look like @spot or Shapes..@spot. A state is prefixed with or #, like •page, Shapes..•page, or #dst. For the current discussion of namespaces, we will use lexical variables in our examples, but the rules are the same for any kind of reference or binding.

    +

    The different kinds of references are recognized by looking at the prefix of the identifier. For example, a lexical variable uses no special prefix, and may look like stroke or Shapes..Graphics..stroke. A dynamic variable uses the prefix @, and may look like @spot or Shapes..Graphics..@spot. A state is prefixed with or #, like •page, Shapes..IO..•page, or #dst. For the current discussion of namespaces, we will use lexical variables in our examples, but the rules are the same for any kind of reference or binding.

    A lexical variable reference consists of an optional namespace qualifier and an identifier. The namespace qualifier may be either absolute, local, or relative, and contains a sequence of zero or more namespace identifiers. The length of a namespace qualifier is its number of namespace identifiers. The written representation of a namespace qualifier uses the namespace separator to separate the namespace identifiers, and has a leading namespace separator in case it is absolute, or a leading ^^ in case it is local. There is no way to visually distinguish between an identifier of a lexical binding and a namespace qualifier, so the intention needs to be clear from the context. For example, in the context of namespace paths, Shapes and MyPackage..Impl are relative namespace paths, ^^MySubPackage and ^^ are local namespace paths, while ..Shapes and .. are absolute namespace paths. The special case of a relative namespace path without any namespace identifier has an empty written representation. The namespace path .. is called the global namespace.

    diff --git a/doc/parts/tutorial/chap-basics.sxml b/doc/parts/tutorial/chap-basics.sxml index dcf10beb..45eb0bda 100644 --- a/doc/parts/tutorial/chap-basics.sxml +++ b/doc/parts/tutorial/chap-basics.sxml @@ -67,7 +67,7 @@

    When putting strokes on the page, there is a natural way of controlling where the strokes appear by simply specifying the desired coordinates. When using the special form, however, the produced graphics always ends up at the origin. We clearly need to be able to move things around… well, strictly speaking, we don't move things in , since the language is functional. What we really do is create a new object which only differs from the original by a transform, see .

    - In each transform is represented as an object in itself, which can then be applied to objects of geometric nature. For example, to create the transform that moves (shifts, see ) things 2cm to the right and 3mm down, we write (we also give a name to the transform, so that it can be referred to later): + In each transform is represented as an object in itself, which can then be applied to objects of geometric nature. For example, to create the transform that moves (shifts, see ) things 2cm to the right and 3mm down, we write (we also give a name to the transform, so that it can be referred to later):

     T1: [shift (2cm,~3mm)]
     
    @@ -79,7 +79,7 @@ T1: [shift (2cm,~3mm)]

    -

    Another very common transformation is rotation (see ): +

    Another very common transformation is rotation (see ):

     T2: [rotate 25°]
     
    @@ -118,7 +118,7 @@ lbl: (TeX `$x^{2} + y^{2}$´)

    It is almost allways the case that combining the operators is (sometimes much) more efficient than applying one transform after the other.

    -

    Well, that's about all we are going to say regarding transforms in this tutorial. Before ending, we'll just mention that there are other constructors beside the ones seen here, that (almost all) transforms can be inverted (see ), and that transforms also exist in (see ).

    +

    Well, that's about all we are going to say regarding transforms in this tutorial. Before ending, we'll just mention that there are other constructors beside the ones seen here, that (almost all) transforms can be inverted (see ), and that transforms also exist in (see ).

    @@ -176,7 +176,7 @@ lbl: (TeX `$x^{2} + y^{2}$´)
    Painting paths -

    You are already familiar with one of the path-painting functions, namely . A similar function, , will fill the path with paint instead of stroking it, and will do both. The following example also shows how to put an arrowhead on the path while stroking it. Besides, it also shows how is used to make a round spot at a given point.

    +

    You are already familiar with one of the path-painting functions, namely . A similar function, , will fill the path with paint instead of stroking it, and will do both. The following example also shows how to put an arrowhead on the path while stroking it. Besides, it also shows how is used to make a round spot at a given point.

    @@ -191,7 +191,7 @@ lbl: (TeX `$x^{2} + y^{2}$´)
    1. The arrowheads are defined in a extension file. If your compiler has the path /usr/local/bin/shapes, then the extension files are typically located in /usr/local/share/shapes/extenions/.

    2. Functions can take named arguments, and here the argument called is some kind of object which defines what the arrowhead shall look like.

    3. -
    4. As you might have guessed, also takes an argument called .

    5. +
    6. As you might have guessed, also takes an argument called .

    @@ -200,7 +200,7 @@ lbl: (TeX `$x^{2} + y^{2}$´)
    Changing graphics parameters, such as color -

    Until now, all our drawings have been black on white, and all strokes of the default width 1bp. In such properties are part of the graphics state, and gives you control over these parameters via dynamic variables (see below); just like has an impact on how smooth paths come out, controls how thick the lines coming from are.

    +

    Until now, all our drawings have been black on white, and all strokes of the default width 1bp. In such properties are part of the graphics state, and gives you control over these parameters via dynamic variables (see below); just like has an impact on how smooth paths come out, controls how thick the lines coming from are.

    As usual, we use an example to show what the most important parameters are called, and how to set them.

    diff --git a/doc/parts/tutorial/chap-hello.sxml b/doc/parts/tutorial/chap-hello.sxml index b3db52eb..49c42a56 100644 --- a/doc/parts/tutorial/chap-hello.sxml +++ b/doc/parts/tutorial/chap-hello.sxml @@ -54,14 +54,14 @@ would be a valid program. However, to display one of the fundamental language c

    In either case, make sure your file is encoded using (if you avoid the bullet character, most eight bit encodings should be fine by intended coincidence). Call the file hello.shape.

    -

    So what does the code mean? As you might have guessed, , has something to do with the page we are drawing on, and the following << is an insertion operator (borrowed from ) that takes the following argument and tacks it onto the page. The expression delimited by square brackets is a function call; here is the callee, and there is one argument. The argument is a straight path between two points, simply constructed by combining the two coordinate pairs using the connection operator .

    +

    So what does the code mean? As you namespace="..Shapes..IO" might have guessed, , has something to do with the page we are drawing on, and the following << is an insertion operator (borrowed from ) that takes the following argument and tacks it onto the page. The expression delimited by square brackets is a function call; here is the callee, and there is one argument. The argument is a straight path between two points, simply constructed by combining the two coordinate pairs using the connection operator .

    The example displays the following traits of the language

    1. Function calls have the callee inside the bracketing syntax, like in Scheme.

    2. Statements are not terminated using a designated token; statements end by themselves, like in Haskell.

    3. -
    4. States (here, ) and variables (here, ) are distinguished by belonging to different name spaces, like variables are distinguished from types in Haskell. This is called Hungarian notation, and is used also for other distinctions in .

    5. +
    6. States (here, ) and variables (here, ) are distinguished by belonging to different name spaces, like variables are distinguished from types in Haskell. This is called Hungarian notation, and is used also for other distinctions in .

    7. Coordinates are specified as pairs of lengths, as opposed to pairs of scalars, unlike many other graphics languages where there is no distinction between lengths and scalars.

    8. The syntax makes use of characters outside the ASCII range, but there is always ASCII fall-backs.

    diff --git a/doc/parts/tutorial/chap-paths.sxml b/doc/parts/tutorial/chap-paths.sxml index 1634b3f2..b66e43c3 100644 --- a/doc/parts/tutorial/chap-paths.sxml +++ b/doc/parts/tutorial/chap-paths.sxml @@ -157,13 +157,13 @@

    In this section, we shall discuss the available methods for upsampling. One of the methods refers to the Bezier spline representation of the new path, while the other methods have geometric meanings.

    -

    Beginning with the method which is not geometric, we have , which will divide each spline in two, such that the velocity is continuous through the new sample point. This will imply that the the two interpolation points around the new sample point are at equal distance (and opposite), hence the balance part of the name. It turns out that the sample point will be at spline time 0.5, so the operation is very cheap. Use this method if you need speed more than good properties of the upsampled path.

    +

    Beginning with the method which is not geometric, we have , which will divide each spline in two, such that the velocity is continuous through the new sample point. This will imply that the the two interpolation points around the new sample point are at equal distance (and opposite), hence the balance part of the name. It turns out that the sample point will be at spline time 0.5, so the operation is very cheap. Use this method if you need speed more than good properties of the upsampled path.

    -

    The method adds samples where there were inflections on the spline segments of the original path. The new path will only have spline segments without inflections, which can be a useful thing when reasoning about the path in terms of its spline segment representation.

    +

    The method adds samples where there were inflections on the spline segments of the original path. The new path will only have spline segments without inflections, which can be a useful thing when reasoning about the path in terms of its spline segment representation.

    -

    The method may be the most useful method of them all. It begins sampling at inflections (see ), and then it makes sure that each spline segment bends at most some given angle. Since it is often the parts of a path where it bends most that are difficult to work with, this method often gives you samples where you need them most.

    +

    The method may be the most useful method of them all. It begins sampling at inflections (see ), and then it makes sure that each spline segment bends at most some given angle. Since it is often the parts of a path where it bends most that are difficult to work with, this method often gives you samples where you need them most.

    -

    The last method, , simply ensures that each spline segment is shorter than some given length. The idea is simple, but it is not clear to me when this is more useful than .

    +

    The last method, , simply ensures that each spline segment is shorter than some given length. The idea is simple, but it is not clear to me when this is more useful than .

    The example below show the various methods applied to a variety of paths.

    @@ -202,7 +202,7 @@

    However, when creating a path from a sub-range of another path, the basic operation of connecting two sliders will create a path without interpolation points on the outsides. To specify interpolation points on the outside of the new path, one may attach interpolation points to the sliders before connecting them. (By using this technique with the end point sliders of a path, one can thus attach or replace interpolation points on the outside end of a complete path.)

    -

    Yet another way to join paths is to merge the end of the first path with the beginning of the second path, see for more details and an example.

    +

    Yet another way to join paths is to merge the end of the first path with the beginning of the second path, see for more details and an example.

    diff --git a/doc/parts/types/composite.sxml b/doc/parts/types/composite.sxml index 5a9bf1b0..0a4251e7 100644 --- a/doc/parts/types/composite.sxml +++ b/doc/parts/types/composite.sxml @@ -23,7 +23,7 @@ -

    An arrowhead that can use when painting paths.

    +

    An arrowhead that can use when painting paths.

    diff --git a/doc/parts/types/index.sxml b/doc/parts/types/index.sxml index 76bb0f24..6c035cbc 100644 --- a/doc/parts/types/index.sxml +++ b/doc/parts/types/index.sxml @@ -22,7 +22,7 @@ Core types -

    Presentation of the variable types defined by the core language.

    +

    Presentation of the value types defined by the core language.

    "$(EXAMPLES)" /> diff --git a/doc/parts/types/text.sxml b/doc/parts/types/text.sxml index 60d251ae..cdbcd0eb 100644 --- a/doc/parts/types/text.sxml +++ b/doc/parts/types/text.sxml @@ -23,7 +23,7 @@ -

    A font face, used with .

    +

    A font face, used with .

    @@ -61,7 +61,7 @@ - +

    Return the paths that generate the image of the glyph corresponding to , along with the kind of painting/clipping operation that should be applied to the paths to generate the image, and by how much the text drawing position should be advanced after the glyph has been painted.

    @@ -98,7 +98,7 @@ -

    Indicate wheter to stroke and/or fill rendered text, used with .

    +

    Indicate wheter to stroke and/or fill rendered text, used with .

    @@ -112,7 +112,7 @@

    The text rendering modes os correspond directly to the non-clipping text rendering modes in . The clipping rendering modes are used internally, but are only accessible to users through .

    -

    See the design note in for the motivation behind this type.

    +

    See the design note in for the motivation behind this type.

    diff --git a/examples/applications/double-pendulum.shape b/examples/applications/double-pendulum.shape index 30609d96..11e0dd1d 100644 --- a/examples/applications/double-pendulum.shape +++ b/examples/applications/double-pendulum.shape @@ -51,49 +51,49 @@ z2r: z1 + hExtend*r2*[dir ~90°] z2rr: z1 + hExtend*r2*[dir ~90°+theta1] |** Draw the ceiling -•page << @width:1mm | [[shift (0,0.5*@width)] [stroke (~1cm,0)--(1cm,0)]] +IO..•page << @width:1mm | [[shift (0,0.5*@width)] [Graphics..stroke (~1cm,0)--(1cm,0)]] -•page << armStyle | [stroke z0--z1--z2] -•page << helperStyle | [stroke z0--z1r] - << helperStyle | [stroke z1--z2r] - << helperStyle | [stroke z1--z2rr] - << armStyle & @nonstroking:GRAY_WHITE | [fillstroke [shift z1] [] [Geometry..circle rm1]] - << armStyle & @nonstroking:GRAY_WHITE | [fillstroke [shift z2] [] [Geometry..circle rm2]] +IO..•page << armStyle | [Graphics..stroke z0--z1--z2] +IO..•page << helperStyle | [Graphics..stroke z0--z1r] + << helperStyle | [Graphics..stroke z1--z2r] + << helperStyle | [Graphics..stroke z1--z2rr] + << armStyle & @nonstroking:Traits..BW..WHITE | [Graphics..fillstroke [shift z1] [] [Geometry..circle rm1]] + << armStyle & @nonstroking:Traits..BW..WHITE | [Graphics..fillstroke [shift z2] [] [Geometry..circle rm2]] { p: [Geometry..ccw_arc z0 z1r z1 15mm] - •page << angleStyle | [stroke p head:angleHead] - •page << [putlabelBelow [TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5] + IO..•page << angleStyle | [Graphics..stroke p head:angleHead] + IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5] } { p: [Geometry..ccw_arc z1 z2r z2rr 17mm] - •page << angleStyle | [stroke p head:angleHead] - •page << [putlabelBelow [TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5] + IO..•page << angleStyle | [Graphics..stroke p head:angleHead] + IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5] } { p: [Geometry..ccw_arc z1 z2rr z2 15mm] - •page << angleStyle | [stroke p head:angleHead] - •page << [putlabelBelow [TeX `$\theta_{2}$´] [Layout..mspoint p 0.5] ~0.5] + IO..•page << angleStyle | [Graphics..stroke p head:angleHead] + IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{2}$´] [Layout..mspoint p 0.5] ~0.5] } { p: [Geometry..ccw_arc z0 1mm*[dir ~150°] 1mm*[dir ~30°] 4mm] - •page << angleStyle | [stroke p head:angleHead] - •page << [putlabelBelow [TeX `$\tau$´] [Layout..mspoint p 0 1mm] 0] + IO..•page << angleStyle | [Graphics..stroke p head:angleHead] + IO..•page << [putlabelBelow [Graphics..TeX `$\tau$´] [Layout..mspoint p 0 1mm] 0] } { p: z1--(+(0,~10mm)) - •page << forceStyle | [stroke p head:forceHead] - •page << [putlabelLeft [TeX `$m_{1} g$´] p.end.p ~1] + IO..•page << forceStyle | [Graphics..stroke p head:forceHead] + IO..•page << [putlabelLeft [Graphics..TeX `$m_{1} g$´] p.end.p ~1] } { p: z2--(+(0,~10mm)) - •page << forceStyle | [stroke p head:forceHead] - •page << [putlabelLeft [TeX `$m_{2} g$´] p.end.p ~1] + IO..•page << forceStyle | [Graphics..stroke p head:forceHead] + IO..•page << [putlabelLeft [Graphics..TeX `$m_{2} g$´] p.end.p ~1] } diff --git a/examples/applications/doughnut.shape b/examples/applications/doughnut.shape index e346fff4..8ec0c1b6 100644 --- a/examples/applications/doughnut.shape +++ b/examples/applications/doughnut.shape @@ -19,30 +19,31 @@ ##needs ..Shapes..Graphics3D / revolutionbody ##lookin ..Shapes +##lookin ..Shapes..Geometry3D doughnutProfile: [Geometry..circle 1.5cm] - >> [shift (3cm,0cm)] >> immerse >> [rotate3D dir:(1,0,0) angle:~90°] + >> [shift (3cm,0cm)] >> immerse >> [Geometry3D..rotate dir:(1,0,0) angle:~90°] square: \ x → x * x doubleDoughnutProfile: -( @defaultunit:1%C +( Geometry..@defaultunit:1%C | - [[range 0° 359° 10°].foldl + [[Data..range 0° 359° 10°].foldl \ p e → { - p--(^)<((0.5cm+1cm*[square [abs [cos e]]])*[dir e])>(^) + p--(^)<((0.5cm+1cm*[square [Numeric..Math..abs [Numeric..Math..cos e]]])*[dir e])>(^) } - emptypath]--cycle + Geometry..emptypath]--cycle ) - >> [shift (3cm,0cm)] >> immerse >> [rotate3D dir:(1,0,0) angle:~90°] + >> [shift (3cm,0cm)] >> immerse >> [Geometry3D..rotate dir:(1,0,0) angle:~90°] doughnut: @nonstroking:[gray 0.8] & @width:0.01bp |** used to fill in object edges & @stroking:[gray 0.8] |** used to fill in object edges - & @join:JOIN_ROUND + & @join:Traits..Join..ROUND & @reflections:0.7*[phong 25] + 0.3*[phong 0.5] & @autointensity:[gray 0.3] & @autoscattering:[phong 0.2] @@ -52,13 +53,13 @@ doughnut: |** [Graphics3D..revolutionBody doughnutProfile phiSteps:'25 thetaSteps:'37] [Graphics3D..revolutionBody doubleDoughnutProfile phiSteps:'36 thetaSteps:'37] -lights: ( newLights << [shift (6cm,8cm,10cm)] [] [specular_light [gray 0.9]] +lights: ( Graphics3D..newLights << [shift (6cm,8cm,10cm)] [] [specular_light [gray 0.9]] |** << [ambient_light [gray 0.3]] ) -•world: newZSorter +•world: Graphics3D..newZSorter •world << lights - << [rotate3D dir:(1,0,0) angle:~70°] [] doughnut + << [Geometry3D..rotate dir:(1,0,0) angle:~70°] [] doughnut world: •world; -•page << @nonstroking:GRAY_BLACK | [fill [rectangle (~5cm,~4cm) (5cm,4cm)]] -•page << view [] world +IO..•page << @nonstroking:Traits..BW..BLACK | [Graphics..fill [Geometry..rectangle (~5cm,~4cm) (5cm,4cm)]] +IO..•page << view [] world diff --git a/examples/applications/droo.shape b/examples/applications/droo.shape index 1f25026f..c9db8a2e 100644 --- a/examples/applications/droo.shape +++ b/examples/applications/droo.shape @@ -31,30 +31,30 @@ y1: y2 - sep ypart: 0.96 d_curve: [[shift (0,y2)] - @defaultunit:1%c | (0mm,y2)>(^0°)--(1%c^)<(0.5*x3,ypart*y2)>(1%C^~10°)--(^)<(x3,0)>(^)--(1%C^10°)<(0.5*x3,~ypart*y2)>(1%c^)--(^0°)<(0mm,~y2) + Geometry..@defaultunit:1%c | (0mm,y2)>(^0°)--(1%c^)<(0.5*x3,ypart*y2)>(1%C^~10°)--(^)<(x3,0)>(^)--(1%C^10°)<(0.5*x3,~ypart*y2)>(1%c^)--(^0°)<(0mm,~y2) ] r_curve: [[shift (0,y2)] - @defaultunit:1%c | (0mm,y1)>(^0°)--(1%c^)<(0.5*x2,ypart*y1)>(1%C^~10°)--(^)<(x2,0)>(^)--(1%C^10°)<(0.5*x2,~ypart*y1)>(1%c^)--(^0°)<(0mm,~y1) + Geometry..@defaultunit:1%c | (0mm,y1)>(^0°)--(1%c^)<(0.5*x2,ypart*y1)>(1%C^~10°)--(^)<(x2,0)>(^)--(1%C^10°)<(0.5*x2,~ypart*y1)>(1%c^)--(^0°)<(0mm,~y1) ] fillColor: @nonstroking:[rgb 205/255 49/255 0/255] -•page << fillColor | [fill d_curve--[reverse r_curve]--cycle] +IO..•page << fillColor | [Graphics..fill d_curve--[Geometry..reverse r_curve]--cycle] -•page << @width:t3 & @cap:CAP_BUTT | [stroke (0cm,2*y2)--(0mm,0mm)] -•page << @width:t2 & @cap:CAP_ROUND & @defaultunit:1%c | [stroke (x1,2*y2)--d_curve--(x1,0mm)] -•page << @width:t2 & @cap:CAP_ROUND & @defaultunit:1%c | [stroke r_curve] +IO..•page << @width:t3 & @cap:Traits..Cap..BUTT | [Graphics..stroke (0cm,2*y2)--(0mm,0mm)] +IO..•page << @width:t2 & @cap:Traits..Cap..ROUND & Geometry..@defaultunit:1%c | [Graphics..stroke (x1,2*y2)--d_curve--(x1,0mm)] +IO..•page << @width:t2 & @cap:Traits..Cap..ROUND & Geometry..@defaultunit:1%c | [Graphics..stroke r_curve] r_point: (7mm,~2mm) r_ray: r_point--(r_curve.end - 3mm).p -•page << @width:t2 & @cap:CAP_ROUND & @defaultunit:1%c | [stroke r_ray] +IO..•page << @width:t2 & @cap:Traits..Cap..ROUND & Geometry..@defaultunit:1%c | [Graphics..stroke r_ray] o_radius: 1.2mm @width:t1 | { radius: o_radius c: [shift (x1,radius-0.5*t2+0.5*@width)][][Geometry..circle radius] - •page << fillColor | [fill c] - •page << [stroke c] + IO..•page << fillColor | [Graphics..fill c] + IO..•page << [Graphics..stroke c] } @width:t1 | @@ -62,6 +62,6 @@ o_radius: 1.2mm radius: o_radius sl: r_ray.begin c: [shift sl.p]*[rotate 180°+[angle sl.T]]*[shift (0,radius-0.5*t2+0.5*@width)] [] [Geometry..circle radius] - •page << fillColor | [fill c] - •page << [stroke c] + IO..•page << fillColor | [Graphics..fill c] + IO..•page << [Graphics..stroke c] } diff --git a/examples/applications/logo.shape b/examples/applications/logo.shape index 8bef8423..d6ac7242 100644 --- a/examples/applications/logo.shape +++ b/examples/applications/logo.shape @@ -31,20 +31,20 @@ yellow: @stroking:[rgb 1 0.7 0] blue: @stroking:[rgb 0.3 0.6 1] thickStyle: @width:3bp -thinStyle: @width:1.5bp & yellow & @cap:CAP_ROUND +thinStyle: @width:1.5bp & yellow & @cap:Traits..Cap..ROUND succedesArrow: { bentPath: (0cm,0cm)>(1%C^0°)--(1%c^)<(+(1cm*[dir 40°]))>(^40°) \ p ahLength:void ahAngle:30° tailAngle:60° → - (@blend:BLEND_NORMAL + (@blend:Traits..Blend..NORMAL | { sl: [p 0] z: sl.p d: [angle sl.T] - theLength: [if [typeof ahLength]=§Void @width*6 ahLength] + theLength: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] (> - picture: @cap:CAP_BUTT | [shift sl.p]*[rotate [angle sl.T]] [] [stroke ([rotate ~0.5*ahAngle]*[scale theLength/1cm][]bentPath) & ([rotate 0.5*ahAngle]*[scale y:~1]*[scale theLength/1cm][]bentPath)] + picture: @cap:Traits..Cap..BUTT | [shift sl.p]*[rotate [angle sl.T]] [] [Graphics..stroke ([rotate ~0.5*ahAngle]*[scale theLength/1cm][]bentPath) & ([rotate 0.5*ahAngle]*[scale y:~1]*[scale theLength/1cm][]bentPath)] cut: 0bp <) } @@ -58,38 +58,38 @@ s_path: (0u,0u)>(0.8%c^140°)--(0.8%c^)<(~1.1u,0u)>(^~120°)--(^)<(0.5u,~1.4u)>( arrowLength: 10u -sl1: [maximizer s_path [dir 108°]] +sl1: [Geometry..maximizer s_path [dir 108°]] the_c: sl1.p+sl1.ik*sl1.N hook: [[shift sl1.p]*[scale ~1]*[shift ~sl1.p] s_path.begin--sl1] rotateAbout: \ z angle → [shift z]*[rotate angle]*[shift ~z] hookCount:'3 -•page << yellow & thickStyle & @nonstroking:[gray 0.94] | [fillstroke [shift the_c] [] [Geometry..circle sl1.ik]] - << yellow & thickStyle & @cap:CAP_ROUND | [[range '1 hookCount].foldl \ p e → ( p & [[rotateAbout the_c 360°/hookCount*(e-'1)] [stroke hook]] ) null] +IO..•page << yellow & thickStyle & @nonstroking:[gray 0.94] | [Graphics..fillstroke [shift the_c] [] [Geometry..circle sl1.ik]] + << yellow & thickStyle & @cap:Traits..Cap..ROUND | [[Data..range '1 hookCount].foldl \ p e → ( p & [[rotateAbout the_c 360°/hookCount*(e-'1)] [Graphics..stroke hook]] ) null] -sl2: [maximizer s_path [dir ~10°]]-3u +sl2: [Geometry..maximizer s_path [dir ~10°]]-3u the_c2: sl2.p+sl2.ik*sl2.N -•page << yellow & thickStyle | [stroke [shift the_c2] [] [Geometry..circle sl2.ik]] +IO..•page << yellow & thickStyle | [Graphics..stroke [shift the_c2] [] [Geometry..circle sl2.ik]] -subPath: [Geometry..sidepath2 [upsample_every 2u sl1--sl2] 1u] +subPath: [Geometry..sidepath2 [Geometry..upsample_every 2u sl1--sl2] 1u] -•page << thickStyle & @cap:CAP_ROUND | [stroke s_path] -|** << h_style | [stroke [controlling s_path]] +IO..•page << thickStyle & @cap:Traits..Cap..ROUND | [Graphics..stroke s_path] +|** << h_style | [Graphics..stroke [Geometry..controlling s_path]] -•page << h_style | [stroke subPath] +IO..•page << h_style | [Graphics..stroke subPath] -•page << h_style | [stroke [shift sl1.p] [] [Geometry..circle 1u]] -•page << thinStyle | [stroke sl1.p--(+(sl1.T*arrowLength)) head:succedesArrow] -•page << thinStyle | [stroke sl1.p--(+(sl1.N*arrowLength)) head:succedesArrow] +IO..•page << h_style | [Graphics..stroke [shift sl1.p] [] [Geometry..circle 1u]] +IO..•page << thinStyle | [Graphics..stroke sl1.p--(+(sl1.T*arrowLength)) head:succedesArrow] +IO..•page << thinStyle | [Graphics..stroke sl1.p--(+(sl1.N*arrowLength)) head:succedesArrow] -•page << h_style | [stroke [shift sl2.p] [] [Geometry..circle 1u]] -•page << thinStyle | [stroke sl2.p--(+(sl2.T*arrowLength)) head:succedesArrow] -•page << thinStyle | [stroke sl2.p--(+(sl2.N*arrowLength)) head:succedesArrow] +IO..•page << h_style | [Graphics..stroke [shift sl2.p] [] [Geometry..circle 1u]] +IO..•page << thinStyle | [Graphics..stroke sl2.p--(+(sl2.T*arrowLength)) head:succedesArrow] +IO..•page << thinStyle | [Graphics..stroke sl2.p--(+(sl2.N*arrowLength)) head:succedesArrow] @nonstroking:(blue|@stroking) | { - •page << [shift sl2.p+sl2.N*(arrowLength+1u)] [] [Layout..center [TeXScale [TeX `$\lambda$´]] (~1,0)] - •page << [shift the_c2] [] [Layout..center [TeXScale [TeX `@´]] (0,0)] - •page << [shift the_c+(2u,~sl1.ik+1u)] [] [Layout..center [TeXScale [TeX `\#´]] (0,~1)] + IO..•page << [shift sl2.p+sl2.N*(arrowLength+1u)] [] [Layout..center [TeXScale [Graphics..TeX `$\lambda$´]] (~1,0)] + IO..•page << [shift the_c2] [] [Layout..center [TeXScale [Graphics..TeX `@´]] (0,0)] + IO..•page << [shift the_c+(2u,~sl1.ik+1u)] [] [Layout..center [TeXScale [Graphics..TeX `\#´]] (0,~1)] } diff --git a/examples/applications/pinhole.shape b/examples/applications/pinhole.shape index 0b10f81c..86044860 100644 --- a/examples/applications/pinhole.shape +++ b/examples/applications/pinhole.shape @@ -21,11 +21,12 @@ ##needs ..Shapes..Graphics3D / metapostarrow ##lookin ..Shapes +##lookin ..Shapes..Geometry3D ##lookin ..Applications..Blockdraw ##unit u = 1cm -pointMark: [facing [fill [Geometry..circle 2bp]]] +pointMark: [facing [Graphics..fill [Geometry..circle 2bp]]] baseVectors3D: \ nx ny nz → { @@ -33,14 +34,14 @@ baseVectors3D: \ nx ny nz → tmpHead: [Graphics3D..MetaPostArrow ahLength:3mm ...] @width: 1.5bp | - ( newGroup3D + ( Graphics3D..newGroup << pointMark - << [stroke (0u,0u,0u)--(len,0u,0u) head:[tmpHead normal:nx ...]] - << [stroke (0u,0u,0u)--(0u,len,0u) head:[tmpHead normal:ny ...]] - << [stroke (0u,0u,0u)--(0u,0u,len) head:[tmpHead normal:nz ...]] - << [tag 'x (len,0u,0u)] - << [tag 'y (0u,len,0u)] - << [tag 'z (0u,0u,len)] + << [Graphics..stroke (0u,0u,0u)--(len,0u,0u) head:[tmpHead normal:nx ...]] + << [Graphics..stroke (0u,0u,0u)--(0u,len,0u) head:[tmpHead normal:ny ...]] + << [Graphics..stroke (0u,0u,0u)--(0u,0u,len) head:[tmpHead normal:nz ...]] + << [Graphics..Tag..tag 'x (len,0u,0u)] + << [Graphics..Tag..tag 'y (0u,len,0u)] + << [Graphics..Tag..tag 'z (0u,0u,len)] ) } @@ -52,16 +53,16 @@ baseVectors2D: \ → tmpHead: [Graphics3D..MetaPostArrow ahLength:2mm ahAngle:60° ...] @width: 0.6bp | - ( newGroup3D + ( Graphics3D..newGroup << pointMark - << [stroke (0u,0u,0u)--(len,0u,0u) head:[tmpHead normal:nx ...]] - << [stroke (0u,0u,0u)--(0u,len,0u) head:[tmpHead normal:ny ...]] - << [tag 'x (len,0u,0u)] - << [tag 'y (0u,len,0u)] + << [Graphics..stroke (0u,0u,0u)--(len,0u,0u) head:[tmpHead normal:nx ...]] + << [Graphics..stroke (0u,0u,0u)--(0u,len,0u) head:[tmpHead normal:ny ...]] + << [Graphics..Tag..tag 'x (len,0u,0u)] + << [Graphics..Tag..tag 'y (0u,len,0u)] ) } -•world: newGroup3D +•world: Graphics3D..newGroup /** ** We draw the picture in the camera's coordinates @@ -76,73 +77,73 @@ p: [Layout..mspoint C--P f/P.z] { base: [baseVectors3D (0,0,1) (0,0,1) (1,0,0)] •world << base - << [shift [find base 'x]] [] [facing [putlabelBelow [TeX `$x$´] (0m,0m) ~1]] - << [shift [find base 'y]] [] [facing [putlabelRight [TeX `$y$´] (0m,0m) ~1]] - << [shift [find base 'z]] [] [facing [putlabelAbove [TeX `$z$´] (0m,0m) 1]] + << [shift [Graphics..Tag..find base 'x]] [] [facing [putlabelBelow [Graphics..TeX `$x$´] (0m,0m) ~1]] + << [shift [Graphics..Tag..find base 'y]] [] [facing [putlabelRight [Graphics..TeX `$y$´] (0m,0m) ~1]] + << [shift [Graphics..Tag..find base 'z]] [] [facing [putlabelAbove [Graphics..TeX `$z$´] (0m,0m) 1]] } -•rayWorld: newZSorter -•rayWorld << [stroke C--P] -•rayWorld << @dash:[dashpattern 1mm 1mm] | [stroke C--P0] +•rayWorld: Graphics3D..newZSorter +•rayWorld << [Graphics..stroke C--P] +•rayWorld << @dash:[dashpattern 1mm 1mm] | [Graphics..stroke C--P0] { sz: 1.5u - imageFrame: [shift (0u,0u,f)] [] [immerse [rectangle (~sz,~sz) (sz,sz)]] - •world << [tag 'frame imageFrame] - •rayWorld << @nonstroking:GRAY_WHITE | [fill imageFrame] - •rayWorld << [stroke imageFrame] + imageFrame: [shift (0u,0u,f)] [] [immerse [Geometry..rectangle (~sz,~sz) (sz,sz)]] + •world << [Graphics..Tag..tag 'frame imageFrame] + •rayWorld << @nonstroking:Traits..BW..WHITE | [Graphics..fill imageFrame] + •rayWorld << [Graphics..stroke imageFrame] } rayWorld: •rayWorld; •world << rayWorld { base: [shift (0u,0u,f)] [] [baseVectors2D] •world << base - << [shift [find base 'x]] [] [facing [putlabelAbove [TeX `$x$´] (0m,0m) ~1]] - << [shift [find base 'y]] [] [facing [putlabelRight [TeX `$y$´] (0m,0m) ~1]] + << [shift [Graphics..Tag..find base 'x]] [] [facing [putlabelAbove [Graphics..TeX `$x$´] (0m,0m) ~1]] + << [shift [Graphics..Tag..find base 'y]] [] [facing [putlabelRight [Graphics..TeX `$y$´] (0m,0m) ~1]] } { - bracePath: [rotate3D dir:(0,1,0) angle:~90°] [] [immerse [Graphics..someClosedBrace (f,0u) (0u,0u)]] - •world << [fill bracePath] + bracePath: [Geometry3D..rotate dir:(0,1,0) angle:~90°] [] [immerse [Graphics..someClosedBrace (f,0u) (0u,0u)]] + •world << [Graphics..fill bracePath] |** Next, I use that I happen to know that the tip of the brace is at path time 1. - •world << [shift [bracePath 1].p] [] [facing [putlabelBelow [TeX `$\mathrm{f}$´] (0m,0m) 0]] + •world << [shift [bracePath 1].p] [] [facing [putlabelBelow [Graphics..TeX `$\mathrm{f}$´] (0m,0m) 0]] } -•world << [shift C] [] [facing [putlabelAbove [TeX `$\mathrm{C}$´] (0m,0m) 1]] - << [tag 'C C] +•world << [shift C] [] [facing [putlabelAbove [Graphics..TeX `$\mathrm{C}$´] (0m,0m) 1]] + << [Graphics..Tag..tag 'C C] << [shift P] [] pointMark - << [tag 'P P] - << [shift P] [] [facing [putlabelBelow [TeX `$P$´] (0m,0m) 0]] + << [Graphics..Tag..tag 'P P] + << [shift P] [] [facing [putlabelBelow [Graphics..TeX `$P$´] (0m,0m) 0]] << [shift p] [] pointMark - << [shift p] [] [facing [putlabelLeft [TeX `$p$´] (0m,0m) 1]] - << [tag 'P0 P0] - << [tag 'planePoint [shift (0u,0u,f)][][immerse (0.3u,~1u)]] + << [shift p] [] [facing [putlabelLeft [Graphics..TeX `$p$´] (0m,0m) 1]] + << [Graphics..Tag..tag 'P0 P0] + << [Graphics..Tag..tag 'planePoint [shift (0u,0u,f)][][immerse (0.3u,~1u)]] -flatWorld: (•world) >> [shift (~30u,~5u,0u)]*[rotate3D dir:(1,0,0) angle:180°]*[rotate3D dir:(0,1,0) angle:90°] >> view -•page << flatWorld +flatWorld: (•world) >> [shift (~30u,~5u,0u)]*[Geometry3D..rotate dir:(1,0,0) angle:180°]*[Geometry3D..rotate dir:(0,1,0) angle:90°] >> view +IO..•page << flatWorld @width: 0.5bp -& @defaultunit: 1%C +& Geometry..@defaultunit: 1%C | { lblArrow: Graphics..ShapesArrow { - pt: [find flatWorld 'C] + pt: [Graphics..Tag..find flatWorld 'C] lblPt: pt + (0.3u,1u) - •page << [shift lblPt] [] [Layout..center [TeX `\begin{minipage}{1cm}\centering optical\\center\end{minipage}´] (0,~1)] - •page << [stroke lblPt>(^~80°)--(^60°)(^~80°)--(^60°)(^~100°)--(^90°)(^~100°)--(^90°)(^10°)--(^180°)(~1cm,~1cm,~1cm)--(1cm,~1cm,~2cm)<(1cm,0cm,~2cm)>(1cm,1cm,~2cm) deeper: \ n → [shift (0cm,0cm,n*~2cm)] -screw: [scale3D 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle +screw: [Geometry3D..scale 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle -•world: newGroup3D +•world: Graphics3D..newGroup -•world << @width:0.3bp & @stroking:[gray 0.5] | [stroke screw] +•world << @width:0.3bp & @stroking:[gray 0.5] | [Graphics..stroke screw] markStart: 0.15 markCount: '5 -paintLeg: \ pth → ( [stroke pth] & ( @nonstroking:RGB_BLACK | [fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) ) +paintLeg: \ pth → ( [Graphics..stroke pth] & ( @nonstroking:Traits..RGB..BLACK | [Graphics..fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) ) •world << - [[range '0 markCount-'1].foldl + [[Data..range '0 markCount-'1].foldl \ p i → { - sl: [screw (markStart + i*(1/markCount))*[abs screw]] + sl: [screw (markStart + i*(1/markCount))*[Numeric..Math..abs screw]] len: 2.5cm p & - ( newGroup3D - << @stroking:RGB_RED | [paintLeg sl.p--(+(len*sl.T))] - << @stroking:RGB_GREEN | [paintLeg sl.p--(+(len*sl.N))] - << @stroking:RGB_BLUE | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))] - << [shift sl.p+(~2mm,3mm,0mm)] [] [facing [Layout..center_x [TeX [sprintf `\textbf{%d}´ i+'1]]]] ) + ( Graphics3D..newGroup + << @stroking:Traits..RGB..RED | [paintLeg sl.p--(+(len*sl.T))] + << @stroking:Traits..RGB..GREEN | [paintLeg sl.p--(+(len*sl.N))] + << @stroking:Traits..RGB..BLUE | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))] + << [shift sl.p+(~2mm,3mm,0mm)] [] [facing [Layout..center_x [Graphics..TeX [String..sprintf `\textbf{%d}´ i+'1]]]] ) } - null3D] + Graphics3D..null] -•world << [shift (~1.5cm,~1.5cm,0cm)] [] [facing [Layout..center_x [TeX `Odd one out!´]]] +•world << [shift (~1.5cm,~1.5cm,0cm)] [] [facing [Layout..center_x [Graphics..TeX `Odd one out!´]]] world: •world; { eyew: 5.0cm lift: 0.5*@eyez - world: [scale3D 0.4]*[rotate3D (1,1,1) 30°] [] ../world - •page << world >> [shift (0.5*eyew,0cm,lift)] >> view >> [shift (~0.5*eyew,0cm)] - •page << world >> [shift (~0.5*eyew,0cm,lift)] >> view >> [shift (0.5*eyew,0cm)] + world: [Geometry3D..scale 0.4]*[Geometry3D..rotate (1,1,1) 30°] [] ../world + IO..•page << world >> [shift (0.5*eyew,0cm,lift)] >> view >> [shift (~0.5*eyew,0cm)] + IO..•page << world >> [shift (~0.5*eyew,0cm,lift)] >> view >> [shift (0.5*eyew,0cm)] } diff --git a/examples/applications/spacebase.shape b/examples/applications/spacebase.shape index a400c957..efe36e0b 100644 --- a/examples/applications/spacebase.shape +++ b/examples/applications/spacebase.shape @@ -17,44 +17,45 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -rot: [rotate3D (1,1,1) 30°] +rot: [Geometry3D..rotate (1,1,1) 30°] screwSeg: (~1cm,1cm,~1cm)<(~1cm,0cm,~1cm)>(~1cm,~1cm,~1cm)--(1cm,~1cm,~2cm)<(1cm,0cm,~2cm)>(1cm,1cm,~2cm) deeper: \ n → [shift (0cm,0cm,n*~2cm)] -screw: [scale3D 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle +screw: [Geometry3D..scale 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle -•world: newGroup3D +•world: Graphics3D..newGroup -•world << @width:0.3bp & @stroking:[gray 0.5] | [stroke screw] +•world << @width:0.3bp & @stroking:[gray 0.5] | [Graphics..stroke screw] markStart: 0.15 markCount: '5 -paintLeg: \ pth → ( [stroke pth] & ( @nonstroking:RGB_BLACK | [fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) ) +paintLeg: \ pth → ( [Graphics..stroke pth] & ( @nonstroking:Traits..RGB..BLACK | [Graphics..fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) ) •world << - [[range '0 markCount-'1].foldl + [[Data..range '0 markCount-'1].foldl \ p i → { - sl: [screw (markStart + i*(1/markCount))*[abs screw]] + sl: [screw (markStart + i*(1/markCount))*[Numeric..Math..abs screw]] len: 2.5cm p & - ( newGroup3D - << @stroking:RGB_RED | [paintLeg sl.p--(+(len*sl.T))] - << @stroking:RGB_GREEN | [paintLeg sl.p--(+(len*sl.N))] - << @stroking:RGB_BLUE | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))] - << [shift sl.p+(~2mm,3mm,0mm)] [] [facing [Layout..center_x [TeX [sprintf `\textbf{%d}´ i+'1]]]] ) + ( Graphics3D..newGroup + << @stroking:Traits..RGB..RED | [paintLeg sl.p--(+(len*sl.T))] + << @stroking:Traits..RGB..GREEN | [paintLeg sl.p--(+(len*sl.N))] + << @stroking:Traits..RGB..BLUE | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))] + << [shift sl.p+(~2mm,3mm,0mm)] [] [facing [Layout..center_x [Graphics..TeX [String..sprintf `\textbf{%d}´ i+'1]]]] ) } - null3D] + Graphics3D..null] -•world << [shift (~1.5cm,~1.5cm,0cm)] [] [facing [Layout..center_x [TeX `Odd one out!´]]] +•world << [shift (~1.5cm,~1.5cm,0cm)] [] [facing [Layout..center_x [Graphics..TeX `Odd one out!´]]] world: •world; { - world: [rotate3D (1,1,1) 30°] [] ../world + world: [Geometry3D..rotate (1,1,1) 30°] [] ../world eyew: 5.0cm - •page << view [] world - •page << world >> [shift (~eyew,0cm,0cm)] >> view >> [shift (2*eyew,0cm)] + IO..•page << view [] world + IO..•page << world >> [shift (~eyew,0cm,0cm)] >> view >> [shift (2*eyew,0cm)] } diff --git a/examples/applications/vild.shape b/examples/applications/vild.shape index daaafb27..b736c90b 100644 --- a/examples/applications/vild.shape +++ b/examples/applications/vild.shape @@ -1,6 +1,6 @@ ##lookin ..Shapes -•page << @text_size:10bp & @text_font:[font `Berlin Sans FB.ttf´] | ( newText << `Friluftsföreningen´ ) >> [shift (0,1bp)] -•page << @text_size:32bp & @text_font:[font `MaturaMTScriptCapitals.ttf´] | ( newText << `Vild!´ ) >> [Layout..center z:(~1,1) ...] >> [shift (~0.1*@text_size,0)] +IO..•page << Text..@size:10bp & Text..@font:[font `Berlin Sans FB.ttf´] | ( Text..newText << `Friluftsföreningen´ ) >> [shift (0,1bp)] +IO..•page << Text..@size:32bp & Text..@font:[font `MaturaMTScriptCapitals.ttf´] | ( Text..newText << `Vild!´ ) >> [Layout..center z:(~1,1) ...] >> [shift (~0.1*Text..@size,0)] -[Layout..enlarge_bleedbox (•page) (2bp,2bp)] +[Layout..enlarge_bleedbox (IO..•page) (2bp,2bp)] diff --git a/examples/doc/blockdraw-blocks.shape b/examples/doc/blockdraw-blocks.shape index df25048d..b364d676 100644 --- a/examples/doc/blockdraw-blocks.shape +++ b/examples/doc/blockdraw-blocks.shape @@ -26,17 +26,17 @@ helper: \ pos obj → [[shift pos] - obj & [[shift (0,~0.5dy)] [Layout..shiftoff_wlm @text_font:FONT_COURIER | (newText << [sourceof obj]) Layout..to_top]]] + obj & [[shift (0,~0.5dy)] [Layout..shiftoff_wlm Text..@font:Text..Font..COURIER | (Text..newText << [Debug..sourceof obj]) Layout..to_top]]] -•page << [helper (1dx,1dy) [locate [sumpicture]]] -•page << [helper (2dx,1dy) [locate [squareblock [TeX `$-1$´]]]] -•page << [helper (3dx,1dy) [locate [splitdot]]] -•page << [helper (4dx,1dy) [locate [termcircle]]] -•page << [helper (1dx,0dy) [locate [longblock [TeX `$F$´]]]] -•page << [helper (1dx,~1dy) [locate [longenoughblock [TeX `$F$´]]]] -•page << [helper (1dx,~2dy) [locate [longenoughblock [TeX `Regulator 1´]]]] -•page << [helper (3dx,0dy) [locate [fracblock [TeX `$\frac{1+s}{2+s^{2}}$´]]]] -•page << [helper (3dx,~1dy) [locate [longenoughfracblock [TeX `$\frac{1+s}{2+s^{2}}$´]]]] -•page << [helper (3dx,~2dy) [locate [longenoughfracblock [TeX `$\frac{1+s+s^{2}+s^{3}+s^{4}}{2+s^{5}}$´]]]] -•page << [helper (1dx,~3dy) [locate [sizedblock [TeX `$\pi$´] 2mm 2mm]]] -•page << [helper (3dx,~3dy) [locate [roundblock [TeX `$\Pi$´]]]] +IO..•page << [helper (1dx,1dy) [Debug..locate [sumpicture]]] +IO..•page << [helper (2dx,1dy) [Debug..locate [squareblock [Graphics..TeX `$-1$´]]]] +IO..•page << [helper (3dx,1dy) [Debug..locate [splitdot]]] +IO..•page << [helper (4dx,1dy) [Debug..locate [termcircle]]] +IO..•page << [helper (1dx,0dy) [Debug..locate [longblock [Graphics..TeX `$F$´]]]] +IO..•page << [helper (1dx,~1dy) [Debug..locate [longenoughblock [Graphics..TeX `$F$´]]]] +IO..•page << [helper (1dx,~2dy) [Debug..locate [longenoughblock [Graphics..TeX `Regulator 1´]]]] +IO..•page << [helper (3dx,0dy) [Debug..locate [fracblock [Graphics..TeX `$\frac{1+s}{2+s^{2}}$´]]]] +IO..•page << [helper (3dx,~1dy) [Debug..locate [longenoughfracblock [Graphics..TeX `$\frac{1+s}{2+s^{2}}$´]]]] +IO..•page << [helper (3dx,~2dy) [Debug..locate [longenoughfracblock [Graphics..TeX `$\frac{1+s+s^{2}+s^{3}+s^{4}}{2+s^{5}}$´]]]] +IO..•page << [helper (1dx,~3dy) [Debug..locate [sizedblock [Graphics..TeX `$\pi$´] 2mm 2mm]]] +IO..•page << [helper (3dx,~3dy) [Debug..locate [roundblock [Graphics..TeX `$\Pi$´]]]] diff --git a/examples/doc/blockdraw-con-points.shape b/examples/doc/blockdraw-con-points.shape dissimilarity index 60% index 48642cca..56ac5941 100644 --- a/examples/doc/blockdraw-con-points.shape +++ b/examples/doc/blockdraw-con-points.shape @@ -1,58 +1,58 @@ -/** This file is part of Shapes. - ** - ** Shapes is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** any later version. - ** - ** Shapes is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Shapes. If not, see . - ** - ** Copyright 2008, 2010, 2014 Henrik Tidefelt - **/ - -##needs ..Applications..Blockdraw - -##lookin ..Shapes -##lookin ..Applications..Blockdraw - -##unit dx = 6cm -##unit dy = 3cm - -F: [longblock [TeX `$F$´]] -S: [sumpicture] - -helper: \ pos pt blk → -[[shift pos] - blk & (@width:4bp & @stroking:RGB_RED | [spot pt]) - & - [[shift (0,~0.5dy)] [Layout..shiftoff_wlm @text_font:FONT_COURIER | (newText << [sourceof pt]) Layout..to_top]]] - -•page << [helper (1dx,0dy) [locate [leftpoint F]] F] -•page << [helper (2dx,0dy) [locate [leftpoint F 2]] F] -•page << [helper (3dx,0dy) [locate [leftpoint F 2 1]] F] -•page << [helper (4dx,0dy) [locate [leftpoint F 2 2]] F] -•page << [helper (5dx,0dy) [locate [leftpoint F 2 3]] F] - -•page << [helper (1dx,~1dy) [locate [rightpoint F]] F] -•page << [helper (2dx,~1dy) [locate [rightpoint F 3]] F] -•page << [helper (3dx,~1dy) [locate [rightpoint F 3 1]] F] -•page << [helper (4dx,~1dy) [locate [rightpoint F 3 2]] F] -•page << [helper (5dx,~1dy) [locate [rightpoint F 3 3]] F] - -•page << [helper (1dx,~2dy) [locate [bottompoint F]] F] -•page << [helper (2dx,~2dy) [locate [bottompoint F 4]] F] -•page << [helper (3dx,~2dy) [locate [bottompoint F 4 1]] F] -•page << [helper (4dx,~2dy) [locate [bottompoint F 4 2]] F] -•page << [helper (5dx,~2dy) [locate [bottompoint F 4 3]] F] - -•page << [helper (1dx,~3dy) [locate [toppoint S]] S] -•page << [helper (2dx,~3dy) [locate [toppoint S 5]] S] -•page << [helper (3dx,~3dy) [locate [toppoint S 5 1]] S] -•page << [helper (4dx,~3dy) [locate [toppoint S 5 2]] S] -•page << [helper (5dx,~3dy) [locate [toppoint S 5 3]] S] +/** This file is part of Shapes. + ** + ** Shapes is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** any later version. + ** + ** Shapes is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Shapes. If not, see . + ** + ** Copyright 2008, 2010, 2014 Henrik Tidefelt + **/ + +##needs ..Applications..Blockdraw + +##lookin ..Shapes +##lookin ..Applications..Blockdraw + +##unit dx = 6cm +##unit dy = 3cm + +F: [longblock [Graphics..TeX `$F$´]] +S: [sumpicture] + +helper: \ pos pt blk → +[[shift pos] + blk & (@width:4bp & @stroking:Traits..RGB..RED | [spot pt]) + & + [[shift (0,~0.5dy)] [Layout..shiftoff_wlm Text..@font:Text..Font..COURIER | (Text..newText << [Debug..sourceof pt]) Layout..to_top]]] + +IO..•page << [helper (1dx,0dy) [Debug..locate [leftpoint F]] F] +IO..•page << [helper (2dx,0dy) [Debug..locate [leftpoint F 2]] F] +IO..•page << [helper (3dx,0dy) [Debug..locate [leftpoint F 2 1]] F] +IO..•page << [helper (4dx,0dy) [Debug..locate [leftpoint F 2 2]] F] +IO..•page << [helper (5dx,0dy) [Debug..locate [leftpoint F 2 3]] F] + +IO..•page << [helper (1dx,~1dy) [Debug..locate [rightpoint F]] F] +IO..•page << [helper (2dx,~1dy) [Debug..locate [rightpoint F 3]] F] +IO..•page << [helper (3dx,~1dy) [Debug..locate [rightpoint F 3 1]] F] +IO..•page << [helper (4dx,~1dy) [Debug..locate [rightpoint F 3 2]] F] +IO..•page << [helper (5dx,~1dy) [Debug..locate [rightpoint F 3 3]] F] + +IO..•page << [helper (1dx,~2dy) [Debug..locate [bottompoint F]] F] +IO..•page << [helper (2dx,~2dy) [Debug..locate [bottompoint F 4]] F] +IO..•page << [helper (3dx,~2dy) [Debug..locate [bottompoint F 4 1]] F] +IO..•page << [helper (4dx,~2dy) [Debug..locate [bottompoint F 4 2]] F] +IO..•page << [helper (5dx,~2dy) [Debug..locate [bottompoint F 4 3]] F] + +IO..•page << [helper (1dx,~3dy) [Debug..locate [toppoint S]] S] +IO..•page << [helper (2dx,~3dy) [Debug..locate [toppoint S 5]] S] +IO..•page << [helper (3dx,~3dy) [Debug..locate [toppoint S 5 1]] S] +IO..•page << [helper (4dx,~3dy) [Debug..locate [toppoint S 5 2]] S] +IO..•page << [helper (5dx,~3dy) [Debug..locate [toppoint S 5 3]] S] diff --git a/examples/doc/blockdraw-connections-connect.shape b/examples/doc/blockdraw-connections-connect.shape index bd481826..e27f398e 100644 --- a/examples/doc/blockdraw-connections-connect.shape +++ b/examples/doc/blockdraw-connections-connect.shape @@ -21,8 +21,8 @@ ##lookin ..Shapes ##lookin ..Applications..Blockdraw -from: [longblock [TeX `From´]] -to: [longblock [TeX `To´]] +from: [longblock [Graphics..TeX `From´]] +to: [longblock [Graphics..TeX `To´]] dynamic @to identity to @@ -33,10 +33,10 @@ helper: \ start → •dst: newGroup •dst << from - [[range '0 '11 '3].foldsl - \ •page p e → + [[Data..range '0 '11 '3].foldsl + \ IO..•page p e → { - [dynShift 3cm*[dir (e*1+start)*(360°/'12)]] | { •page << @to [ignore [connect •page from @to]] } + [dynShift 3cm*[dir (e*1+start)*(360°/'12)]] | { IO..•page << @to [ignore [connect IO..•page from @to]] } p } void @@ -45,7 +45,7 @@ helper: \ start → } ##unit dx = 8cm -•page << [shift (0dx,0cm)] [] [helper 0] -•page << [shift (1dx,0cm)] [] [helper 0.5] -•page << [shift (2dx,0cm)] [] [helper 1] -•page << [shift (3dx,0cm)] [] [helper 2] +IO..•page << [shift (0dx,0cm)] [] [helper 0] +IO..•page << [shift (1dx,0cm)] [] [helper 0.5] +IO..•page << [shift (2dx,0cm)] [] [helper 1] +IO..•page << [shift (3dx,0cm)] [] [helper 2] diff --git a/examples/doc/blockdraw-connections-intermediate.shape b/examples/doc/blockdraw-connections-intermediate.shape index c95018bf..973d5499 100644 --- a/examples/doc/blockdraw-connections-intermediate.shape +++ b/examples/doc/blockdraw-connections-intermediate.shape @@ -24,18 +24,18 @@ ##unit dx = 8cm ##unit dy = 5cm -from: [longblock [TeX `From´]] -to: [longblock [TeX `To´]] +from: [longblock [Graphics..TeX `From´]] +to: [longblock [Graphics..TeX `To´]] dynamic @from identity from dynamic @to identity to helper: \ pth → ( -@text_font:FONT_COURIER +Text..@font:Text..Font..COURIER | (@from & @to - & [[shift [bottompoint @to & @from]+(1cm,~0.5cm)] [Layout..shiftoff_wlm (newText << [sourceof pth]) Layout..to_bot]]) + & [[shift [bottompoint @to & @from]+(1cm,~0.5cm)] [Layout..shiftoff_wlm (Text..newText << [Debug..sourceof pth]) Layout..to_bot]]) ) dynShift1: \ pos → ( @from:[[shift pos+(~1cm,0.5cm)] from] & @to:[[shift pos+(1cm,2cm)] to] ) @@ -45,23 +45,23 @@ dynShift4: \ pos → ( @from:[[shift pos+(~1cm,2cm)] from] & @to:[[shift pos+(1c r: 0.8 -[dynShift1 (~0.7dx,0dy)] | { •page << [helper [locate [llconnect •page @from @to ~1mm]]] } -[dynShift1 (0dx,~0.7dy)] | { •page << [helper [locate [bbconnect •page @from @to ~3mm]]] } -[dynShift1 (0dx,0.7dy)] | { •page << [helper [locate [ttconnect •page @from @to 5mm]]] } -[dynShift1 (0.7dx,0dy)] | { •page << [helper [locate [rrconnect •page @from @to 7mm]]] } +[dynShift1 (~0.7dx,0dy)] | { IO..•page << [helper [Debug..locate [llconnect IO..•page @from @to ~1mm]]] } +[dynShift1 (0dx,~0.7dy)] | { IO..•page << [helper [Debug..locate [bbconnect IO..•page @from @to ~3mm]]] } +[dynShift1 (0dx,0.7dy)] | { IO..•page << [helper [Debug..locate [ttconnect IO..•page @from @to 5mm]]] } +[dynShift1 (0.7dx,0dy)] | { IO..•page << [helper [Debug..locate [rrconnect IO..•page @from @to 7mm]]] } -[dynShift3 (~r*1dx,1.7dy)] | { •page << [helper [locate [trconnect •page @from @to]]] } -[dynShift1 (0dx,1.7dy)] | { •page << [helper [locate [tbconnect •page @from @to]]] } -[dynShift1 (r*1dx,1.7dy)] | { •page << [helper [locate [tlconnect •page @from @to]]] } +[dynShift3 (~r*1dx,1.7dy)] | { IO..•page << [helper [Debug..locate [trconnect IO..•page @from @to]]] } +[dynShift1 (0dx,1.7dy)] | { IO..•page << [helper [Debug..locate [tbconnect IO..•page @from @to]]] } +[dynShift1 (r*1dx,1.7dy)] | { IO..•page << [helper [Debug..locate [tlconnect IO..•page @from @to]]] } -[dynShift1 (1.7dx,r*1dy)] | { •page << [helper [locate [rbconnect •page @from @to]]] } -[dynShift1 (1.7dx,0dy)] | { •page << [helper [locate [rlconnect •page @from @to]]] } -[dynShift4 (1.7dx,~r*1dy)] | { •page << [helper [locate [rtconnect •page @from @to]]] } +[dynShift1 (1.7dx,r*1dy)] | { IO..•page << [helper [Debug..locate [rbconnect IO..•page @from @to]]] } +[dynShift1 (1.7dx,0dy)] | { IO..•page << [helper [Debug..locate [rlconnect IO..•page @from @to]]] } +[dynShift4 (1.7dx,~r*1dy)] | { IO..•page << [helper [Debug..locate [rtconnect IO..•page @from @to]]] } -[dynShift4 (~r*1dx,~1.7dy)] | { •page << [helper [locate [blconnect •page @from @to]]] } -[dynShift2 (0dx,~1.7dy)] | { •page << [helper [locate [btconnect •page @from @to]]] } -[dynShift2 (r*1dx,~1.7dy)] | { •page << [helper [locate [brconnect •page @from @to]]] } +[dynShift4 (~r*1dx,~1.7dy)] | { IO..•page << [helper [Debug..locate [blconnect IO..•page @from @to]]] } +[dynShift2 (0dx,~1.7dy)] | { IO..•page << [helper [Debug..locate [btconnect IO..•page @from @to]]] } +[dynShift2 (r*1dx,~1.7dy)] | { IO..•page << [helper [Debug..locate [brconnect IO..•page @from @to]]] } -[dynShift2 (~1.7dx,r*1dy)] | { •page << [helper [locate [ltconnect •page @from @to]]] } -[dynShift2 (~1.7dx,0dy)] | { •page << [helper [locate [lrconnect •page @from @to]]] } -[dynShift3 (~1.7dx,~r*1dy)] | { •page << [helper [locate [lbconnect •page @from @to]]] } +[dynShift2 (~1.7dx,r*1dy)] | { IO..•page << [helper [Debug..locate [ltconnect IO..•page @from @to]]] } +[dynShift2 (~1.7dx,0dy)] | { IO..•page << [helper [Debug..locate [lrconnect IO..•page @from @to]]] } +[dynShift3 (~1.7dx,~r*1dy)] | { IO..•page << [helper [Debug..locate [lbconnect IO..•page @from @to]]] } diff --git a/examples/doc/blockdraw-connections-primitive.shape b/examples/doc/blockdraw-connections-primitive.shape index bad0a309..93439a2f 100644 --- a/examples/doc/blockdraw-connections-primitive.shape +++ b/examples/doc/blockdraw-connections-primitive.shape @@ -32,23 +32,23 @@ dynamic @p1 identity p1 helper: \ pth → ( -@text_font:FONT_COURIER +Text..@font:Text..Font..COURIER | -(( @width:4bp & @stroking:RGB_RED | [spot @p0] & [spot @p1] ) - & [putlabelAbove (newText << `@p0´) @p0 0] - & [putlabelBelow (newText << `@p1´) @p1 0] - & [[shift @p0+(1cm,~0.5cm)] [Layout..shiftoff_wlm (newText << [sourceof pth]) Layout..to_bot]]) +(( @width:4bp & @stroking:Traits..RGB..RED | [spot @p0] & [spot @p1] ) + & [putlabelAbove (Text..newText << `@p0´) @p0 0] + & [putlabelBelow (Text..newText << `@p1´) @p1 0] + & [[shift @p0+(1cm,~0.5cm)] [Layout..shiftoff_wlm (Text..newText << [Debug..sourceof pth]) Layout..to_bot]]) ) dynShift: \ pos → ( @p0:[[shift pos] p0] & @p1:[[shift pos] p1] ) -[dynShift (1dx,0dy)] | { •page << [helper [locate [hhconnect •page @p0 @p1 0 ~5mm]]] } -[dynShift (2dx,0dy)] | { •page << [helper [locate [hhconnect •page @p0 @p1 0.5 0mm]]] } -[dynShift (3dx,0dy)] | { •page << [helper [locate [hhconnect •page @p0 @p1 1 5mm]]] } +[dynShift (1dx,0dy)] | { IO..•page << [helper [Debug..locate [hhconnect IO..•page @p0 @p1 0 ~5mm]]] } +[dynShift (2dx,0dy)] | { IO..•page << [helper [Debug..locate [hhconnect IO..•page @p0 @p1 0.5 0mm]]] } +[dynShift (3dx,0dy)] | { IO..•page << [helper [Debug..locate [hhconnect IO..•page @p0 @p1 1 5mm]]] } -[dynShift (1.5dx,~1dy)] | { •page << [helper [locate [vhconnect •page @p0 @p1]]] } -[dynShift (2.5dx,~1dy)] | { •page << [helper [locate [hvconnect •page @p0 @p1]]] } +[dynShift (1.5dx,~1dy)] | { IO..•page << [helper [Debug..locate [vhconnect IO..•page @p0 @p1]]] } +[dynShift (2.5dx,~1dy)] | { IO..•page << [helper [Debug..locate [hvconnect IO..•page @p0 @p1]]] } -[dynShift (1dx,~2dy)] | { •page << [helper [locate [vvconnect •page @p0 @p1 0 ~5mm]]] } -[dynShift (2dx,~2dy)] | { •page << [helper [locate [vvconnect •page @p0 @p1 0.5 0mm]]] } -[dynShift (3dx,~2dy)] | { •page << [helper [locate [vvconnect •page @p0 @p1 1 5mm]]] } +[dynShift (1dx,~2dy)] | { IO..•page << [helper [Debug..locate [vvconnect IO..•page @p0 @p1 0 ~5mm]]] } +[dynShift (2dx,~2dy)] | { IO..•page << [helper [Debug..locate [vvconnect IO..•page @p0 @p1 0.5 0mm]]] } +[dynShift (3dx,~2dy)] | { IO..•page << [helper [Debug..locate [vvconnect IO..•page @p0 @p1 1 5mm]]] } diff --git a/examples/doc/blockdraw-labels.shape b/examples/doc/blockdraw-labels.shape index f8a1ef07..8cc9ef4a 100644 --- a/examples/doc/blockdraw-labels.shape +++ b/examples/doc/blockdraw-labels.shape @@ -28,32 +28,32 @@ z: (0cm,0cm) helper: \ pos lbl → [[shift pos] - ( @width:2bp & @stroking:RGB_RED | [spot z] ) + ( @width:2bp & @stroking:Traits..RGB..RED | [spot z] ) & lbl - & [putlabelBelow @text_font:FONT_COURIER | (newText << [sourceof lbl]) z+(0,~5mm) 0] + & [putlabelBelow Text..@font:Text..Font..COURIER | (Text..newText << [Debug..sourceof lbl]) z+(0,~5mm) 0] ] -•page << [helper (1dx,0dy) [locate [putlabelLeft [TeX `$z$´] z ~1]]] -•page << [helper (2dx,0dy) [locate [putlabelLeft [TeX `$z$´] z 0]]] -•page << [helper (3dx,0dy) [locate [putlabelLeft [TeX `$z$´] z 1]]] +IO..•page << [helper (1dx,0dy) [Debug..locate [putlabelLeft [Graphics..TeX `$z$´] z ~1]]] +IO..•page << [helper (2dx,0dy) [Debug..locate [putlabelLeft [Graphics..TeX `$z$´] z 0]]] +IO..•page << [helper (3dx,0dy) [Debug..locate [putlabelLeft [Graphics..TeX `$z$´] z 1]]] -•page << [helper (1dx,~1dy) [locate [putlabelBelow [TeX `$z$´] z ~1]]] -•page << [helper (2dx,~1dy) [locate [putlabelBelow [TeX `$z$´] z 0]]] -•page << [helper (3dx,~1dy) [locate [putlabelBelow [TeX `$z$´] z 1]]] +IO..•page << [helper (1dx,~1dy) [Debug..locate [putlabelBelow [Graphics..TeX `$z$´] z ~1]]] +IO..•page << [helper (2dx,~1dy) [Debug..locate [putlabelBelow [Graphics..TeX `$z$´] z 0]]] +IO..•page << [helper (3dx,~1dy) [Debug..locate [putlabelBelow [Graphics..TeX `$z$´] z 1]]] -•page << [helper (1dx,~2dy) [locate [putlabelRight [TeX `$z$´] z ~1]]] -•page << [helper (2dx,~2dy) [locate [putlabelRight [TeX `$z$´] z 0]]] -•page << [helper (3dx,~2dy) [locate [putlabelRight [TeX `$z$´] z 1]]] +IO..•page << [helper (1dx,~2dy) [Debug..locate [putlabelRight [Graphics..TeX `$z$´] z ~1]]] +IO..•page << [helper (2dx,~2dy) [Debug..locate [putlabelRight [Graphics..TeX `$z$´] z 0]]] +IO..•page << [helper (3dx,~2dy) [Debug..locate [putlabelRight [Graphics..TeX `$z$´] z 1]]] -•page << [helper (1dx,~3dy) [locate [putlabelAbove [TeX `$z$´] z ~1]]] -•page << [helper (2dx,~3dy) [locate [putlabelAbove [TeX `$z$´] z 0]]] -•page << [helper (3dx,~3dy) [locate [putlabelAbove [TeX `$z$´] z 1]]] +IO..•page << [helper (1dx,~3dy) [Debug..locate [putlabelAbove [Graphics..TeX `$z$´] z ~1]]] +IO..•page << [helper (2dx,~3dy) [Debug..locate [putlabelAbove [Graphics..TeX `$z$´] z 0]]] +IO..•page << [helper (3dx,~3dy) [Debug..locate [putlabelAbove [Graphics..TeX `$z$´] z 1]]] { tf: [shift (2dx,~4dy)] - p: [hhconnect •page [tf (~1cm,0cm)] [tf (1cm,0cm)] 0.5 0cm] - •page << [putlabelAbove [TeX `$g$´] p.begin.p ~1] - •page << [putlabelAbove [TeX `$G$´] p.end.p 1] - •page << [putlabelBelow [TeX `$x$´] p.begin.p ~1] - •page << [putlabelBelow [TeX `$X$´] p.end.p 1] + p: [hhconnect IO..•page [tf (~1cm,0cm)] [tf (1cm,0cm)] 0.5 0cm] + IO..•page << [putlabelAbove [Graphics..TeX `$g$´] p.begin.p ~1] + IO..•page << [putlabelAbove [Graphics..TeX `$G$´] p.end.p 1] + IO..•page << [putlabelBelow [Graphics..TeX `$x$´] p.begin.p ~1] + IO..•page << [putlabelBelow [Graphics..TeX `$X$´] p.end.p 1] } diff --git a/examples/doc/blockdraw-layout.shape b/examples/doc/blockdraw-layout.shape index bf7ebb2f..1a1b1b7c 100644 --- a/examples/doc/blockdraw-layout.shape +++ b/examples/doc/blockdraw-layout.shape @@ -25,36 +25,36 @@ ##unit dy = 3cm helper: { - F0: [longblock [TeX `Old´]] - G0: [longblock [TeX `New´]] + F0: [longblock [Graphics..TeX `Old´]] + G0: [longblock [Graphics..TeX `New´]] \ •dst pos fun obj:G0 → { F: [putblockOrigin •dst [[shift pos] F0]] G: [fun •dst obj F] - •dst << [shift pos+(0,~0.5dy)] [] [Layout..shiftoff_wlm @text_font:FONT_COURIER | (newText << [sourceof fun]) Layout..to_top] + •dst << [shift pos+(0,~0.5dy)] [] [Layout..shiftoff_wlm Text..@font:Text..Font..COURIER | (Text..newText << [Debug..sourceof fun]) Layout..to_top] } } -[helper •page (1dx,0dy) [locate putblockVeryNearRight]] -[helper •page (1dx,~1dy) [locate putblockNearRight]] -[helper •page (1dx,~2dy) [locate putblockLabelSpaceRight]] -[helper •page (1dx,~3dy) [locate putblockFarRight]] -[helper •page (1dx,~4dy) [locate putblockVeryFarRight]] +[helper IO..•page (1dx,0dy) [Debug..locate putblockVeryNearRight]] +[helper IO..•page (1dx,~1dy) [Debug..locate putblockNearRight]] +[helper IO..•page (1dx,~2dy) [Debug..locate putblockLabelSpaceRight]] +[helper IO..•page (1dx,~3dy) [Debug..locate putblockFarRight]] +[helper IO..•page (1dx,~4dy) [Debug..locate putblockVeryFarRight]] -[helper •page (2dx,0dy) [locate putblockVeryNearAbove]] -[helper •page (3dx,0dy) [locate putblockVeryNearLeft]] -[helper •page (4dx,0dy) [locate putblockVeryNearBelow]] +[helper IO..•page (2dx,0dy) [Debug..locate putblockVeryNearAbove]] +[helper IO..•page (3dx,0dy) [Debug..locate putblockVeryNearLeft]] +[helper IO..•page (4dx,0dy) [Debug..locate putblockVeryNearBelow]] -[helper •page (2dx,~1dy) [locate putblockNearRight] [[shift (0,3mm)] [longblock [TeX `High´]]]] +[helper IO..•page (2dx,~1dy) [Debug..locate putblockNearRight] [[shift (0,3mm)] [longblock [Graphics..TeX `High´]]]] -[helper •page (3dx,~1dy) [locate putblockLabelMarginLeft] [TeX `$u$´]] -[helper •page (3dx,~2dy) [locate putblockLabelMarginBelow] [TeX `$u$´]] -[helper •page (3dx,~3dy) [locate putblockLabelMarginRight] [TeX `$u$´]] -[helper •page (3dx,~4dy) [locate putblockLabelMarginAbove] [TeX `$u$´]] +[helper IO..•page (3dx,~1dy) [Debug..locate putblockLabelMarginLeft] [Graphics..TeX `$u$´]] +[helper IO..•page (3dx,~2dy) [Debug..locate putblockLabelMarginBelow] [Graphics..TeX `$u$´]] +[helper IO..•page (3dx,~3dy) [Debug..locate putblockLabelMarginRight] [Graphics..TeX `$u$´]] +[helper IO..•page (3dx,~4dy) [Debug..locate putblockLabelMarginAbove] [Graphics..TeX `$u$´]] { - fun: [locate putblockOrigin] + fun: [Debug..locate putblockOrigin] pos: (2.3dx,~2.5dy) - F: [fun •page [[shift pos] [longblock [TeX `New´]]]] - •page << [shift pos+(0,~0.5dy)] [] [Layout..shiftoff_wlm @text_font:FONT_COURIER | (newText << [sourceof fun]) Layout..to_top] + F: [fun IO..•page [[shift pos] [longblock [Graphics..TeX `New´]]]] + IO..•page << [shift pos+(0,~0.5dy)] [] [Layout..shiftoff_wlm Text..@font:Text..Font..COURIER | (Text..newText << [Debug..sourceof fun]) Layout..to_top] } diff --git a/examples/doc/blockdraw-tutorial-conpoint.shape b/examples/doc/blockdraw-tutorial-conpoint.shape index 91e3db25..9b17ed5e 100644 --- a/examples/doc/blockdraw-tutorial-conpoint.shape +++ b/examples/doc/blockdraw-tutorial-conpoint.shape @@ -25,7 +25,7 @@ ** This block just serve as something to select connection point on. ** A connection point is a point on the boundary of the object where connection paths should attach. **/ -F: [putblockOrigin •page [longblock [TeX `$F_{\mathrm{y}}(s)$´]]] +F: [putblockOrigin IO..•page [longblock [Graphics..TeX `$F_{\mathrm{y}}(s)$´]]] /** ** In the first two examples, the connection point is bound to a variable called "z" before we use it, @@ -34,21 +34,21 @@ F: [putblockOrigin •page [longblock [TeX `$F_{\mathrm{y}}(s)$´]]] **/ { z: [leftpoint F 2 2] - •page << [@connectpainter [reverse z--(+(~1cm,0))]] + IO..•page << [@connectpainter [Geometry..reverse z--(+(~1cm,0))]] } { z: [rightpoint F 2 1] - •page << [@connectpainter z--(+(1cm,0))] + IO..•page << [@connectpainter z--(+(1cm,0))] } /** ** The number of points on a side defaults to 1, as does the index of the point on that side. **/ -•page << [@connectpainter [reverse [bottompoint F]--(+(0,~1cm))]] +IO..•page << [@connectpainter [Geometry..reverse [bottompoint F]--(+(0,~1cm))]] /** ** OK, we've seen the pattern now, binding the connection point to a variable before using it seems unncessary. **/ -•page << [@connectpainter [toppoint F 3 1]--(+(0,5mm))] +IO..•page << [@connectpainter [toppoint F 3 1]--(+(0,5mm))] << [@connectpainter [toppoint F 3 2]--(+(0,7mm))] << [@connectpainter [toppoint F 3 3]--(+(0,9mm))] diff --git a/examples/doc/blockdraw-tutorial-hello.shape b/examples/doc/blockdraw-tutorial-hello.shape index 544ec1d6..49ea02de 100644 --- a/examples/doc/blockdraw-tutorial-hello.shape +++ b/examples/doc/blockdraw-tutorial-hello.shape @@ -21,4 +21,4 @@ ##lookin ..Shapes ##lookin ..Applications..Blockdraw -•page << [longblock [TeX `$F_{\mathrm{y}}(s)$´]] +IO..•page << [longblock [Graphics..TeX `$F_{\mathrm{y}}(s)$´]] diff --git a/examples/doc/blockdraw-tutorial-labels.shape b/examples/doc/blockdraw-tutorial-labels.shape index 4317def2..95724eaf 100644 --- a/examples/doc/blockdraw-tutorial-labels.shape +++ b/examples/doc/blockdraw-tutorial-labels.shape @@ -26,29 +26,29 @@ tut_prefs | { |** Tutorial preferences activated. -F: [putblockOrigin •page [longblock [TeX `$F(s)$´]]] -S: [putblockNearLeft •page [sumpicture] F] -G: [putblockFarRight •page [longblock [TeX `$G(s)$´]] F] +F: [putblockOrigin IO..•page [longblock [Graphics..TeX `$F(s)$´]]] +S: [putblockNearLeft IO..•page [sumpicture] F] +G: [putblockFarRight IO..•page [longblock [Graphics..TeX `$G(s)$´]] F] -tr: [putblockFarLeft •page pointpicture S] -sy: [putblockVeryNearRight •page [splitdot] G] -ty: [putblockFarRight •page pointpicture G] +tr: [putblockFarLeft IO..•page pointpicture S] +sy: [putblockVeryNearRight IO..•page [splitdot] G] +ty: [putblockFarRight IO..•page pointpicture G] -ignore [] [connect •page tr S] -•page << [leftpointsign S `+´] +ignore [] [connect IO..•page tr S] +IO..•page << [leftpointsign S `+´] -ignore [] [connect •page S F] +ignore [] [connect IO..•page S F] -ignore [] [connect •page G ty] +ignore [] [connect IO..•page G ty] -ignore [] [bbconnect •page sy S @blockspacenear] -•page << [bottompointsign S `-´] +ignore [] [bbconnect IO..•page sy S @blockspacenear] +IO..•page << [bottompointsign S `-´] -{p: [connect •page F G] - •page << [putlabelAbove [TeX `$u$´] [Layout..mspoint p 0.5] 0] +{p: [connect IO..•page F G] + IO..•page << [putlabelAbove [Graphics..TeX `$u$´] [Layout..mspoint p 0.5] 0] } -•page << [putlabelAbove [TeX `$r$´] [toppoint tr] ~1] -•page << [putlabelAbove [TeX `$y$´] [toppoint ty] 1] +IO..•page << [putlabelAbove [Graphics..TeX `$r$´] [toppoint tr] ~1] +IO..•page << [putlabelAbove [Graphics..TeX `$y$´] [toppoint ty] 1] } |** End of tutorial preferences. diff --git a/examples/doc/blockdraw-tutorial-layout.shape b/examples/doc/blockdraw-tutorial-layout.shape index 318973dd..2176e4ca 100644 --- a/examples/doc/blockdraw-tutorial-layout.shape +++ b/examples/doc/blockdraw-tutorial-layout.shape @@ -26,48 +26,48 @@ tut_prefs | { |** Tutorial preferences activated. -SF: [putblockOrigin •page [sumpicture]] -F: [putblockNearRight •page [longblock [TeX `$F$´]] SF] -S1: [putblockNearRight •page [sumpicture] F] -G1: [putblockFarRight •page [longblock [TeX `$G_{1}$´]] S1] -S2: [putblockNearRight •page [sumpicture] G1] -G2: [putblockNearRight •page [longblock [TeX `$G_{2}$´]] S2] -H: [putblockNearAbove •page [longblock [TeX `$H$´]] S2] -sn: [putblockNearAbove •page [splitdot] H] -Ff: [putblockVeryFarLeft •page [longblock [TeX `$F_{\mathrm{f}}$´]] sn] -Neg: [putblockNearBelow •page [squareblock [TeX `$-1$´]] G1] +SF: [putblockOrigin IO..•page [sumpicture]] +F: [putblockNearRight IO..•page [longblock [Graphics..TeX `$F$´]] SF] +S1: [putblockNearRight IO..•page [sumpicture] F] +G1: [putblockFarRight IO..•page [longblock [Graphics..TeX `$G_{1}$´]] S1] +S2: [putblockNearRight IO..•page [sumpicture] G1] +G2: [putblockNearRight IO..•page [longblock [Graphics..TeX `$G_{2}$´]] S2] +H: [putblockNearAbove IO..•page [longblock [Graphics..TeX `$H$´]] S2] +sn: [putblockNearAbove IO..•page [splitdot] H] +Ff: [putblockVeryFarLeft IO..•page [longblock [Graphics..TeX `$F_{\mathrm{f}}$´]] sn] +Neg: [putblockNearBelow IO..•page [squareblock [Graphics..TeX `$-1$´]] G1] -tr: [putblockFarLeft •page pointpicture SF] -tn: [putblockFarAbove •page pointpicture H] -sy: [putblockVeryNearRight •page [splitdot] G2] -ty: [putblockFarRight •page pointpicture G2] +tr: [putblockFarLeft IO..•page pointpicture SF] +tn: [putblockFarAbove IO..•page pointpicture H] +sy: [putblockVeryNearRight IO..•page [splitdot] G2] +ty: [putblockFarRight IO..•page pointpicture G2] -ignore [] [connect •page tr SF] -•page << [leftpointsign SF `+´] +ignore [] [connect IO..•page tr SF] +IO..•page << [leftpointsign SF `+´] -ignore [] [connect •page SF F] +ignore [] [connect IO..•page SF F] -ignore [] [connect •page F S1] -•page << [leftpointsign S1 `+´] +ignore [] [connect IO..•page F S1] +IO..•page << [leftpointsign S1 `+´] -ignore [] [connect •page S1 G1] +ignore [] [connect IO..•page S1 G1] -ignore [] [connect •page G1 S2] -•page << [leftpointsign S2 `+´] +ignore [] [connect IO..•page G1 S2] +IO..•page << [leftpointsign S2 `+´] -ignore [] [connect •page S2 G2] -ignore [] [connect •page G2 ty] +ignore [] [connect IO..•page S2 G2] +ignore [] [connect IO..•page G2 ty] -ignore [] [brconnect •page sy Neg] -ignore [] [connect •page Neg SF] -•page << [bottompointsign SF `+´] +ignore [] [brconnect IO..•page sy Neg] +ignore [] [connect IO..•page Neg SF] +IO..•page << [bottompointsign SF `+´] -ignore [] [connect •page tn H] -ignore [] [connect •page sn Ff] -ignore [] [connect •page Ff S1] -•page << [toppointsign S1 `+´] -ignore [] [connect •page H S2] -•page << [toppointsign S2 `+´] +ignore [] [connect IO..•page tn H] +ignore [] [connect IO..•page sn Ff] +ignore [] [connect IO..•page Ff S1] +IO..•page << [toppointsign S1 `+´] +ignore [] [connect IO..•page H S2] +IO..•page << [toppointsign S2 `+´] { dashboxmargin: 4mm @@ -79,8 +79,8 @@ ignore [] [connect •page H S2] y2: [bottompoint Ff].y - dashboxmargin y3: [toppoint Ff].y + dashboxmargin - •page << hstyle1 | [stroke (x1,y1)--(x1,y3)--(x3,y3)--(x3,y2)--(x2,y2)--(x2,y1)--cycle] - << [shift (x1+10mm,y3-5mm)] [] [Layout..center_wlm [TeX `Regulator´] (~1,1)] + IO..•page << hstyle1 | [Graphics..stroke (x1,y1)--(x1,y3)--(x3,y3)--(x3,y2)--(x2,y2)--(x2,y1)--cycle] + << [shift (x1+10mm,y3-5mm)] [] [Layout..center_wlm [Graphics..TeX `Regulator´] (~1,1)] } } |** End of tutorial preferences. diff --git a/examples/doc/blockdraw-tutorial-relative.shape b/examples/doc/blockdraw-tutorial-relative.shape index 5dd39862..eeca1ad5 100644 --- a/examples/doc/blockdraw-tutorial-relative.shape +++ b/examples/doc/blockdraw-tutorial-relative.shape @@ -21,5 +21,5 @@ ##lookin ..Shapes ##lookin ..Applications..Blockdraw -S: [putblockOrigin •page [sumpicture]] -F: [putblockFarRight •page [longblock [TeX `$F_{\mathrm{y}}(s)$´]] S] +S: [putblockOrigin IO..•page [sumpicture]] +F: [putblockFarRight IO..•page [longblock [Graphics..TeX `$F_{\mathrm{y}}(s)$´]] S] diff --git a/examples/doc/bondgraph-bonds.shape b/examples/doc/bondgraph-bonds.shape index d1fda45b..d94aa973 100644 --- a/examples/doc/bondgraph-bonds.shape +++ b/examples/doc/bondgraph-bonds.shape @@ -25,7 +25,7 @@ ##unit dy = 3.5cm dc: (2.5cm,0) -centermark: @stroking:[gray 0.7] | [stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] +centermark: @stroking:[gray 0.7] | [Graphics..stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] helper: \ pos dc fun lbl → [[shift pos] @@ -39,11 +39,11 @@ helper: \ pos dc fun lbl → & [[shift 0.5*dc + (0,~1.2cm)] [Layout..shiftoff_wlm lbl Layout..to_bot]] }] -•page << [helper (1dx,3dy) dc [stroke head:Graphics..ShapesArrow ...] [TeX `\texttt{head:Graphics..ShapesArrow}´]] +IO..•page << [helper (1dx,3dy) dc [Graphics..stroke head:Graphics..ShapesArrow ...] [Graphics..TeX `\texttt{head:Graphics..ShapesArrow}´]] -•page << [helper (1dx,2dy) dc [stroke head:[bondgraphArrow doHook:true ...] ...] [TeX `\texttt{head:[bondgraphArrow doHook:true ...]}´]] -•page << [helper (2dx,2dy) dc [stroke head:[bondgraphArrow doCausal:true ...] ...] [TeX `\texttt{head:[bondgraphArrow doCausal:true ...]}´]] +IO..•page << [helper (1dx,2dy) dc [Graphics..stroke head:[bondgraphArrow doHook:true ...] ...] [Graphics..TeX `\texttt{head:[bondgraphArrow doHook:true ...]}´]] +IO..•page << [helper (2dx,2dy) dc [Graphics..stroke head:[bondgraphArrow doCausal:true ...] ...] [Graphics..TeX `\texttt{head:[bondgraphArrow doCausal:true ...]}´]] -•page << [helper (1dx,1dy) dc ubond [TeX `\texttt{ubond}´]] -•page << [helper (2dx,1dy) dc hbond [TeX `\texttt{hbond}´]] -•page << [helper (3dx,1dy) dc tbond [TeX `\texttt{tbond}´]] +IO..•page << [helper (1dx,1dy) dc ubond [Graphics..TeX `\texttt{ubond}´]] +IO..•page << [helper (2dx,1dy) dc hbond [Graphics..TeX `\texttt{hbond}´]] +IO..•page << [helper (3dx,1dy) dc tbond [Graphics..TeX `\texttt{tbond}´]] diff --git a/examples/doc/bondgraph-junctions.shape b/examples/doc/bondgraph-junctions.shape index dff6614e..6ea359f8 100644 --- a/examples/doc/bondgraph-junctions.shape +++ b/examples/doc/bondgraph-junctions.shape @@ -24,19 +24,19 @@ ##unit dx = 4cm ##unit dy = 3.5cm -centermark: @stroking:[gray 0.7] | [stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] +centermark: @stroking:[gray 0.7] | [Graphics..stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] helper: \ pos obj lbl → [[shift pos] ( centermark & obj & [[shift (0,~1.2cm)] [Layout..shiftoff_wlm lbl Layout..to_bot]] )] -•page << [helper (1dx,3dy) sjunction [TeX `serial (type 1)´]] -•page << [helper (2dx,3dy) pjunction [TeX `parallel (type 0)´]] +IO..•page << [helper (1dx,3dy) sjunction [Graphics..TeX `serial (type 1)´]] +IO..•page << [helper (2dx,3dy) pjunction [Graphics..TeX `parallel (type 0)´]] -•page << [helper (1dx,2dy) [tfjunction Layout..to_rt [TeX `$r$´]] [TeX `transformer, \texttt{to\_rt}´]] -•page << [helper (2dx,2dy) [tfjunction Layout..to_top [TeX `$r$´]] [TeX `transformer, \texttt{to\_top}´]] -•page << [helper (3dx,2dy) [tfjunction Layout..to_lft [TeX `$r$´]] [TeX `transformer, \texttt{to\_lft}´]] -•page << [helper (4dx,2dy) [tfjunction Layout..to_bot [TeX `$r$´]] [TeX `transformer, \texttt{to\_bot}´]] +IO..•page << [helper (1dx,2dy) [tfjunction Layout..to_rt [Graphics..TeX `$r$´]] [Graphics..TeX `transformer, \texttt{to\_rt}´]] +IO..•page << [helper (2dx,2dy) [tfjunction Layout..to_top [Graphics..TeX `$r$´]] [Graphics..TeX `transformer, \texttt{to\_top}´]] +IO..•page << [helper (3dx,2dy) [tfjunction Layout..to_lft [Graphics..TeX `$r$´]] [Graphics..TeX `transformer, \texttt{to\_lft}´]] +IO..•page << [helper (4dx,2dy) [tfjunction Layout..to_bot [Graphics..TeX `$r$´]] [Graphics..TeX `transformer, \texttt{to\_bot}´]] -•page << [helper (1dx,1dy) [gyjunction Layout..to_rt [TeX `$\mu$´]] [TeX `gyrator, \texttt{to\_rt}´]] -•page << [helper (2dx,1dy) [gyjunction Layout..to_top [TeX `$\mu$´]] [TeX `gyrator, \texttt{to\_top}´]] -•page << [helper (3dx,1dy) [gyjunction Layout..to_lft [TeX `$\mu$´]] [TeX `gyrator, \texttt{to\_lft}´]] -•page << [helper (4dx,1dy) [gyjunction Layout..to_bot [TeX `$\mu$´]] [TeX `gyrator, \texttt{to\_bot}´]] +IO..•page << [helper (1dx,1dy) [gyjunction Layout..to_rt [Graphics..TeX `$\mu$´]] [Graphics..TeX `gyrator, \texttt{to\_rt}´]] +IO..•page << [helper (2dx,1dy) [gyjunction Layout..to_top [Graphics..TeX `$\mu$´]] [Graphics..TeX `gyrator, \texttt{to\_top}´]] +IO..•page << [helper (3dx,1dy) [gyjunction Layout..to_lft [Graphics..TeX `$\mu$´]] [Graphics..TeX `gyrator, \texttt{to\_lft}´]] +IO..•page << [helper (4dx,1dy) [gyjunction Layout..to_bot [Graphics..TeX `$\mu$´]] [Graphics..TeX `gyrator, \texttt{to\_bot}´]] diff --git a/examples/doc/bondgraph-labels.shape b/examples/doc/bondgraph-labels.shape index 9b437f6d..7254fa4a 100644 --- a/examples/doc/bondgraph-labels.shape +++ b/examples/doc/bondgraph-labels.shape @@ -36,12 +36,12 @@ helper: \ pos dc fun lbl → [[shift (0,~2cm)] [Layout..shiftoff_wlm lbl Layout..to_bot]] }] -•page << [helper (1dx,2dy) [rotate 0°][]dc [flowlabel lbl:[TeX `$f_{1}$´] ...] [TeX `\texttt{flowlabel}´]] -•page << [helper (2dx,2dy) [rotate 90°][]dc [flowlabel lbl:[TeX `$f_{1}$´] ...] [TeX `\texttt{flowlabel}´]] -•page << [helper (3dx,2dy) [rotate 180°][]dc [flowlabel lbl:[TeX `$f_{1}$´] ...] [TeX `\texttt{flowlabel}´]] -•page << [helper (4dx,2dy) [rotate 270°][]dc [flowlabel lbl:[TeX `$f_{1}$´] ...] [TeX `\texttt{flowlabel}´]] +IO..•page << [helper (1dx,2dy) [rotate 0°][]dc [flowlabel lbl:[Graphics..TeX `$f_{1}$´] ...] [Graphics..TeX `\texttt{flowlabel}´]] +IO..•page << [helper (2dx,2dy) [rotate 90°][]dc [flowlabel lbl:[Graphics..TeX `$f_{1}$´] ...] [Graphics..TeX `\texttt{flowlabel}´]] +IO..•page << [helper (3dx,2dy) [rotate 180°][]dc [flowlabel lbl:[Graphics..TeX `$f_{1}$´] ...] [Graphics..TeX `\texttt{flowlabel}´]] +IO..•page << [helper (4dx,2dy) [rotate 270°][]dc [flowlabel lbl:[Graphics..TeX `$f_{1}$´] ...] [Graphics..TeX `\texttt{flowlabel}´]] -•page << [helper (1dx,1dy) [rotate 0°][]dc [effortlabel lbl:[TeX `$e_{1}$´] ...] [TeX `\texttt{effortlabel}´]] -•page << [helper (2dx,1dy) [rotate 90°][]dc [effortlabel lbl:[TeX `$e_{1}$´] ...] [TeX `\texttt{effortlabel}´]] -•page << [helper (3dx,1dy) [rotate 180°][]dc [effortlabel lbl:[TeX `$e_{1}$´] ...] [TeX `\texttt{effortlabel}´]] -•page << [helper (4dx,1dy) [rotate 270°][]dc [effortlabel lbl:[TeX `$e_{1}$´] ...] [TeX `\texttt{effortlabel}´]] +IO..•page << [helper (1dx,1dy) [rotate 0°][]dc [effortlabel lbl:[Graphics..TeX `$e_{1}$´] ...] [Graphics..TeX `\texttt{effortlabel}´]] +IO..•page << [helper (2dx,1dy) [rotate 90°][]dc [effortlabel lbl:[Graphics..TeX `$e_{1}$´] ...] [Graphics..TeX `\texttt{effortlabel}´]] +IO..•page << [helper (3dx,1dy) [rotate 180°][]dc [effortlabel lbl:[Graphics..TeX `$e_{1}$´] ...] [Graphics..TeX `\texttt{effortlabel}´]] +IO..•page << [helper (4dx,1dy) [rotate 270°][]dc [effortlabel lbl:[Graphics..TeX `$e_{1}$´] ...] [Graphics..TeX `\texttt{effortlabel}´]] diff --git a/examples/doc/bondgraph-termbonds.shape b/examples/doc/bondgraph-termbonds.shape index 60f278ef..bfe65841 100644 --- a/examples/doc/bondgraph-termbonds.shape +++ b/examples/doc/bondgraph-termbonds.shape @@ -25,24 +25,24 @@ ##unit dy = 6cm dc: (2cm,0cm) -centermark: @stroking:[gray 0.7] | [stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] +centermark: @stroking:[gray 0.7] | [Graphics..stroke (~1cm,0cm)--(1cm,0cm) & (0cm,~1cm)--(0cm,1cm) ] helper: \ pos dc fun lbl → { •dst: newGroup •dst << [[shift dc] centermark] << sjunction - << [stroke [fun •dst pointpicture dc [TeX `I: $m_{1}$´]] head:[Graphics..ShapesArrow width:4 ...]] + << [Graphics..stroke [fun •dst pointpicture dc [Graphics..TeX `I: $m_{1}$´]] head:[Graphics..ShapesArrow width:4 ...]] << [[shift (0,~2.5cm)] [Layout..shiftoff_wlm lbl Layout..to_bot]] [shift pos] [] (•dst) } -•page << [helper (1dx,2dy) [rotate 0°][]dc terminalfrom [TeX `\texttt{terminalfrom}´]] -•page << [helper (2dx,2dy) [rotate 90°][]dc terminalfrom [TeX `\texttt{terminalfrom}´]] -•page << [helper (3dx,2dy) [rotate 180°][]dc terminalfrom [TeX `\texttt{terminalfrom}´]] -•page << [helper (4dx,2dy) [rotate 270°][]dc terminalfrom [TeX `\texttt{terminalfrom}´]] +IO..•page << [helper (1dx,2dy) [rotate 0°][]dc terminalfrom [Graphics..TeX `\texttt{terminalfrom}´]] +IO..•page << [helper (2dx,2dy) [rotate 90°][]dc terminalfrom [Graphics..TeX `\texttt{terminalfrom}´]] +IO..•page << [helper (3dx,2dy) [rotate 180°][]dc terminalfrom [Graphics..TeX `\texttt{terminalfrom}´]] +IO..•page << [helper (4dx,2dy) [rotate 270°][]dc terminalfrom [Graphics..TeX `\texttt{terminalfrom}´]] -•page << [helper (1dx,1dy) [rotate 0°][]dc terminalto [TeX `\texttt{terminalto}´]] -•page << [helper (2dx,1dy) [rotate 90°][]dc terminalto [TeX `\texttt{terminalto}´]] -•page << [helper (3dx,1dy) [rotate 180°][]dc terminalto [TeX `\texttt{terminalto}´]] -•page << [helper (4dx,1dy) [rotate 270°][]dc terminalto [TeX `\texttt{terminalto}´]] +IO..•page << [helper (1dx,1dy) [rotate 0°][]dc terminalto [Graphics..TeX `\texttt{terminalto}´]] +IO..•page << [helper (2dx,1dy) [rotate 90°][]dc terminalto [Graphics..TeX `\texttt{terminalto}´]] +IO..•page << [helper (3dx,1dy) [rotate 180°][]dc terminalto [Graphics..TeX `\texttt{terminalto}´]] +IO..•page << [helper (4dx,1dy) [rotate 270°][]dc terminalto [Graphics..TeX `\texttt{terminalto}´]] diff --git a/examples/doc/clip-text.shape b/examples/doc/clip-text.shape index 53afbdaa..2df5cec9 100644 --- a/examples/doc/clip-text.shape +++ b/examples/doc/clip-text.shape @@ -23,25 +23,25 @@ shapes_gray: [gray 0.94] shapes_yellow: [rgb 1 0.7 0] shapes_blue: [rgb 0.3 0.6 1] -@text_size:20mm +Text..@size:20mm | { content: @stroking:shapes_yellow & @width:2bp | - [[range 2mm @text_size-10mm 2mm].foldl - \ p e → p & [stroke (1cm,e)--(6cm,e)] + [[Data..range 2mm Text..@size-10mm 2mm].foldl + \ p e → p & [Graphics..stroke (1cm,e)--(6cm,e)] null] - •page << [clip content - @nonstroking:shapes_gray & @stroking:shapes_blue & @text_rendering:[textmode] | ( newText << [kern `Shapes´] )] - >> [shift (0cm,0*@text_size)] - •page << [clip content - @nonstroking:shapes_gray & @stroking:shapes_blue & @text_rendering:[textmode fill:true] | ( newText << [kern `Shapes´] )] - >> [shift (0cm,~1*@text_size)] - •page << [clip content - @nonstroking:shapes_gray & @stroking:shapes_blue & @text_rendering:[textmode stroke:true] | ( newText << [kern `Shapes´] )] - >> [shift (0cm,~2*@text_size)] - •page << [clip content - @nonstroking:shapes_gray & @stroking:shapes_blue & @text_rendering:[textmode fill:true stroke:true] | ( newText << [kern `Shapes´] )] - >> [shift (0cm,~3*@text_size)] + IO..•page << [Graphics..clip content + @nonstroking:shapes_gray & @stroking:shapes_blue & Text..@rendering:[textmode] | ( Text..newText << [kern `Shapes´] )] + >> [shift (0cm,0*Text..@size)] + IO..•page << [Graphics..clip content + @nonstroking:shapes_gray & @stroking:shapes_blue & Text..@rendering:[textmode fill:true] | ( Text..newText << [kern `Shapes´] )] + >> [shift (0cm,~1*Text..@size)] + IO..•page << [Graphics..clip content + @nonstroking:shapes_gray & @stroking:shapes_blue & Text..@rendering:[textmode stroke:true] | ( Text..newText << [kern `Shapes´] )] + >> [shift (0cm,~2*Text..@size)] + IO..•page << [Graphics..clip content + @nonstroking:shapes_gray & @stroking:shapes_blue & Text..@rendering:[textmode fill:true stroke:true] | ( Text..newText << [kern `Shapes´] )] + >> [shift (0cm,~3*Text..@size)] } diff --git a/examples/doc/clip-winding-rule.shape b/examples/doc/clip-winding-rule.shape index fd7a64b8..e6878545 100644 --- a/examples/doc/clip-winding-rule.shape +++ b/examples/doc/clip-winding-rule.shape @@ -20,12 +20,12 @@ ##lookin ..Shapes -cmd: clip +cmd: Graphics..clip @nonstroking: [gray 0.4] | { - •page << ( [cmd img starPath] & starPathStroke ) + IO..•page << ( [cmd img starPath] & starPathStroke ) << ( [cmd img sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd img alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/doc/clipodd-winding-rule.shape b/examples/doc/clipodd-winding-rule.shape index e18e1fd7..7f589987 100644 --- a/examples/doc/clipodd-winding-rule.shape +++ b/examples/doc/clipodd-winding-rule.shape @@ -20,12 +20,12 @@ ##lookin ..Shapes -cmd: clipodd +cmd: Graphics..clipodd @nonstroking: [gray 0.4] | { - •page << ( [cmd img starPath] & starPathStroke ) + IO..•page << ( [cmd img starPath] & starPathStroke ) << ( [cmd img sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd img alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/doc/encapsulation-namespace.blank b/examples/doc/encapsulation-namespace.blank index fc5132ef..286465d4 100644 --- a/examples/doc/encapsulation-namespace.blank +++ b/examples/doc/encapsulation-namespace.blank @@ -32,7 +32,7 @@ x: 1 y: 2 x: 3 /** Shadowing binding. **/ /** Use a local reference to refer to the shadowed binding: **/ -Shapes..•stdout << ^^x << "{n} +Shapes..IO..•stdout << ^^x << "{n} ##pop B ##pop ^^ @@ -49,6 +49,6 @@ Shapes..•stdout << ^^x << "{n} ##pop A /** The encapsulation namespace isn't seen from the outside: **/ -Shapes..•stdout << (resolved_identifier_string A..x) << "{n} -Shapes..•stdout << (resolved_identifier_string A..B..y) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string A..x) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string A..B..y) << "{n} z: A..x + A..B..y diff --git a/examples/doc/fill-winding-rule.shape b/examples/doc/fill-winding-rule.shape index 79174cd7..66a41eef 100644 --- a/examples/doc/fill-winding-rule.shape +++ b/examples/doc/fill-winding-rule.shape @@ -25,7 +25,7 @@ cmd: fill @nonstroking: [gray 0.4] | { - •page << ( [cmd starPath] & starPathStroke ) + IO..•page << ( [cmd starPath] & starPathStroke ) << ( [cmd sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/doc/fillodd-winding-rule.shape b/examples/doc/fillodd-winding-rule.shape index 1665fdab..314d87c5 100644 --- a/examples/doc/fillodd-winding-rule.shape +++ b/examples/doc/fillodd-winding-rule.shape @@ -20,12 +20,12 @@ ##lookin ..Shapes -cmd: fillodd +cmd: Graphics..fillodd @nonstroking: [gray 0.4] | { - •page << ( [cmd starPath] & starPathStroke ) + IO..•page << ( [cmd starPath] & starPathStroke ) << ( [cmd sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/doc/lexiographicSort.shape b/examples/doc/lexiographicSort.shape index e3c357df..7a4db2f3 100644 --- a/examples/doc/lexiographicSort.shape +++ b/examples/doc/lexiographicSort.shape @@ -22,38 +22,38 @@ /** Text input form of an array. **/ -vectorInputForm: \ v → (newString << `[vector ´ << [seq_string [separate ` ´ v.list]] << ` ]´) +vectorInputForm: \ v → (String..newString << `[Data..vector ´ << [seq_string [separate ` ´ v.list]] << ` ]´) /** Data to be sorted. **/ -keys: [list - [vector '~10 '~10] - [vector '~10] - [vector '5 '0 '0] - [vector '~100] - [vector '5 '0 '0] - [vector ] - [vector '~10 '5] - [vector '5 '0] - [vector '5 '10] +keys: [Data..list + [Data..vector '~10 '~10] + [Data..vector '~10] + [Data..vector '5 '0 '0] + [Data..vector '~100] + [Data..vector '5 '0 '0] + [Data..vector ] + [Data..vector '~10 '5] + [Data..vector '5 '0] + [Data..vector '5 '10] ] /** Sort keys, and show. **/ keysSorted: [lexiographicSort keys] -•stdout << `Sorted keys:´ << "{n} -•stdout << [seq_string [separate "{n} [fmap vectorInputForm keysSorted]]] << "{n} +IO..•stdout << `Sorted keys:´ << "{n} +IO..•stdout << [seq_string [separate "{n} [fmap vectorInputForm keysSorted]]] << "{n} /** Values to associate with keys. ** Typically, the keys are computed based on the values, but this will be shown further down. **/ -values: [list `one´ `two´ `three´ `four´ `five´ `six´ `seven´ `eight´ `nine´] +values: [Data..list `one´ `two´ `three´ `four´ `five´ `six´ `seven´ `eight´ `nine´] /** Sort values associated with keys, and show. **/ valuesSorted: [lexiographicSort keys values] -•stdout << `Sorted values associated with keys:´ << "{n} -•stdout << [seq_string [separate "{n} valuesSorted]] << "{n} +IO..•stdout << `Sorted values associated with keys:´ << "{n} +IO..•stdout << [seq_string [separate "{n} valuesSorted]] << "{n} /** Now the typical situation where the keys are derived from the values. ** Sort the string values in alphabetical order by deriving keys from the values. @@ -61,14 +61,14 @@ valuesSorted: [lexiographicSort keys values] ** this example is just about showing how keys can naturally be derived from the ** values to be sorted. **/ -stringKey: \ str → vector [] <>[unlist [fmap ( \ i → [str.UTF8select i].code ) [range '0 count:str.UTF8count]]] +stringKey: \ str → vector [] <>[Data..unlist [fmap ( \ i → [str.UTF8select i].code ) [Data..range '0 count:str.UTF8count]]] valueKeys: [fmap stringKey values] -•stdout << `Keys derived from strings:´ << "{n} -•stdout << [seq_string [separate "{n} [fmap vectorInputForm valueKeys]]] << "{n} +IO..•stdout << `Keys derived from strings:´ << "{n} +IO..•stdout << [seq_string [separate "{n} [fmap vectorInputForm valueKeys]]] << "{n} valuesAlphabetical: [lexiographicSort valueKeys values] -•stdout << `Strings sorted alphabetically:´ << "{n} -•stdout << [seq_string [separate "{n} valuesAlphabetical]] << "{n} +IO..•stdout << `Strings sorted alphabetically:´ << "{n} +IO..•stdout << [seq_string [separate "{n} valuesAlphabetical]] << "{n} @spot diff --git a/examples/doc/namespace-aliases.blank b/examples/doc/namespace-aliases.blank index e38e4e63..1ed47490 100644 --- a/examples/doc/namespace-aliases.blank +++ b/examples/doc/namespace-aliases.blank @@ -38,8 +38,8 @@ a: 1 /** The alias can be accessed using a relative identifier. **/ { - res: [locate (resolved_identifier_string K..Z..a)] - •stdout << `Resolving ´ << [sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} + res: [Debug..locate (resolved_identifier_string K..Z..a)] + IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} } @@ -54,8 +54,8 @@ a: 1 **/ ##push R { - res: [locate (resolved_identifier_string L..Z..a)] - •stdout << `Resolving ´ << [sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} + res: [Debug..locate (resolved_identifier_string L..Z..a)] + IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} } ##pop R @@ -67,8 +67,8 @@ a: 1 /** Expand the alias from the same namespace opened again. **/ { - res: [locate (resolved_identifier_string L..Z..a)] - •stdout << `Resolving ´ << [sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} + res: [Debug..locate (resolved_identifier_string L..Z..a)] + IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} } ##pop W @@ -81,6 +81,6 @@ a: 1 ** This wouldn't work: **/ |**{ -|** res: [locate (resolved_identifier_string W..L..Z..a)] -|** •stdout << `Resolving ´ << [sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} +|** res: [Debug..locate (resolved_identifier_string W..L..Z..a)] +|** IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n} |**} diff --git a/examples/doc/private-namespace.blank b/examples/doc/private-namespace.blank index 212b9df3..5f0d16e8 100644 --- a/examples/doc/private-namespace.blank +++ b/examples/doc/private-namespace.blank @@ -28,19 +28,19 @@ x: 1 /** Implementation detail of A. **/ /** Source code reflection of the private namespace shows a namespace identifier in ** the form of a unique number: **/ -Shapes..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} +Shapes..IO..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} ##pop - /** Access implementation detail from the private namespace using relative identifier ** with empty namespace path: **/ -Shapes..•stdout << (resolved_identifier_string x) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string x) << "{n} /** Open the private namespace a second time: **/ ##push - -Shapes..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} +Shapes..IO..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} /** The private variable x is still in scope here. **/ -Shapes..•stdout << (resolved_identifier_string x) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string x) << "{n} /** Implement some functions in the private namespace. **/ foo: \ y → x + y bar: \ y → x - y @@ -55,7 +55,7 @@ b: bar /** Expose bar under a different name. **/ baz: - /** Special syntax for exposing private namespace variable of the same name. **/ /** Verify that the private namespace has precedence over the normal namespace: **/ -Shapes..•stdout << (resolved_identifier_string foo) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string foo) << "{n} ##pop A @@ -64,13 +64,13 @@ Shapes..•stdout << (resolved_identifier_string foo) << "{n} /** Pushing the same named namespace again sets up a new unique private namespace: **/ ##push A ##push - -Shapes..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} +Shapes..IO..•stdout << `Current namespace: ´ << (resolved_identifier_string @@) << "{n} /** The variable x is not in scope here, since this is a different private namespace. **/ /** The foo in the other private namespace is no longer in scope: **/ -Shapes..•stdout << (resolved_identifier_string foo) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string foo) << "{n} ##pop - /** Neither is x in scope here. **/ ##pop A /** The exposed bindings can still be accessed in the normal namespace: **/ -Shapes..•stdout << (resolved_identifier_string A..baz) << "{n} +Shapes..IO..•stdout << (resolved_identifier_string A..baz) << "{n} diff --git a/examples/doc/remainders.shape b/examples/doc/remainders.shape new file mode 100644 index 00000000..39ea783d --- /dev/null +++ b/examples/doc/remainders.shape @@ -0,0 +1,166 @@ +/** This file is part of Shapes. + ** + ** Shapes is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** any later version. + ** + ** Shapes is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Shapes. If not, see . + ** + ** Copyright 2015 Henrik Tidefelt + **/ + +##needs ..Shapes..Layout / shiftoff + +##lookin ..Shapes +##lookin ..Shapes..Traits +##lookin ..Shapes..Geometry +##lookin ..Shapes..Graphics +##lookin ..Shapes..Numeric..Math + +##unit u = 5mm + +den: '3 +xMin: '~8 +xMax: '8 + +intMark: [Graphics..fill [circle 3bp]] +holeMark: @width:0.1bp & @nonstroking:BW..WHITE | [Graphics..fillstroke [circle 2bp]] + +axisHead: [ShapesArrow width:5bp ...] + +xAxis: \ dataMin dataMax → +{ + @width:0.3bp + & Text..@size:8bp + | + { + [Graphics..stroke (dataMin,0u)--(dataMax,0u) head:axisHead] + & + [[Data..range begin:[Numeric..Math..ceil dataMin/1u] end:[Numeric..Math..floor dataMax/1u]].foldl + \ p e → + { + x: e * 1u + p + & + [if e ≠ '0 and [modulo e den] = '0 + [Graphics..stroke (x,0)--(x,~5bp)] & [[shift (x,~5bp)] [Layout..shiftoff_wlm (Text..newText << (String..newString << x/1u)) Layout..to_bot]] + [Graphics..stroke (x,0)--(x,~3bp)] + ] + } + null + ] + + } +} + + +yAxis: \ dataMin dataMax → +{ + @width:0.3bp + & Text..@size:8bp + | + { + [Graphics..stroke (0u,dataMin)--(0u,dataMax) head:axisHead] + & + [[Data..range begin:[Numeric..Math..ceil dataMin/1u] end:[Numeric..Math..floor dataMax/1u]].foldl + \ p e → + { + y: e * 1u + p + & + [if e ≠ '0 and [modulo e den] = '0 + [Graphics..stroke (0,y)--(~5bp,y)] & [[shift (~5bp,y)] [Layout..shiftoff_wlm (Text..newText << (String..newString << y/1u)) Layout..to_lft]] + [Graphics..stroke (0,y)--(~3bp,y)] + ] + } + null + ] + + } +} + + +remainderPlot: \ fun den → +{ + aden: [abs den] + floatPath: + @width:0.5bp + | + { + [[Data..range begin:(xMin/aden - '1) end:(xMax/aden)].foldl + \ p e → + { + x1: e * aden * 1u + x2: (e + '1) * aden * 1u + /** To get the corrent limit in all cases, we use the fact that the limit will always be an integer, + ** so an approximation is first computed in the interior of the segment, and then rounded. + **/ + y1: [Numeric..Math..round [fun (x1/1u + 0.1) den*1.0]] * 1u + y2: [Numeric..Math..round [fun (x2/1u - 0.1) den*1.0]] * 1u + p & [Graphics..stroke (x1,y1)--(x2,y2)] + } + null + ] + } + intMarks: [[Data..range begin:xMin end:(xMax + '1)].foldl + \ p e → + { + x: e + y: [fun x den] + p & [[shift (x*1u,y*1u)] intMark] + } + null + ] + holeMarks: [[Data..range begin:xMin end:(xMax + '1)].foldl + \ p e → + { + x: e * 1.0 + /** Using rounding to get the left and right limits, and also rounding the value at x, + ** the logic is simplified since we can use integer equality testing. + **/ + y0: [Numeric..Math..round [fun x den*1.0]] + y1: [Numeric..Math..round [fun (x + 0.1) den*1.0]] + y2: [Numeric..Math..round [fun (x - 0.1) den*1.0]] + [Control..cond + [Data..cons y1 ≠ y0 p & [[shift (x*1u,y1*1u)] holeMark]] + [Data..cons y2 ≠ y0 p & [[shift (x*1u,y2*1u)] holeMark]] + [Data..cons true p] + ] + } + null + ] + viewXMin: (xMin*1.0-0.7)*1u + viewXMax: (xMax*1.0+0.7)*1u + viewYMin: ~(aden*1.0+1.7)*1u + viewYMax: (aden*1.0+1.7)*1u + •plot: newGroup + •plot << [xAxis viewXMin viewXMax] + •plot << [yAxis viewYMin viewYMax] + data: floatPath & intMarks & holeMarks + •plot << [Graphics..clip data [Geometry..rectangle (viewXMin,viewYMin) (viewXMax,viewYMax)]] + Text..@font:Text..Font..COURIER + | + { + •plot << [[shift (0,viewYMax)] [Layout..shiftoff_wlm (Text..newText << (String..newString << [Debug..sourceof fun] << ` ´ << den*1.0)) Layout..to_top]] + } + plot: •plot; + [Layout..enlarge_bleedbox plot (2mm,2mm)] +} + + +remainderPlotPair: \ fun → + [[shift (~10u,0)] [remainderPlot fun den]] + & + [[shift (10u,0)] [remainderPlot fun ~den]] + +yPlotStep: 12u +IO..•page << [remainderPlotPair [Debug..locate modulo]] >> [shift (0,~0*yPlotStep)] +IO..•page << [remainderPlotPair [Debug..locate mod]] >> [shift (0,~1*yPlotStep)] +IO..•page << [remainderPlotPair [Debug..locate rem]] >> [shift (0,~2*yPlotStep)] diff --git a/examples/doc/schur.blank b/examples/doc/schur.blank index 1e33d54b..5821a39b 100644 --- a/examples/doc/schur.blank +++ b/examples/doc/schur.blank @@ -17,29 +17,30 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D /** Define transform to work with. **/ -tf: [shift (3cm,4cm,5cm)]*[rotate3D angle:25° dir:(1,1,2)] -•stdout << `Linear? ´ << tf.linear? << "{n} -•stdout << `Translation? ´ << tf.translation? << "{n} -•stdout << `Special? ´ << tf.special? << "{n} -•stdout << `Euclidean? ´ << tf.Euclidean? << "{n} +tf: [shift (3cm,4cm,5cm)]*[Geometry3D..rotate angle:25° dir:(1,1,2)] +IO..•stdout << `Linear? ´ << tf.linear? << "{n} +IO..•stdout << `Translation? ´ << tf.translation? << "{n} +IO..•stdout << `Special? ´ << tf.special? << "{n} +IO..•stdout << `Euclidean? ´ << tf.Euclidean? << "{n} -•stdout << `Transforms in new coordinates:´ << "{n} +IO..•stdout << `Transforms in new coordinates:´ << "{n} /** Compute decompositions, both with automatic and manual selection of rank. **/ sda: [Schur_decomp tf] -•stdout << sda.U << "{n} -•stdout << [sda.U.chop L:0.00001 p:0.000001mm] << ` (chopped)´ << "{n} +IO..•stdout << sda.U << "{n} +IO..•stdout << [sda.U.chop L:0.00001 p:0.000001mm] << ` (chopped)´ << "{n} sdac: [Schur_decomp tf canonical:true] -•stdout << sdac.U << "{n} +IO..•stdout << sdac.U << "{n} sd0: [Schur_decomp tf rank:'0] -•stdout << sd0.U << "{n} +IO..•stdout << sd0.U << "{n} sd2: [Schur_decomp tf rank:'2] -•stdout << sd2.U << "{n} +IO..•stdout << sd2.U << "{n} /** Verify decompositions; if two transforms are equal, then combining one with ** the inverse of the other shall be the identity. @@ -52,14 +53,14 @@ check: \ tf decomp → ** these predicates we must chop the elements of the transform first. **/ tmp: [( [inverse tf] * decomp.Q*decomp.U*[inverse decomp.Q] ).chop L:0.00001 p:0.00001mm] - `Verifying ´ + [sourceof decomp] + `: ´ + [if tmp.linear? and tmp.translation? `OK´ `Incorrect´] + `Verifying ´ + [Debug..sourceof decomp] + `: ´ + [if tmp.linear? and tmp.translation? `OK´ `Incorrect´] } -•stdout << `Verification:´ << "{n} -•stdout << [check tf [locate sda]] << "{n} -•stdout << [check tf [locate sdac]] << "{n} -•stdout << [check tf [locate sd0]] << "{n} -•stdout << [check tf [locate sd2]] << "{n} +IO..•stdout << `Verification:´ << "{n} +IO..•stdout << [check tf [Debug..locate sda]] << "{n} +IO..•stdout << [check tf [Debug..locate sdac]] << "{n} +IO..•stdout << [check tf [Debug..locate sd0]] << "{n} +IO..•stdout << [check tf [Debug..locate sd2]] << "{n} -•stdout << `(Not canonical:) Change of coordinates is special? ´ << sda.Q.special? << "{n} -•stdout << `(Canonical:) Change of coordinates is special? ´ << sdac.Q.special? << "{n} +IO..•stdout << `(Not canonical:) Change of coordinates is special? ´ << sda.Q.special? << "{n} +IO..•stdout << `(Canonical:) Change of coordinates is special? ´ << sdac.Q.special? << "{n} diff --git a/examples/doc/single-file-module.shext b/examples/doc/single-file-module.shext index 1dae46da..d4ead921 100644 --- a/examples/doc/single-file-module.shext +++ b/examples/doc/single-file-module.shext @@ -41,10 +41,10 @@ hypot3D: hypot3D_impl ##push - -hypot: \­ x y → [sqrt x * x + y * y] +hypot: \­ x y → [Numeric..Math..sqrt x * x + y * y] -hypot3D_impl: \­ x y z → [sqrt x * x + y * y + z * z] +hypot3D_impl: \­ x y z → [Numeric..Math..sqrt x * x + y * y + z * z] ##pop - diff --git a/examples/doc/structure-oneliner.shape b/examples/doc/structure-oneliner.shape index 706b6b4a..41ca9c1b 100644 --- a/examples/doc/structure-oneliner.shape +++ b/examples/doc/structure-oneliner.shape @@ -1 +1 @@ -[Shapes..TeX `$x^{2}$´] +[Shapes..Graphics..TeX `$x^{2}$´] diff --git a/examples/doc/structure-text.shape b/examples/doc/structure-text.shape index 42a11999..f6c48d3a 100644 --- a/examples/doc/structure-text.shape +++ b/examples/doc/structure-text.shape @@ -1,6 +1,6 @@ ##lookin ..Shapes factorial: \ n → [if ( n = '0 ) '1 ( n * [factorial n-'1] )] -•stdout << [factorial '5] << "{n} +IO..•stdout << [factorial '5] << "{n} @spot /** Avoid empty-output error in graphics mode. **/ diff --git a/examples/doc/structure-typical.shape b/examples/doc/structure-typical.shape index fb4beeab..1d2a596e 100644 --- a/examples/doc/structure-typical.shape +++ b/examples/doc/structure-typical.shape @@ -11,8 +11,8 @@ | { -a: [putblockOrigin •page [longblock [TeX `$\bm{a}$´]]] -b: [putblockFarRight •page [longblock [TeX `$\bm{b}$´]] a] -ignore [] [connect •page a b] +a: [putblockOrigin IO..•page [longblock [Graphics..TeX `$\bm{a}$´]]] +b: [putblockFarRight IO..•page [longblock [Graphics..TeX `$\bm{b}$´]] a] +ignore [] [connect IO..•page a b] } diff --git a/examples/doc/tex-quotes.shape b/examples/doc/tex-quotes.shape index 31397fc3..92538760 100644 --- a/examples/doc/tex-quotes.shape +++ b/examples/doc/tex-quotes.shape @@ -20,6 +20,6 @@ ##unit dy = 1.5cm -[TeX ("\parbox{10cm}{``This \emph{poor man's string} has bulky delimiters, but can use the \texttt{\`{}\`{}} sequence for the opening left double quote, and uses a sequence of two \emph{impossible-to-produce-in-\LaTeX-apostrophe} for the closing right double quote.''}")] -& [[shift (0,~1dy)] [TeX `\parbox{10cm}{“This string is entered with left and right double quotes, and can use the \emph{normal string} syntax.”}´]] -& [[shift (0,~2dy)] [TeX "{{\parbox}7B{10cm}7D7BE2809C{This string is entered as a \emph}7B{data string}7D{, and would be OK for a computer program to generate. It is entered using plain \textsc}7B{ascii}7D{, have a look at the source!}E2809D7D}]] +[Graphics..TeX ("\parbox{10cm}{``This \emph{poor man's string} has bulky delimiters, but can use the \texttt{\`{}\`{}} sequence for the opening left double quote, and uses a sequence of two \emph{impossible-to-produce-in-\LaTeX-apostrophe} for the closing right double quote.''}")] +& [[shift (0,~1dy)] [Graphics..TeX `\parbox{10cm}{“This string is entered with left and right double quotes, and can use the \emph{normal string} syntax.”}´]] +& [[shift (0,~2dy)] [Graphics..TeX "{{\parbox}7B{10cm}7D7BE2809C{This string is entered as a \emph}7B{data string}7D{, and would be OK for a computer program to generate. It is entered using plain \textsc}7B{ascii}7D{, have a look at the source!}E2809D7D}]] diff --git a/examples/doc/tutorial-approximator-intersection.shape b/examples/doc/tutorial-approximator-intersection.shape index 696ccef6..d1bc7e86 100644 --- a/examples/doc/tutorial-approximator-intersection.shape +++ b/examples/doc/tutorial-approximator-intersection.shape @@ -20,22 +20,22 @@ a: (1.5cm,4.5cm) -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) -circMark: @width:0.5bp | [stroke [Geometry..circle 4bp]] -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +circMark: @width:0.5bp | [Graphics..stroke [Geometry..circle 4bp]] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] helper: \ pth2 → { - ( @width:0.5bp & @stroking:RGB_BLUE & @dash:[dashpattern 2bp 1bp] | [stroke pth2] ) + ( @width:0.5bp & @stroking:Traits..RGB..BLUE & @dash:[dashpattern 2bp 1bp] | [Graphics..stroke pth2] ) & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:0.0bp | [stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) + ( @width:0.0bp | [Graphics..stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) & - ( @width:5bp & @stroking:RGB_RED | [spot [approximator pth pth2].p] ) + ( @width:5bp & @stroking:Traits..RGB..RED | [spot [Geometry..approximator pth pth2].p] ) } -•page << [helper [shift (1.3cm,4cm)][][Geometry..circle 0.5cm]] +IO..•page << [helper [shift (1.3cm,4cm)][][Geometry..circle 0.5cm]] << [shift (6cm,0cm)] [] [helper [shift (1cm,2.5cm)][][Geometry..circle 1.5cm]] << [shift (12cm,0cm)] [] [helper [shift (2cm,2cm)][][Geometry..circle 3cm]] diff --git a/examples/doc/tutorial-approximator.shape b/examples/doc/tutorial-approximator.shape index b7671157..aa725366 100644 --- a/examples/doc/tutorial-approximator.shape +++ b/examples/doc/tutorial-approximator.shape @@ -20,22 +20,22 @@ a: (1.5cm,4.5cm) -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) -circMark: @width:0.5bp | [stroke [Geometry..circle 4bp]] -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +circMark: @width:0.5bp | [Graphics..stroke [Geometry..circle 4bp]] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] helper: \ pth → { [[shift a] crossMark] & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:5bp & @stroking:RGB_RED | [spot [approximator pth a].p] ) + ( @width:5bp & @stroking:Traits..RGB..RED | [spot [Geometry..approximator pth a].p] ) & - ( [shift [pathpoint_approximator pth a].p] [] circMark ) + ( [shift [Geometry..pathpoint_approximator pth a].p] [] circMark ) } -•page << [helper pth.begin--[pth 1.5]] +IO..•page << [helper pth.begin--[pth 1.5]] << [shift (4cm,0cm)] [] [helper pth.begin--[pth 2.5]] << [shift (8cm,0cm)] [] [helper pth] diff --git a/examples/doc/tutorial-bezier-connected.shape b/examples/doc/tutorial-bezier-connected.shape index 1dce3cf8..83f5ef05 100644 --- a/examples/doc/tutorial-bezier-connected.shape +++ b/examples/doc/tutorial-bezier-connected.shape @@ -27,38 +27,38 @@ pathStyle: @width: 1bp controlStyle: @width: 0.3bp & @dash:[dashpattern 2mm 2mm] & @stroking:[gray 0.5] labelStyle: @width: 0.3bp & @stroking:[gray 0.5] -onPathMark: @nonstroking:RGB_RED | [fill [Geometry..circle 1mm]] +onPathMark: @nonstroking:Traits..RGB..RED | [Graphics..fill [Geometry..circle 1mm]] controlHead: \ p → (> cut:0bp - picture: @width:1bp & @stroking:RGB_RED & @dash:[dashpattern] | ([shift p.begin.p]*[rotate [angle p.begin.T]])[][stroke (~1.5mm,~1.5mm)--(1.5mm,1.5mm) & (~1.5mm,1.5mm)--(1.5mm,~1.5mm)] + picture: @width:1bp & @stroking:Traits..RGB..RED & @dash:[dashpattern] | ([shift p.begin.p]*[rotate [angle p.begin.T]])[][Graphics..stroke (~1.5mm,~1.5mm)--(1.5mm,1.5mm) & (~1.5mm,1.5mm)--(1.5mm,~1.5mm)] <) arcHead: [Graphics..ShapesArrow width:2mm ...] coordsHelper: \ src base offset → { p: (base--offset).end.p - [TeX - { tmp: ( newString << `\url{´ + [Graphics..TeX + { tmp: ( String..newString << `\url{´ << src << `} $\Rightarrow (\unit{´ - << [sprintf `%.1f´ p.x/1cm] + << [String..sprintf `%.1f´ p.x/1cm] << `}{\centi\metre},\unit{´ - << [sprintf `%.1f´ p.y/1cm] + << [String..sprintf `%.1f´ p.y/1cm] << `}{\centi\metre})$´ - ) [debuglog_before tmp tmp] } + ) [Debug..log_before tmp tmp] } ] } -arc: \ p0 p1 a → ( @defaultunit:1%C | p0>(^[angle p1-p0]+a)--(^[angle p0-p1]-a)(^[angle p1-p0]+a)--(^[angle p0-p1]-a)p0f--p1rp1f--p2 @@ -67,49 +67,49 @@ pth: p0rp0f--p1rp1f--p2 { xMax: 18.9cm yMax: 6.9cm - •page << [stroke (~1.5cm,0cm)--(xMax,0cm) head:[Graphics..ShapesArrow width:3.5mm ...]] - << [[range 1cm xMax 1cm].foldl - \ p e → ( p & [stroke (e,0cm)--(+(0cm,~[if [abs [mod e 5cm]]<0.1mm 2.5mm 1mm]))] ) + IO..•page << [Graphics..stroke (~1.5cm,0cm)--(xMax,0cm) head:[Graphics..ShapesArrow width:3.5mm ...]] + << [[Data..range 1cm xMax 1cm].foldl + \ p e → ( p & [Graphics..stroke (e,0cm)--(+(0cm,~[if [Numeric..Math..abs [Numeric..Math..mod e 5cm]]<0.1mm 2.5mm 1mm]))] ) null] - << [putlabelBelow [TeX `$\unit{5}{\centi\metre}$´] (5cm,~3mm) 0] - •page << [stroke (0cm,~1.5cm)--(0cm,yMax) head:[Graphics..ShapesArrow width:3.5mm ...]] - << [[range 1cm yMax 1cm].foldl - \ p e → ( p & [stroke (0cm,e)--(+(~[if [abs [mod e 5cm]]<0.1mm 2.5mm 1mm],0cm))] ) + << [putlabelBelow [Graphics..TeX `$\unit{5}{\centi\metre}$´] (5cm,~3mm) 0] + IO..•page << [Graphics..stroke (0cm,~1.5cm)--(0cm,yMax) head:[Graphics..ShapesArrow width:3.5mm ...]] + << [[Data..range 1cm yMax 1cm].foldl + \ p e → ( p & [Graphics..stroke (0cm,e)--(+(~[if [Numeric..Math..abs [Numeric..Math..mod e 5cm]]<0.1mm 2.5mm 1mm],0cm))] ) null] - << [putlabelLeft [TeX `$\unit{5}{\centi\metre}$´] (~3mm,5cm) ~0.5] + << [putlabelLeft [Graphics..TeX `$\unit{5}{\centi\metre}$´] (~3mm,5cm) ~0.5] } -•page << [[range '0 [duration pth]].foldl \ p e → p & [[shift [pth e*1].p] onPathMark] null] - << pathStyle | [stroke pth] +IO..•page << [[Data..range '0 [Geometry..duration pth]].foldl \ p e → p & [[shift [pth e*1].p] onPathMark] null] + << pathStyle | [Graphics..stroke pth] { pa: (0cm,0cm) pb: p0 pTo: (pa--pb).end.p pLbl: pTo + (~2cm,1.5cm) - •page << [putlabelAbove [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa ~30°] head:arcHead] + IO..•page << [putlabelAbove [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa ~30°] head:arcHead] } { pa: [pth 0].p pb: p0r pTo: (pa--pb).end.p pLbl: pTo + (0.5cm,~1cm) - •page << controlStyle | [stroke pa--pTo head:controlHead] - << [putlabelBelow [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa ~40°] head:arcHead] + IO..•page << controlStyle | [Graphics..stroke pa--pTo head:controlHead] + << [putlabelBelow [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa ~40°] head:arcHead] } { pa: [pth 0].p pb: p0f pTo: (pa--pb).end.p pLbl: pTo + (0.5cm,1.5cm) - •page << controlStyle | [stroke pa--pTo head:controlHead] - << [putlabelAbove [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa ~40°] head:arcHead] + IO..•page << controlStyle | [Graphics..stroke pa--pTo head:controlHead] + << [putlabelAbove [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa ~40°] head:arcHead] } { @@ -117,29 +117,29 @@ pth: p0rp0f--p1rp1f--p2 pb: p1 pTo: (pa--pb).end.p pLbl: pTo + (~2.5cm,~1cm) - •page << [putlabelBelow [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa 20°] head:arcHead] + IO..•page << [putlabelBelow [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa 20°] head:arcHead] } { pa: [pth 1].p pb: p1r pTo: (pa--pb).end.p pLbl: pTo + (1cm,1.5cm) - •page << controlStyle | [stroke pa--pTo head:controlHead] - << [putlabelAbove [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa 40°] head:arcHead] + IO..•page << controlStyle | [Graphics..stroke pa--pTo head:controlHead] + << [putlabelAbove [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa 40°] head:arcHead] } { pa: [pth 1].p pb: p1f pTo: (pa--pb).end.p pLbl: pTo + (2cm,1.3cm) - •page << controlStyle | [stroke pa--pTo head:controlHead] - << [putlabelAbove [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa 40°] head:arcHead] + IO..•page << controlStyle | [Graphics..stroke pa--pTo head:controlHead] + << [putlabelAbove [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa 40°] head:arcHead] } { @@ -147,7 +147,7 @@ pth: p0rp0f--p1rp1f--p2 pb: p2 pTo: (pa--pb).end.p pLbl: pTo + (~1cm,1cm) - •page << [putlabelAbove [coordsHelper [sourceof pb] pa pb] pLbl 0] - << labelStyle | [stroke pLbl--pTo] - << labelStyle | [stroke [arc pTo pa ~20°] head:arcHead] + IO..•page << [putlabelAbove [coordsHelper [Debug..sourceof pb] pa pb] pLbl 0] + << labelStyle | [Graphics..stroke pLbl--pTo] + << labelStyle | [Graphics..stroke [arc pTo pa ~20°] head:arcHead] } diff --git a/examples/doc/tutorial-graphics-params.shape b/examples/doc/tutorial-graphics-params.shape index 6939de36..637d4940 100644 --- a/examples/doc/tutorial-graphics-params.shape +++ b/examples/doc/tutorial-graphics-params.shape @@ -18,62 +18,62 @@ ##lookin ..Shapes -pth: @defaultunit:1%C | (0cm,0cm)>(^60°)--(^)<(2cm,0.5cm)>(^)--(^)<(3cm,~1cm)--(^)<(6cm,0cm)>(^90°)--(5cm,0.5cm)--(0.5cm,1cm)--cycle +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^60°)--(^)<(2cm,0.5cm)>(^)--(^)<(3cm,~1cm)--(^)<(6cm,0cm)>(^90°)--(5cm,0.5cm)--(0.5cm,1cm)--cycle yStep: 2cm /** Topmost, we just stroke the path to show what it looks like with default parameters **/ -•page << [stroke pth] +IO..•page << [Graphics..stroke pth] /** The default fill color is black: **/ -•page << [shift (0,~1*yStep)] [] [fill pth] +IO..•page << [shift (0,~1*yStep)] [] [Graphics..fill pth] /** Note the various ways to combine many several bindings, as shown in the following examples that set properties of a stroke. **/ /** This way, it is difficult to indent nicely since there is no ampersand associated with the first binding. **/ -•page << +IO..•page << @stroking:[rgb 0.1 0.3 0.2] & @width:2bp - & @cap:CAP_SQUARE + & @cap:Traits..Cap..SQUARE & @dash:[dashpattern 3mm 2mm 1bp 2mm] | - [shift (0,~2*yStep)] [] [stroke pth] + [shift (0,~2*yStep)] [] [Graphics..stroke pth] /** This way, one has to introduce , and indenting is still not an easy question. **/ -•page << +IO..•page << nullbind - & @stroking:RGB_BLUE + & @stroking:Traits..RGB..BLUE & @width:2bp - & @cap:CAP_BUTT + & @cap:Traits..Cap..BUTT & @dash:[dashpattern 3mm 2mm 1bp 2mm] | - [shift (0,~2.25*yStep)] [] [stroke pth] + [shift (0,~2.25*yStep)] [] [Graphics..stroke pth] /** This way, one has to abandon the good old & way of combining bindings, and learn about the new function . ** However, indenting is easy here. **/ -•page << +IO..•page << [bindings - @stroking:RGB_GREEN + @stroking:Traits..RGB..GREEN @width:1mm - @cap:CAP_ROUND - @join:JOIN_MITER + @cap:Traits..Cap..ROUND + @join:Traits..Join..MITER @miterlimit:4.5 @dash:[dashpattern 3mm 2mm 1bp 2mm] ] | - [shift (0,~2.5*yStep)] [] [stroke pth] + [shift (0,~2.5*yStep)] [] [Graphics..stroke pth] /** The fill color is changed as follows: **/ -•page << @nonstroking:RGB_BLUE | [shift (0,~3*yStep)] [] [fill pth] +IO..•page << @nonstroking:Traits..RGB..BLUE | [shift (0,~3*yStep)] [] [Graphics..fill pth] /** If a path is both to be filled and stroked, it is efficient to use the fillstroke command, ** here, the ampersand is used instead of the function : **/ -•page << - @nonstroking:GRAY_WHITE +IO..•page << + @nonstroking:Traits..BW..WHITE & @stroking:[rgb 0.5 0.5 0] | - [shift (0,~4*yStep)]*[rotate 30°] [] [fillstroke pth] + [shift (0,~4*yStep)]*[rotate 30°] [] [Graphics..fillstroke pth] diff --git a/examples/doc/tutorial-intersection.shape b/examples/doc/tutorial-intersection.shape index 384b189e..10d1ff0f 100644 --- a/examples/doc/tutorial-intersection.shape +++ b/examples/doc/tutorial-intersection.shape @@ -17,21 +17,22 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry a: (1.5cm,4.5cm) -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) -circMark: @width:0.5bp | [stroke [Geometry..circle 4bp]] -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +circMark: @width:0.5bp | [Graphics..stroke [circle 4bp]] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] helper: \ pth2 → { - ( @width:0.5bp & @stroking:RGB_BLUE & @dash:[dashpattern 2bp 1bp] | [stroke pth2] ) + ( @width:0.5bp & @stroking:Traits..RGB..BLUE & @dash:[dashpattern 2bp 1bp] | [Graphics..stroke pth2] ) & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:0.0bp | [stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) + ( @width:0.0bp | [Graphics..stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) & (escape_continuation cont /** The two options for @handler_NoIntersection below deal with the situation in quite different ways. @@ -41,10 +42,10 @@ helper: \ pth2 → @handler_NoIntersection: ( \ pth1 pth2 → (escape_continue cont null) ) |** @handler_NoIntersection: ( \ pth1 pth2 → pth.begin ) & @width:5bp - & @stroking:RGB_RED + & @stroking:Traits..RGB..RED | [spot [intersection pth pth2].p] ) } -•page << [helper [shift (1.3cm,4cm)][][Geometry..circle 0.5cm]] - << [shift (6cm,0cm)] [] [helper [shift (1cm,2.5cm)][][Geometry..circle 1.5cm]] - << [shift (12cm,0cm)] [] [helper [shift (2cm,2cm)][][Geometry..circle 3cm]] +IO..•page << [helper [shift (1.3cm,4cm)][][circle 0.5cm]] + << [shift (6cm,0cm)] [] [helper [shift (1cm,2.5cm)][][circle 1.5cm]] + << [shift (12cm,0cm)] [] [helper [shift (2cm,2cm)][][circle 3cm]] diff --git a/examples/doc/tutorial-maximizer.shape b/examples/doc/tutorial-maximizer.shape index 32890328..cf53c248 100644 --- a/examples/doc/tutorial-maximizer.shape +++ b/examples/doc/tutorial-maximizer.shape @@ -20,26 +20,26 @@ n: [dir 125°] -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) -circMark: @width:0.5bp | [stroke [Geometry..circle 4bp]] -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +circMark: @width:0.5bp | [Graphics..stroke [Geometry..circle 4bp]] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] helper: \ pth → { - ( @width:2bp | [stroke (1cm,3cm)--(+n*1cm) head:Graphics..ShapesArrow] ) + ( @width:2bp | [Graphics..stroke (1cm,3cm)--(+n*1cm) head:Graphics..ShapesArrow] ) & - ( @width:1bp & @stroking:RGB_BLUE | [stroke [controlling pth]] ) + ( @width:1bp & @stroking:Traits..RGB..BLUE | [Graphics..stroke [Geometry..controlling pth]] ) & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:5bp & @stroking:RGB_RED | [spot [maximizer pth n].p] ) + ( @width:5bp & @stroking:Traits..RGB..RED | [spot [Geometry..maximizer pth n].p] ) & - ( [shift [pathpoint_maximizer pth n].p] [] circMark ) + ( [shift [Geometry..pathpoint_maximizer pth n].p] [] circMark ) & - ( [shift [controlling_maximizer pth n]] [] crossMark ) + ( [shift [Geometry..controlling_maximizer pth n]] [] crossMark ) } -•page << [helper pth.begin--[pth 1.5]] +IO..•page << [helper pth.begin--[pth 1.5]] << [shift (4cm,0cm)] [] [helper pth.begin--[pth 2.5]] << [shift (8cm,0cm)] [] [helper pth] diff --git a/examples/doc/tutorial-one-segment.shape b/examples/doc/tutorial-one-segment.shape index e87d319c..fa8350f5 100644 --- a/examples/doc/tutorial-one-segment.shape +++ b/examples/doc/tutorial-one-segment.shape @@ -20,9 +20,9 @@ pathStyle: @width: 1bp controlStyle: @width: 0.3bp & @dash:[dashpattern 2mm 2mm] & @stroking:[gray 0.5] -onPathMark: @nonstroking:RGB_RED | [fill [Geometry..circle 1mm]] +onPathMark: @nonstroking:Traits..RGB..RED | [Graphics..fill [Geometry..circle 1mm]] controlHead: \ p → (> cut:0bp - picture: @width:1bp & @stroking:RGB_RED & @dash:[dashpattern] | ([shift p.begin.p]*[rotate [angle p.begin.T]])[][stroke (~1.5mm,~1.5mm)--(1.5mm,1.5mm) & (~1.5mm,1.5mm)--(1.5mm,~1.5mm)] + picture: @width:1bp & @stroking:Traits..RGB..RED & @dash:[dashpattern] | ([shift p.begin.p]*[rotate [angle p.begin.T]])[][Graphics..stroke (~1.5mm,~1.5mm)--(1.5mm,1.5mm) & (~1.5mm,1.5mm)--(1.5mm,~1.5mm)] <) twoHandlesHelper: \ p0 p1 p2 p3 → @@ -31,11 +31,11 @@ twoHandlesHelper: \ p0 p1 p2 p3 → & [[shift p3] onPathMark] & - ( controlStyle | [stroke p0--p1 head:controlHead] ) + ( controlStyle | [Graphics..stroke p0--p1 head:controlHead] ) & - ( controlStyle | [stroke p3--p2 head:controlHead] ) + ( controlStyle | [Graphics..stroke p3--p2 head:controlHead] ) & - ( pathStyle | [stroke p0>p1--p2p1--p2p1--p3] ) + ( pathStyle | [Graphics..stroke p0>p1--p3] ) ) rearHandlesHelper: \ p0 p2 p3 → @@ -55,9 +55,9 @@ rearHandlesHelper: \ p0 p2 p3 → & [[shift p3] onPathMark] & - ( controlStyle | [stroke p3--p2 head:controlHead] ) + ( controlStyle | [Graphics..stroke p3--p2 head:controlHead] ) & - ( pathStyle | [stroke p0--p2(^~60°)--(^~60°)<(1.5cm,4.5cm)--(+(2cm*[dir 45°])) +pth2: Geometry..@defaultunit:1%C | (1cm,3.5cm)>(^~60°)--(^~60°)<(1.5cm,4.5cm)--(+(2cm*[dir 45°])) -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] helper: \ pth → { - sl: [approximator pth pth2] - ( @width:0.5bp & @stroking:RGB_BLUE & @dash:[dashpattern 2bp 1bp] | [stroke pth2] ) + sl: [Geometry..approximator pth pth2] + ( @width:0.5bp & @stroking:Traits..RGB..BLUE & @dash:[dashpattern 2bp 1bp] | [Graphics..stroke pth2] ) & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:5bp & @stroking:RGB_RED | [spot sl.p] ) + ( @width:5bp & @stroking:Traits..RGB..RED | [spot sl.p] ) & [[shift sl.info.other.p] crossMark] } -•page << [helper pth.begin--[pth 1.5]] +IO..•page << [helper pth.begin--[pth 1.5]] << [shift (4cm,0cm)] [] [helper pth.begin--[pth 2.5]] << [shift (8cm,0cm)] [] [helper pth] diff --git a/examples/doc/tutorial-path-painting.shape b/examples/doc/tutorial-path-painting.shape index e7ddca81..d06030e3 100644 --- a/examples/doc/tutorial-path-painting.shape +++ b/examples/doc/tutorial-path-painting.shape @@ -18,8 +18,8 @@ ##lookin ..Shapes -•page << [stroke (0cm,4cm)--(0cm,0cm)--(5cm,0cm)] -•page << [fill (1cm,1cm)--(3cm,2cm)--(2cm,3.5cm)--cycle] -•page << @width:3bp & @nonstroking:[gray 0.7] | [fillstroke (3cm,1.5cm)--(3.5cm,1cm)--(1.5cm,0.8cm)--cycle] -•page << @defaultunit:1%c | [stroke (3mm,3mm)>(^0°)--(^~90°)<(4cm,3cm) head:Graphics..ShapesArrow] -•page << @width:8bp & @stroking:[gray 0.5] | [spot (1cm,3.5cm)] +IO..•page << [Graphics..stroke (0cm,4cm)--(0cm,0cm)--(5cm,0cm)] +IO..•page << [Graphics..fill (1cm,1cm)--(3cm,2cm)--(2cm,3.5cm)--cycle] +IO..•page << @width:3bp & @nonstroking:[gray 0.7] | [Graphics..fillstroke (3cm,1.5cm)--(3.5cm,1cm)--(1.5cm,0.8cm)--cycle] +IO..•page << Geometry..@defaultunit:1%c | [Graphics..stroke (3mm,3mm)>(^0°)--(^~90°)<(4cm,3cm) head:Graphics..ShapesArrow] +IO..•page << @width:8bp & @stroking:[gray 0.5] | [spot (1cm,3.5cm)] diff --git a/examples/doc/tutorial-slider-use.shape b/examples/doc/tutorial-slider-use.shape index 268ccb68..60ecb9b8 100644 --- a/examples/doc/tutorial-slider-use.shape +++ b/examples/doc/tutorial-slider-use.shape @@ -26,26 +26,26 @@ pathStyle: @width: 1bp labelStyle: @width: 0.3bp & @stroking:[gray 0.5] & @dash:[dashpattern 1mm 1mm] labelHead: [Graphics..ShapesArrow width:2mm ...] -onPathMark: @nonstroking:RGB_RED | [fill [Geometry..circle 1mm]] +onPathMark: @nonstroking:Traits..RGB..RED | [Graphics..fill [Geometry..circle 1mm]] dirStyle: @width: 0.7bp dirHead: [Graphics..ShapesArrow width:2mm ...] dirLen: 1cm -sourceFont: @text_size:9bp & @text_font:FONT_COURIER +sourceFont: Text..@size:9bp & Text..@font:Text..Font..COURIER -path: @defaultunit:1%C | (0cm,0cm)--(2cm,2cm)>(^)--(^)<(5cm,~2cm)>(^)--(^)<(7cm,~2cm) +path: Geometry..@defaultunit:1%C | (0cm,0cm)--(2cm,2cm)>(^)--(^)<(5cm,~2cm)>(^)--(^)<(7cm,~2cm) -•page << pathStyle | [stroke path] +IO..•page << pathStyle | [Graphics..stroke path] /** ** Here, the slider s0 "slides" by distance and arctime to yield the sliders s1 and s2. **/ -s0: [locate [path 1.2]] -s1: [locate s0+4.7cm] -s2: [locate s0+1] +s0: [Debug..locate [path 1.2]] +s1: [Debug..locate s0+4.7cm] +s2: [Debug..locate s0+1] -•stdout << `s0: ´ << [sprintf `spline time: %.3g´ s0.time] << `, ´ << [sprintf `arc time: %.3gcm´ s0.length/1cm] << "{n} -•stdout << `s1: ´ << [sprintf `spline time: %.3g´ s1.time] << `, ´ << [sprintf `arc time: %.3gcm´ s1.length/1cm] << "{n} -•stdout << `s2: ´ << [sprintf `spline time: %.3g´ s2.time] << `, ´ << [sprintf `arc time: %.3gcm´ s2.length/1cm] << "{n} +IO..•stdout << `s0: ´ << [String..sprintf `spline time: %.3g´ s0.time] << `, ´ << [String..sprintf `arc time: %.3gcm´ s0.length/1cm] << "{n} +IO..•stdout << `s1: ´ << [String..sprintf `spline time: %.3g´ s1.time] << `, ´ << [String..sprintf `arc time: %.3gcm´ s1.length/1cm] << "{n} +IO..•stdout << `s2: ´ << [String..sprintf `spline time: %.3g´ s2.time] << `, ´ << [String..sprintf `arc time: %.3gcm´ s2.length/1cm] << "{n} /** ** Annotate s0 @@ -54,24 +54,24 @@ s2: [locate s0+1] /** ** Mark the point where the slider sits, and label it. **/ - •page << [shift s0.p] [] onPathMark + IO..•page << [shift s0.p] [] onPathMark lblPoint: s0.p+(1cm,0.5cm) - •page << [putlabelRight sourceFont | ( newText << `s0.p´ ) lblPoint ~1] - •page << labelStyle | [stroke lblPoint--s0.p head:labelHead] + IO..•page << [putlabelRight sourceFont | ( Text..newText << `s0.p´ ) lblPoint ~1] + IO..•page << labelStyle | [Graphics..stroke lblPoint--s0.p head:labelHead] /** ** Show the tangent direction, . **/ Tend: s0.p + dirLen*s0.T - •page << dirStyle | [stroke s0.p--Tend head:dirHead] - •page << [putlabelRight sourceFont | ( newText << `s0.T´ ) Tend 0] + IO..•page << dirStyle | [Graphics..stroke s0.p--Tend head:dirHead] + IO..•page << [putlabelRight sourceFont | ( Text..newText << `s0.T´ ) Tend 0] /** ** Show the normal direction, . Note that it does not depend on curvature, but is always counter-clockwise from the tangent. **/ Nend: s0.p + dirLen*s0.N - •page << dirStyle | [stroke s0.p--Nend head:dirHead] - •page << [putlabelAbove sourceFont | ( newText << `s0.N´ ) Nend 0] + IO..•page << dirStyle | [Graphics..stroke s0.p--Nend head:dirHead] + IO..•page << [putlabelAbove sourceFont | ( Text..newText << `s0.N´ ) Nend 0] /** ** To show the inverse curvature, , we draw a circle with this radius, centered in the normal direction. @@ -79,42 +79,42 @@ s2: [locate s0+1] ** even though the direction of the normal s0.N does not depend on curvature (as it sometomes does in mathematics). **/ center: s0.p + s0.N * s0.ik - •page << labelStyle | [stroke [shift center] [] [Geometry..circle s0.ik]] - << labelStyle | [stroke s0.p--center head:labelHead] - << [putlabelBelow sourceFont | ( newText << `s0.N * s0.ik´ ) center 0] + IO..•page << labelStyle | [Graphics..stroke [shift center] [] [Geometry..circle s0.ik]] + << labelStyle | [Graphics..stroke s0.p--center head:labelHead] + << [putlabelBelow sourceFont | ( Text..newText << `s0.N * s0.ik´ ) center 0] } /** ** Annotate s1 **/ { - •page << [shift s1.p] [] onPathMark + IO..•page << [shift s1.p] [] onPathMark lblPoint: s1.p+(~1cm,0.5cm) - •page << [putlabelLeft sourceFont | ( newText << `s1.p´ ) lblPoint ~1] - •page << labelStyle | [stroke lblPoint--s1.p head:labelHead] + IO..•page << [putlabelLeft sourceFont | ( Text..newText << `s1.p´ ) lblPoint ~1] + IO..•page << labelStyle | [Graphics..stroke lblPoint--s1.p head:labelHead] Tend: s1.p + dirLen*s1.T - •page << dirStyle | [stroke s1.p--Tend head:dirHead] - •page << [putlabelBelow sourceFont | ( newText << `s1.T´ ) Tend 0] + IO..•page << dirStyle | [Graphics..stroke s1.p--Tend head:dirHead] + IO..•page << [putlabelBelow sourceFont | ( Text..newText << `s1.T´ ) Tend 0] Nend: s1.p + dirLen*s1.N - •page << dirStyle | [stroke s1.p--Nend head:dirHead] - •page << [putlabelAbove sourceFont | ( newText << `s1.N´ ) Nend 1] + IO..•page << dirStyle | [Graphics..stroke s1.p--Nend head:dirHead] + IO..•page << [putlabelAbove sourceFont | ( Text..newText << `s1.N´ ) Nend 1] center: s1.p + s1.N * s1.ik - •page << labelStyle | [stroke [shift center] [] [Geometry..circle s1.ik]] - << labelStyle | [stroke s1.p--center head:labelHead] - << [putlabelAbove sourceFont | ( newText << `s1.N * s1.ik´ ) center 0] + IO..•page << labelStyle | [Graphics..stroke [shift center] [] [Geometry..circle s1.ik]] + << labelStyle | [Graphics..stroke s1.p--center head:labelHead] + << [putlabelAbove sourceFont | ( Text..newText << `s1.N * s1.ik´ ) center 0] } /** ** Annotate s2 **/ { - •page << [shift s2.p] [] onPathMark + IO..•page << [shift s2.p] [] onPathMark lblPoint: s2.p+(1cm,~0.5cm) - •page << [putlabelRight sourceFont | ( newText << `s2.p´ ) lblPoint ~1] - •page << labelStyle | [stroke lblPoint--s2.p head:labelHead] + IO..•page << [putlabelRight sourceFont | ( Text..newText << `s2.p´ ) lblPoint ~1] + IO..•page << labelStyle | [Graphics..stroke lblPoint--s2.p head:labelHead] } @@ -126,8 +126,8 @@ s2: [locate s0+1] { c: (13cm,0) circ: [shift c] [] [Geometry..circle 2cm] - •page << pathStyle | [stroke circ] - << [[range '0 '3].foldl \ p e → ( p & [[shift [circ e*1].p] onPathMark] ) null] + IO..•page << pathStyle | [Graphics..stroke circ] + << [[Data..range '0 '3].foldl \ p e → ( p & [[shift [circ e*1].p] onPathMark] ) null] upAngle: \ d → { a: [angle d] @@ -140,62 +140,62 @@ s2: [locate s0+1] { pth: sl.p--(sl.p+sl.T*sl.v) slMid: (pth.end - 1cm) - [stroke pth head:dirHead] + [Graphics..stroke pth head:dirHead] & - [[shift pth.begin.p] [stroke pth.begin.N*2bp--pth.begin.N*~2bp]] + [[shift pth.begin.p] [Graphics..stroke pth.begin.N*2bp--pth.begin.N*~2bp]] & -[[shift slMid.p+1mm*[dir [upAngle slMid.T]+90°]]*[rotate [upAngle slMid.T]] [Layout..center [TeX [sprintf `$\unit{%.3g}{\centi\metre}$´ sl.v/1cm]] (0,~1)]] +[[shift slMid.p+1mm*[dir [upAngle slMid.T]+90°]]*[rotate [upAngle slMid.T]] [Layout..center [Graphics..TeX [String..sprintf `$\unit{%.3g}{\centi\metre}$´ sl.v/1cm]] (0,~1)]] & [helper sl+1.6cm] } null] - •page << dirStyle | [helper circ.begin] - •page << [shift c] [] [Layout..center [TeX `The velocity $v$´] (0,0)] + IO..•page << dirStyle | [helper circ.begin] + IO..•page << [shift c] [] [Layout..center [Graphics..TeX `The velocity $v$´] (0,0)] - /** While we are working with a closed path, we also illustrate the field. It is a slider at the same location, but with a spline time in the range + /** While we are working with a closed path, we also illustrate the field. It is a slider at the same location, but with a spline time in the range ** zero to the duration of the path. **/ sLoop: [circ 5.5] - sMod: sLoop.mod - •stdout << `sLoop: ´ << [sprintf `spline time: %.3g´ sLoop.time] << `, ´ << [sprintf `arc time: %.3gcm´ sLoop.length/1cm] << "{n} - •stdout << `sMod: ´ << [sprintf `spline time: %.3g´ sMod.time] << `, ´ << [sprintf `arc time: %.3gcm´ sMod.length/1cm] << "{n} + sMod: sLoop.Numeric..Math..mod + IO..•stdout << `sLoop: ´ << [String..sprintf `spline time: %.3g´ sLoop.time] << `, ´ << [String..sprintf `arc time: %.3gcm´ sLoop.length/1cm] << "{n} + IO..•stdout << `sMod: ´ << [String..sprintf `spline time: %.3g´ sMod.time] << `, ´ << [String..sprintf `arc time: %.3gcm´ sMod.length/1cm] << "{n} } /** ** Finally, we show very briefly the difference between normal and reverse fields by comparing and at a corner. **/ { - pth: @defaultunit:1%C | [[shift (18cm,0)] (0cm,0cm)>(^90°)--(2cm^170°)<(2cm,2cm)>(2cm^~45°)--(^90°)<(4cm,0cm)] - •page << pathStyle | [stroke pth] + pth: Geometry..@defaultunit:1%C | [[shift (18cm,0)] (0cm,0cm)>(^90°)--(2cm^170°)<(2cm,2cm)>(2cm^~45°)--(^90°)<(4cm,0cm)] + IO..•page << pathStyle | [Graphics..stroke pth] s: [pth 1] - •page << [shift s.p] [] onPathMark + IO..•page << [shift s.p] [] onPathMark lblPoint: s.p+(0cm,1.5cm) - •page << [putlabelAbove sourceFont | ( newText << `s.p´ ) lblPoint 0] - •page << labelStyle | [stroke lblPoint--s.p head:labelHead] + IO..•page << [putlabelAbove sourceFont | ( Text..newText << `s.p´ ) lblPoint 0] + IO..•page << labelStyle | [Graphics..stroke lblPoint--s.p head:labelHead] { /** First the forward versions of tangent and normal. **/ Tend: s.p + dirLen*s.T - •page << dirStyle | [stroke s.p--Tend head:dirHead] - •page << [putlabelBelow sourceFont | ( newText << `s.T´ ) Tend 0] + IO..•page << dirStyle | [Graphics..stroke s.p--Tend head:dirHead] + IO..•page << [putlabelBelow sourceFont | ( Text..newText << `s.T´ ) Tend 0] Nend: s.p + dirLen*s.N - •page << dirStyle | [stroke s.p--Nend head:dirHead] - •page << [putlabelAbove sourceFont | ( newText << `s.N´ ) Nend ~1] + IO..•page << dirStyle | [Graphics..stroke s.p--Nend head:dirHead] + IO..•page << [putlabelAbove sourceFont | ( Text..newText << `s.N´ ) Nend ~1] } { /** Then the reverse versions. **/ Tend: s.p + dirLen*s.rT - •page << dirStyle | [stroke s.p--Tend head:dirHead] - •page << [putlabelAbove sourceFont | ( newText << `s.rT´ ) Tend 1] + IO..•page << dirStyle | [Graphics..stroke s.p--Tend head:dirHead] + IO..•page << [putlabelAbove sourceFont | ( Text..newText << `s.rT´ ) Tend 1] Nend: s.p + dirLen*s.rN - •page << dirStyle | [stroke s.p--Nend head:dirHead] - •page << [putlabelBelow sourceFont | ( newText << `s.rN´ ) Nend 1] + IO..•page << dirStyle | [Graphics..stroke s.p--Nend head:dirHead] + IO..•page << [putlabelBelow sourceFont | ( Text..newText << `s.rN´ ) Nend 1] } } diff --git a/examples/doc/tutorial-subpath-intersection.shape b/examples/doc/tutorial-subpath-intersection.shape index c998739b..4ba8bfdd 100644 --- a/examples/doc/tutorial-subpath-intersection.shape +++ b/examples/doc/tutorial-subpath-intersection.shape @@ -20,28 +20,28 @@ a: (1.5cm,4.5cm) -pth: @defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^20°)--(1cm,2cm)--(^)<(2.5cm,2cm)>(^)--(2cm^)<(4cm,5cm)>(^~30°)--(^)<(5cm,4cm) sl1: [pth 2cm] sl2: [pth 4cm] -circMark: @width:0.5bp | [stroke [Geometry..circle 4bp]] -crossMark: @width:0.5bp | [stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] +circMark: @width:0.5bp | [Graphics..stroke [Geometry..circle 4bp]] +crossMark: @width:0.5bp | [Graphics..stroke (~4bp,~4bp)--(4bp,4bp) & (~4bp,4bp)--(4bp,~4bp)] -subpath_intersection: \ sl1 sl2 pth → (sl1+[intersection sl1--sl2 pth].length) +subpath_intersection: \ sl1 sl2 pth → (sl1+[Geometry..intersection sl1--sl2 pth].length) helper: \ pth2 → { - ( @width:0.5bp & @stroking:RGB_BLUE & @dash:[dashpattern 2bp 1bp] | [stroke pth2] ) + ( @width:0.5bp & @stroking:Traits..RGB..BLUE & @dash:[dashpattern 2bp 1bp] | [Graphics..stroke pth2] ) & - ( @width:0.5bp | [stroke pth] ) + ( @width:0.5bp | [Graphics..stroke pth] ) & - ( @width:0.0bp | [stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) + ( @width:0.0bp | [Graphics..stroke [pth 0.5cm]--[pth 1cm] head:[Graphics..ShapesArrow width:2mm ...]] ) & [[shift sl1.p] circMark] & [[shift sl2.p] circMark] & - ( @width:5bp & @stroking:RGB_RED | [spot [subpath_intersection sl1 sl2 pth2].p] ) /** We know that there will be an intersection, so no error handler this time. **/ + ( @width:5bp & @stroking:Traits..RGB..RED | [spot [subpath_intersection sl1 sl2 pth2].p] ) /** We know that there will be an intersection, so no error handler this time. **/ } -•page << [helper (0cm,0.3cm)--(5cm,5cm)] +IO..•page << [helper (0cm,0.3cm)--(5cm,5cm)] diff --git a/examples/doc/tutorial-transforms.shape b/examples/doc/tutorial-transforms.shape index 8958430d..2999068e 100644 --- a/examples/doc/tutorial-transforms.shape +++ b/examples/doc/tutorial-transforms.shape @@ -20,5 +20,5 @@ T1: [shift (2cm,~3mm)] T2: [rotate 25°] -lbl: [TeX `$x^{2} + y^{2}$´] -•page << [T1 lbl] << [T2 lbl] << lbl +lbl: [Graphics..TeX `$x^{2} + y^{2}$´] +IO..•page << [T1 lbl] << [T2 lbl] << lbl diff --git a/examples/doc/tutorial-view.shape b/examples/doc/tutorial-view.shape index e10e34f8..75c46e94 100644 --- a/examples/doc/tutorial-view.shape +++ b/examples/doc/tutorial-view.shape @@ -22,6 +22,7 @@ ##needs ..Applications..Blockdraw ##lookin ..Shapes +##lookin ..Shapes..Geometry3D ##lookin ..Applications..Blockdraw R: 5cm @@ -29,7 +30,7 @@ u: R/2.1 /** The function describing the manifold. **/ -surfz: \ p → (0.24*R) * [sin (p.x/u) * (p.y/u)] +surfz: \ p → (0.24*R) * [Numeric..Math..sin (p.x/u) * (p.y/u)] /** A general-purpose helper. **/ @@ -40,31 +41,31 @@ surfit: \ f p → ( p.x, p.y, [f p] ) surfaceCircle: \ f r c sides:'12 → { mid: [surfit f c] - [[range '0 sides-'1].foldl - \ p e → p & [fill mid--[surfit f c+r*[dir (360°*e)/sides]]--[surfit f c+r*[dir (360°*(e+'1))/sides]]--cycle] - null3D] + [[Data..range '0 sides-'1].foldl + \ p e → p & [Graphics..fill mid--[surfit f c+r*[dir (360°*e)/sides]]--[surfit f c+r*[dir (360°*(e+'1))/sides]]--cycle] + Graphics3D..null] } foldpairsl: { - helper: \ op nullRes last lst → [if [null? lst] nullRes [helper op [op nullRes last lst.car] lst.car lst.cdr]] + helper: \ op nullRes last lst → [if [Data..null? lst] nullRes [helper op [op nullRes last lst.car] lst.car lst.cdr]] \ op nullRes lst → - [if [null? lst] + [if [Data..null? lst] lst [helper op nullRes lst.car lst.cdr]] } foldtriplesl: { - helper: \ op nullRes back2 back1 lst → [if [null? lst] nullRes [helper op [op nullRes back2 back1 lst.car] back1 lst.car lst.cdr]] + helper: \ op nullRes back2 back1 lst → [if [Data..null? lst] nullRes [helper op [op nullRes back2 back1 lst.car] back1 lst.car lst.cdr]] \ op nullRes lst → - [if [null? lst] + [if [Data..null? lst] lst - [if [null? lst.cdr] - [list] + [if [Data..null? lst.cdr] + [Data..list] [helper op nullRes lst.car lst.cdr.car lst.cdr.cdr]]] } @@ -75,23 +76,23 @@ functionMesh: \ zMap xRange yRange step:'1 → \ p x → p & - [stroke + [Graphics..stroke [yRange.foldl \ p y → p--[xyz (x,y)] - emptypath3D + Geometry3D..emptypath ]] - null3D] + Graphics3D..null] & [[Data..sublist [Data..consify yRange] step].foldl \ p y → p & - [stroke + [Graphics..stroke [xRange.foldl \ p x → p--[xyz (x,y)] - emptypath3D + Geometry3D..emptypath ]] - null3D] + Graphics3D..null] } functionSurface: \ zMap xRange yRange → @@ -113,18 +114,18 @@ functionSurface: \ zMap xRange yRange → p21: [xyz (x2,y1)] p22: [xyz (x2,y2)] pc: [xyz (0.5*(x1+x2),0.5*(y1+y2))] - [fill pc--p11--p12--cycle] + [Graphics..fill pc--p11--p12--cycle] & - [fill pc--p12--p22--cycle] + [Graphics..fill pc--p12--p22--cycle] & - [fill pc--p22--p21--cycle] + [Graphics..fill pc--p22--p21--cycle] & - [fill pc--p21--p11--cycle] + [Graphics..fill pc--p21--p11--cycle] } - null3D + Graphics3D..null yConsRange ] - null3D + Graphics3D..null xConsRange ] /** @@ -168,18 +169,18 @@ ridgeLines: p & - [if [ridgeTest p11 pc p12 p21] [stroke [xyz (x1,y1)]--pc3D] null3D] + [if [ridgeTest p11 pc p12 p21] [Graphics..stroke [xyz (x1,y1)]--pc3D] Graphics3D..null] & - [if [ridgeTest p12 pc p11 p22] [stroke [xyz (x1,y2)]--pc3D] null3D] + [if [ridgeTest p12 pc p11 p22] [Graphics..stroke [xyz (x1,y2)]--pc3D] Graphics3D..null] & - [if [ridgeTest p22 pc p12 p21] [stroke [xyz (x2,y2)]--pc3D] null3D] + [if [ridgeTest p22 pc p12 p21] [Graphics..stroke [xyz (x2,y2)]--pc3D] Graphics3D..null] & - [if [ridgeTest p21 pc p11 p22] [stroke [xyz (x2,y1)]--pc3D] null3D] + [if [ridgeTest p21 pc p11 p22] [Graphics..stroke [xyz (x2,y1)]--pc3D] Graphics3D..null] } p yConsRange ] - null3D + Graphics3D..null xConsRange ] & @@ -193,13 +194,13 @@ ridgeLines: pc1: [xyz (0.5*(x1+x2),0.5*(y1+y2))] >> tf >> view pc2: [xyz (0.5*(x2+x3),0.5*(y1+y2))] >> tf >> view [if [ridgeTest p1 p2 pc1 pc2] - p & [stroke [xyz (x2,y1)]--[xyz (x2,y2)]] + p & [Graphics..stroke [xyz (x2,y1)]--[xyz (x2,y2)]] p] } p yConsRange ] - null3D + Graphics3D..null xConsRange ] & @@ -213,24 +214,24 @@ ridgeLines: pc1: [xyz (0.5*(x1+x2),0.5*(y1+y2))] >> tf >> view pc2: [xyz (0.5*(x1+x2),0.5*(y2+y3))] >> tf >> view [if [ridgeTest p1 p2 pc1 pc2] - p & [stroke [xyz (x1,y2)]--[xyz (x2,y2)]] + p & [Graphics..stroke [xyz (x1,y2)]--[xyz (x2,y2)]] p] } p xConsRange ] - null3D + Graphics3D..null yConsRange ] } } -T_obj: [shift (0cm,0cm,~10cm)]*[rotate3D dir:(1,0,0) angle:~90°-~19°]*[rotate3D dir:(0,0,1) angle:~90°+25°] +T_obj: [shift (0cm,0cm,~10cm)]*[Geometry3D..rotate dir:(1,0,0) angle:~90°-~19°]*[Geometry3D..rotate dir:(0,0,1) angle:~90°+25°] N_major: '8 N_minor: '2 -xRange: [range ~R R count: N_major * N_minor + '1] -yRange: [range ~R R count: N_major * N_minor + '1] +xRange: [Data..range ~R R count: N_major * N_minor + '1] +yRange: [Data..range ~R R count: N_major * N_minor + '1] world: ( @@ -245,7 +246,7 @@ world: [view T_obj [] - ( newZSorter + ( Graphics3D..newZSorter << @nonstroking:OCCLUDING | [functionSurface surfz xRange yRange] << [functionMesh surfz xRange yRange N_minor] @@ -253,33 +254,33 @@ world: ) ] -•imagePlane << @width:0.3bp | [stroke [rectangle (~3cm,~3cm) (3cm,3cm)]] - << [shift (~3cm,~3cm)+(5mm,5mm)] [] [TeX `{\Huge Image plane}´] +•imagePlane << @width:0.3bp | [Graphics..stroke [Geometry..rectangle (~3cm,~3cm) (3cm,3cm)]] + << [shift (~3cm,~3cm)+(5mm,5mm)] [] [Graphics..TeX `{\Huge Image plane}´] -•world: newGroup3D +•world: Graphics3D..newGroup len: 4cm •world << [immerse (•imagePlane)] - << [stroke (0cm,0cm,0cm)--(len,0cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(0,0,1) ...]] - << [stroke (0cm,0cm,0cm)--(0cm,len,0cm) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(0,0,1) ...]] - << [stroke (0cm,0cm,0cm)--(0cm,0cm,len) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(1,0,0) ...]] - << [shift (len,0cm,0cm)] [] [facing [putlabelAbove [TeX `$\hat{x}$´] (0cm,0cm) 1]] - << [shift (0cm,len,0cm)] [] [facing [putlabelRight [TeX `$\hat{y}$´] (0cm,0cm) 1]] - << [shift (0cm,0cm,len)] [] [facing [putlabelAbove [TeX `$\hat{z}$´] (0cm,0cm) 1]] - << [shift (0cm,0cm,@eyez)] [] [facing [fill [Geometry..circle 2bp]]] - << [shift (0cm,0cm,@eyez)] [] [facing [putlabelAbove [TeX `eye´] (0cm,1mm) 0]] - << [tag 'eye (0cm,0cm,@eyez)] - << [tag 'origin (0cm,0cm,0cm)] + << [Graphics..stroke (0cm,0cm,0cm)--(len,0cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(0,0,1) ...]] + << [Graphics..stroke (0cm,0cm,0cm)--(0cm,len,0cm) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(0,0,1) ...]] + << [Graphics..stroke (0cm,0cm,0cm)--(0cm,0cm,len) head:[Graphics3D..MetaPostArrow ahLength:3mm normal:(1,0,0) ...]] + << [shift (len,0cm,0cm)] [] [facing [putlabelAbove [Graphics..TeX `$\hat{x}$´] (0cm,0cm) 1]] + << [shift (0cm,len,0cm)] [] [facing [putlabelRight [Graphics..TeX `$\hat{y}$´] (0cm,0cm) 1]] + << [shift (0cm,0cm,len)] [] [facing [putlabelAbove [Graphics..TeX `$\hat{z}$´] (0cm,0cm) 1]] + << [shift (0cm,0cm,@eyez)] [] [facing [Graphics..fill [Geometry..circle 2bp]]] + << [shift (0cm,0cm,@eyez)] [] [facing [putlabelAbove [Graphics..TeX `eye´] (0cm,1mm) 0]] + << [Graphics..Tag..tag 'eye (0cm,0cm,@eyez)] + << [Graphics..Tag..tag 'origin (0cm,0cm,0cm)] - bracePath: [rotate3D dir:(0,1,0) angle:~90°] [] [immerse [Graphics..someClosedBrace (0cm,0cm) (@eyez,0cm)]] - •world << [fill bracePath] + bracePath: [Geometry3D..rotate dir:(0,1,0) angle:~90°] [] [immerse [Graphics..someClosedBrace (0cm,0cm) (@eyez,0cm)]] + •world << [Graphics..fill bracePath] |** Next, I use that I happen to know that the tip of the brace is at path time 1. - •world << [shift [bracePath 1].p] [] [facing [putlabelBelow [TeX `$z_{\mathrm{eye}}$´] (0m,0m) 0]] + •world << [shift [bracePath 1].p] [] [facing [putlabelBelow [Graphics..TeX `$z_{\mathrm{eye}}$´] (0m,0m) 0]] •world; } ) -T_view: [shift (0cm,~40cm,0cm)]*[rotate3D dir:(0,1,0) angle:65°]*[rotate3D dir:(0,0,1) angle:15°]*[rotate3D dir:(1,0,0) angle:5°] +T_view: [shift (0cm,~40cm,0cm)]*[Geometry3D..rotate dir:(0,1,0) angle:65°]*[Geometry3D..rotate dir:(0,0,1) angle:15°]*[Geometry3D..rotate dir:(1,0,0) angle:5°] @eyez:∞ | @@ -291,14 +292,14 @@ theView: [view (T_view * T_obj) [] - ( newZSorter + ( Graphics3D..newZSorter |** << @nonstroking:OCCLUDING | [functionSurface surfz xRange yRange] << [functionMesh surfz xRange yRange N_minor] << [ridgeLines surfz xRange yRange T_view * T_obj] ) ] -•page << theView - << [view (T_view * T_obj) [] [facing [putlabelBelow [TeX `{\huge $3^{\mathrm{D}}$ scene}´] (~2cm,~3cm) 0]]] +IO..•page << theView + << [view (T_view * T_obj) [] [facing [putlabelBelow [Graphics..TeX `{\huge $3^{\mathrm{D}}$ scene}´] (~2cm,~3cm) 0]]] << [view T_view [] world] } diff --git a/examples/doc/winding-numbers.shape b/examples/doc/winding-numbers.shape index 6ab7d5ff..9da3ea90 100644 --- a/examples/doc/winding-numbers.shape +++ b/examples/doc/winding-numbers.shape @@ -22,17 +22,17 @@ cmd: \ pth → { - bb: [bbox @width:4mm | [stroke pth]] + bb: [Layout..bbox @width:4mm | [Graphics..stroke pth]] step: 3mm x1: [Layout..xmin bb] x2: [Layout..xmax bb] y1: [Layout..ymin bb] y2: [Layout..ymax bb] - @text_size:0.7*step + Text..@size:0.7*step | - [[range x1 x2 step].foldl - \ p x → [[range y1 y2 step].foldl - \ p y → p & [[shift (x,y)] Layout..center [] (newText << [sprintf `%d´ [winding pth (x,y)]])] + [[Data..range x1 x2 step].foldl + \ p x → [[Data..range y1 y2 step].foldl + \ p y → p & [[shift (x,y)] Layout..center [] (Text..newText << [String..sprintf `%d´ [Geometry..winding pth (x,y)]])] p] null] } @@ -40,7 +40,7 @@ cmd: \ pth → @nonstroking: [gray 0.4] | { - •page << ( [cmd starPath] & starPathStroke ) + IO..•page << ( [cmd starPath] & starPathStroke ) << ( [cmd sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/doc/winding-rule-paths.shext b/examples/doc/winding-rule-paths.shext index b8ff473f..71e5c1f5 100644 --- a/examples/doc/winding-rule-paths.shext +++ b/examples/doc/winding-rule-paths.shext @@ -17,51 +17,52 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry lineStyle: @width:0.3bp starPath: - [[range '0 '4].foldl + [[Data..range '0 '4].foldl \ p e → p--(15mm*[dir 90°+e*2*360°/5]) - emptypath]--cycle + Geometry..emptypath]--cycle starPathStroke: - ( lineStyle | [stroke starPath] ) + ( lineStyle | [Graphics..stroke starPath] ) & ( @width:0m | - [[range 0 4.5].foldl - \ p e → p & [stroke [starPath e+0.5].p--[starPath e+0.7].p head:Graphics..ShapesArrow] + [[Data..range 0 4.5].foldl + \ p e → p & [Graphics..stroke [starPath e+0.5].p--[starPath e+0.7].p head:Graphics..ShapesArrow] null] ) -c1: [Geometry..circle 5mm] -c2: [Geometry..circle 10mm] +c1: [circle 5mm] +c2: [circle 10mm] circleHeads: \ pth rng → @width:0m | [rng.foldl - \ p e → p & { sl:[pth [abs pth.begin.p]*e] [stroke (sl-1cm)--sl head:Graphics..ShapesArrow] } + \ p e → p & { sl:[pth [Numeric..Math..abs pth.begin.p]*e] [Graphics..stroke (sl-1cm)--sl head:Graphics..ShapesArrow] } null] sameCircle: c1 & c2 sameCircleStroke: - ( lineStyle | [stroke sameCircle] ) + ( lineStyle | [Graphics..stroke sameCircle] ) & - [circleHeads c1 [range 90° 360° 120°]] + [circleHeads c1 [Data..range 90° 360° 120°]] & - [circleHeads c2 [range 30° 360° 120°]] + [circleHeads c2 [Data..range 30° 360° 120°]] -c1r: [reverse c1] +c1r: [Geometry..reverse c1] alternatingCircle: c1r & c2 alternatingCircleStroke: - ( lineStyle | [stroke alternatingCircle] ) + ( lineStyle | [Graphics..stroke alternatingCircle] ) & - [circleHeads c1r [range 90° 360° 120°]] + [circleHeads c1r [Data..range 90° 360° 120°]] & - [circleHeads c2 [range 30° 360° 120°]] + [circleHeads c2 [Data..range 30° 360° 120°]] img: ( newGroup - << @nonstroking:[gray 0.8] | [fill [rectangle (~20mm,~20mm) (20mm,20mm)]] - << @nonstroking:[rgb 0.965 0.430 0.541] | ( [[shift (~4mm,0)] [fill [Geometry..circle 3mm]]] & [[shift (4mm,0)] [fill [Geometry..circle 3mm]]] ) - << @nonstroking:[gray 0.2]&@text_size:5mm | [Layout..center ( newText << `Clip me!´ )] + << @nonstroking:[gray 0.8] | [Graphics..fill [rectangle (~20mm,~20mm) (20mm,20mm)]] + << @nonstroking:[rgb 0.965 0.430 0.541] | ( [[shift (~4mm,0)] [Graphics..fill [circle 3mm]]] & [[shift (4mm,0)] [Graphics..fill [circle 3mm]]] ) + << @nonstroking:[gray 0.2]&Text..@size:5mm | [Layout..center ( Text..newText << `Clip me!´ )] ) diff --git a/examples/features/amb.blank b/examples/features/amb.blank index 5b796147..99910155 100644 --- a/examples/features/amb.blank +++ b/examples/features/amb.blank @@ -32,23 +32,23 @@ ** one of the values passed to amb. ** ** Though it may appear inconvenient that one will not be able to write - ** a: [amb [Data..consify [range 1 5]]] + ** a: [amb [Data..consify [Data..range 1 5]]] ** [try_something a] ** it shall be observed that this would not be legal anyway, since the variable definition ** construct is based on a one-assignment, rather than being translated to some kind of let* . ** Arguably, this is a drawback of the variable definition semantics, and suggests that ** providing a let macro may actually be useful. If we solved the continuation thing in some ** other way, it might be possible to write - ** (let (a: [amb [Data..consify [range 1 5]]]) + ** (let (a: [amb [Data..consify [Data..range 1 5]]]) ** [try_something a]) ** which may be more readable than - ** [amb [Data..consify [range 1 5]]] [] \ a → + ** [amb [Data..consify [Data..range 1 5]]] [] \ a → ** [try_something a] ** ** When rejecting an instantiation of the amb values, the argument passed to the amb_fail ** continuation does not matter. The user should not have to know about the name of ** the continuation, but simply write - ** [amb [list]] + ** [amb [Data..list]] ** to indicate that the current instantiation is a failure. ** ** Of course, we could have designed amb to be a variable arity function, to make @@ -57,14 +57,14 @@ ** [amb 1 2 3] ** would be conventient to enter this way, it becomes clumsy when we want to apply ** amb to a range, - ** amb [] <>[unlist [range 1 30]] + ** amb [] <>[Data..unlist [Data..range 1 30]] ** and it does not generalize at all if we would like to use infinite streams. **/ /** This function is applicable to cons-lists. **/ amb: \ lst → - [if [null? lst] + [if [Data..null? lst] (escape_continue amb_fail `amb alternatives exhausted.´) \ fun → (escape_continuation return @@ -76,12 +76,12 @@ /** The first example simply picks the first value in a range that does not violate a constraint. **/ thex: - [amb [Data..consify [range 1 5]]] [] \ x → + [amb [Data..consify [Data..range 1 5]]] [] \ x → [if x < 3 - [amb [list]] + [amb [Data..list]] x] -•stdout << `The first solution is: ´ << thex << "{n} +IO..•stdout << `The first solution is: ´ << thex << "{n} /** The next example is a bit more advanced, having nested amb applications, and generating @@ -98,7 +98,7 @@ thex: **/ amb_null_wrapper: \ fun → (escape_continuation return - [( \ dummy → [list] ) + [( \ dummy → [Data..list] ) !(escape_continuation amb_fail (escape_continue return [fun]))]) @@ -106,12 +106,12 @@ amb_null_wrapper: \ fun → **/ terms: amb_null_wrapper [] \ → - [amb [Data..consify [range 1 5]]] [] \ x → - [amb [Data..consify [range 1 5]]] [] \ y → + [amb [Data..consify [Data..range 1 5]]] [] \ x → + [amb [Data..consify [Data..range 1 5]]] [] \ y → [if x < y or x + y ≠ 4 - [amb [list]] - [cons [vector x y] - [amb [list]]]] + [amb [Data..list]] + [Data..cons [Data..vector x y] + [amb [Data..list]]]] /** Note that the stream is lazy; values are only computed as needed. This may be verified ** using the debug log to record the order of the times when values are being created and used. @@ -119,9 +119,9 @@ terms: /** Now, we just use a left fold with state to display the stream. **/ -•stdout << `Numbers that sum to four, the second not being bigger than the first:´ +IO..•stdout << `Numbers that sum to four, the second not being bigger than the first:´ [terms.foldsl \ •dst p e → { •dst << ` ´ << e[]'0 << `+´ << e[]'1 } void - •stdout] -•stdout << "{n} + IO..•stdout ] +IO..•stdout << "{n} diff --git a/examples/features/annotations.shape b/examples/features/annotations.shape index a2209489..87a62af0 100644 --- a/examples/features/annotations.shape +++ b/examples/features/annotations.shape @@ -17,15 +17,16 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Graphics..PDF -•page << [stroke [Geometry..circle 5cm]] +IO..•page << [Graphics..stroke [Geometry..circle 5cm]] -myFont: @text_font:FONT_HELVETICA & @text_size:1cm +myFont: Text..@font:Text..Font..HELVETICA & Text..@size:1cm { - bar: [[shift (~2cm,~2cm)] myFont | (newText << `Blah´ )] - •page << bar - •page << [annotationText site:[site target:bar + bar: [[shift (~2cm,~2cm)] myFont | (Text..newText << `Blah´ )] + IO..•page << bar + IO..•page << [annotationText site:[site target:bar text:`The long story just goes on and on...´ width:2bp] title:`Extended version´] @@ -33,8 +34,8 @@ myFont: @text_font:FONT_HELVETICA & @text_size:1cm { bar: [Geometry..circle 5mm] >> stroke >> [shift (3cm,1cm)] - •page << bar - •page << [annotationLaunch site:[site target:bar + IO..•page << bar + IO..•page << [annotationLaunch site:[site target:bar text:`The true source.´ width:2bp] file:`https://sourceforge.net/projects/lang-shapes/´] @@ -42,8 +43,8 @@ myFont: @text_font:FONT_HELVETICA & @text_size:1cm { bar: [Geometry..circle 5mm] >> stroke >> [shift (3cm,2cm)] - •page << bar - •page << [annotationLaunch site:[site target:bar + IO..•page << bar + IO..•page << [annotationLaunch site:[site target:bar text:`The look.´ width:2bp] file:`../applications/droo.pdf´] diff --git a/examples/features/approximators.shape b/examples/features/approximators.shape index f91393c0..a215f3b8 100644 --- a/examples/features/approximators.shape +++ b/examples/features/approximators.shape @@ -18,21 +18,21 @@ ##lookin ..Shapes -•rand: [newRandom (•time)] +•rand: [Random..newRandom (•time)] { pth: [Geometry..circle 1cm] - •page << [stroke pth] + IO..•page << [Graphics..stroke pth] - •page << + IO..•page << ( @width: 0.2bp | - [[range '1 '200].foldsl + [[Data..range '1 '200].foldsl \ pile e •randstate → { - p: 1.4cm * [random2D •randstate] - pile & [stroke p--[approximator pth p].p ] + p: 1.4cm * [Random..ball2D •randstate] + pile & [Graphics..stroke p--[Geometry..approximator pth p].p ] } null •rand @@ -41,26 +41,26 @@ } randPath: \ n •rand → - [[range '1 n].foldsl - \ pile e •randstate → pile--( ^ )<(1cm*[random2D •randstate])>( 2mm * (1+[random1D •randstate]) ^ 180°*[random1D •randstate] ) - emptypath + [[Data..range '1 n].foldsl + \ pile e •randstate → pile--( ^ )<(1cm*[Random..ball2D •randstate])>( 2mm * (1+[Random..ball1D •randstate]) ^ 180°*[Random..ball1D •randstate] ) + Geometry..emptypath •rand] { sh: [shift (3cm,0cm)] pth: sh [] [randPath '10 •rand] - •page << [stroke pth] - •page << @stroking:RGB_RED | [stroke controlling [] pth] + IO..•page << [Graphics..stroke pth] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke controlling [] pth] - •page << + IO..•page << ( @width: 0.2bp | - [[range '1 '200].foldsl + [[Data..range '1 '200].foldsl \ pile e •randstate → { - p: sh [] 1.4cm * [random2D •randstate] - pile & [stroke p--[approximator pth p].p ] + p: sh [] 1.4cm * [Random..ball2D •randstate] + pile & [Graphics..stroke p--[Geometry..approximator pth p].p ] } null •rand diff --git a/examples/features/approximators3d.shape b/examples/features/approximators3d.shape index 0d8ba483..55ede3de 100644 --- a/examples/features/approximators3d.shape +++ b/examples/features/approximators3d.shape @@ -17,8 +17,9 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -•rand: [newRandom (•time)] +•rand: [Random..newRandom (•time)] nIter: '40 @@ -26,69 +27,69 @@ nIter: '40 pth: [immerse [Geometry..circle 1cm]] /** - pth: [[range '0 '3].foldl - \ pile e → { sl: [pth0 e*1.] pile--(+sl.rv*sl.rT)<(sl.p + 0.1mm*[random3D])>(+sl.v*sl.T) - emptypath3D]--cycle + pth: [[Data..range '0 '3].foldl + \ pile e → { sl: [pth0 e*1.] pile--(+sl.rv*sl.rT)<(sl.p + 0.1mm*[Random..ball3D])>(+sl.v*sl.T) + Geometry3D..emptypath]--cycle **/ - •page << view [] [stroke pth] + IO..•page << view [] [Graphics..stroke pth] - •timer: newTimer - •page << + •timer: Debug..newTimer + IO..•page << ( @width: 0.2bp | - [[range '1 nIter].foldsl + [[Data..range '1 nIter].foldsl \ pile e •randstate → { - p: 1.4cm * [random3D •randstate] -|** tim: newTimer << - sl: [approximator pth p] -|** tim; + p: 1.4cm * [Random..ball3D •randstate] +|** tim: Debug..newTimer + sl: [Geometry..approximator pth p] +|** tim; a: (p - sl.p) /_ sl.T - [debuglog_before - [sprintf `%g°´+"{n} a / 1° ] |** [sprintf `, %gs´+"{n} tim] - pile & [view @stroking:[rgb 0 [min 1 [abs a - 90°]/0.1°] 0] | [stroke p--sl.p]]] + [Debug..log_before + [String..sprintf `%g°´+"{n} a / 1° ] |** [String..sprintf `, %gs´+"{n} tim] + pile & [view @stroking:[rgb 0 [Numeric..Math..min 1 [Numeric..Math..abs a - 90°]/0.1°] 0] | [Graphics..stroke p--sl.p]]] } null •rand ] ) timer: •timer; - •stdout << [sprintf `Average time: %gs´ timer / nIter] << "{n} + IO..•stdout << [String..sprintf `Average time: %gs´ (timer / nIter)] << "{n} } randPath: \ n •randstate → - [[range '1 n].foldsl - \ pile e •st → { h: 3mm*[random3D •st] pile--(+~h)<(1cm*[random3D •st])>(+h) } - emptypath3D •randstate]--cycle + [[Data..range '1 n].foldsl + \ pile e •st → { h: 3mm*[Random..ball3D •st] pile--(+~h)<(1cm*[Random..ball3D •st])>(+h) } + Geometry3D..emptypath •randstate]--cycle { sh: [shift (3cm,0cm,0cm)] pth: sh [] [randPath '10 •rand] - •page << view [] [stroke pth] - •page << @stroking:RGB_RED | ( view [] [stroke controlling [] pth] ) + IO..•page << view [] [Graphics..stroke pth] + IO..•page << @stroking:Traits..RGB..RED | ( view [] [Graphics..stroke controlling [] pth] ) - •timer: newTimer - •page << + •timer: Debug..newTimer + IO..•page << ( @width: 0.2bp | - [[range '1 nIter].foldsl + [[Data..range '1 nIter].foldsl \ pile e •randstate → { - p: sh [] 1.4cm * [random3D •randstate] -|** tim: newTimer - sl: [approximator pth p] -|** tim; + p: sh [] 1.4cm * [Random..ball3D •randstate] +|** tim: Debug..newTimer + sl: [Geometry..approximator pth p] +|** tim; a: (p - sl.p) /_ sl.T - [debuglog_before - [sprintf `%g°´+"{n} a / 1° ] |** [sprintf `, %gs´+"{n} tim] - pile & [view @stroking:[rgb 0 [min 1 [abs a - 90°]/0.1°] 0] | [stroke p--sl.p]]] + [Debug..log_before + [String..sprintf `%g°´+"{n} a / 1° ] |** [String..sprintf `, %gs´+"{n} tim] + pile & [view @stroking:[rgb 0 [Numeric..Math..min 1 [Numeric..Math..abs a - 90°]/0.1°] 0] | [Graphics..stroke p--sl.p]]] } null •rand ] ) timer: •timer; - •stdout << [sprintf `Average time: %gs´ timer / nIter] << "{n} + IO..•stdout << [String..sprintf `Average time: %gs´ (timer / nIter)] << "{n} } diff --git a/examples/features/arclength.shape b/examples/features/arclength.shape index 5f268150..8d7136d5 100644 --- a/examples/features/arclength.shape +++ b/examples/features/arclength.shape @@ -18,25 +18,26 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry +##lookin ..Shapes..Geometry3D |** pth: (0cm,0cm)--(2cm,3cm)--(3cm,2cm) -|** •page << [stroke pth] -|** •page << [[range '0 '10].foldl \ p e → ( p & [stroke [[shift [point pth [arctime pth e*0.1*[abs pth]]]] [Geometry..circle 2mm]]] ) null] +|** IO..•page << [Graphics..stroke pth] +|** IO..•page << [[Data..range '0 '10].foldl \ p e → ( p & [Graphics..stroke [[shift [point pth [arctime pth e*0.1*[Numeric..Math..abs pth]]]] [circle 2mm]]] ) null] @dash:[dashpattern 2.5cm 3mm 8mm 1cm] | { r: 15cm - viewRot: [rotate3D dir:(~1,0,0) angle:30°] - •page << [view [stroke [viewRot [immerse [[rotate 10°] (~r,~r)--(~r,r)--(r,r)--(r,~r)--cycle]]]]] - •page << [view @dash:[dashpattern]|[stroke [viewRot [immerse [[rotate 10°]*[shift (~r,~r)] [Geometry..circle 7mm]]]]]] + viewRot: [Geometry3D..rotate dir:(~1,0,0) angle:30°] + IO..•page << [view [Graphics..stroke [viewRot [immerse [[rotate 10°] (~r,~r)--(~r,r)--(r,r)--(r,~r)--cycle]]]]] + IO..•page << [view @dash:[dashpattern]|[Graphics..stroke [viewRot [immerse [[rotate 10°]*[shift (~r,~r)] [circle 7mm]]]]]] a: 5° - •page << [view [stroke [viewRot [immerse @defaultunit:1%c|[[rotate 10°] (^~a)<(~r,~r)>(^90°+a)--(^~90°-a)<(~r,r)>(^a)--(^180°-a)<(r,r)>(^~90°+a)--(^90°-a)<(r,~r)>(^~180°+a)--cycle]]]]] - •page << [Geometry..circle 5mm] >> immerse >> viewRot >> stroke >> view - •page << [Geometry..circle 10mm] >> immerse >> viewRot >> stroke >> view - •page << [Geometry..circle 15mm] >> immerse >> viewRot >> stroke >> view - •page << [Geometry..circle 20mm] >> immerse >> viewRot >> stroke >> view - •page << [Geometry..circle 25mm] >> immerse >> viewRot >> stroke >> view - •page << [Geometry..circle 30mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [view [Graphics..stroke [viewRot [immerse Geometry..@defaultunit:1%c|[[rotate 10°] (^~a)<(~r,~r)>(^90°+a)--(^~90°-a)<(~r,r)>(^a)--(^180°-a)<(r,r)>(^~90°+a)--(^90°-a)<(r,~r)>(^~180°+a)--cycle]]]]] + IO..•page << [circle 5mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [circle 10mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [circle 15mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [circle 20mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [circle 25mm] >> immerse >> viewRot >> stroke >> view + IO..•page << [circle 30mm] >> immerse >> viewRot >> stroke >> view } diff --git a/examples/features/argument.shape b/examples/features/argument.shape index 44d25db5..f12264c4 100644 --- a/examples/features/argument.shape +++ b/examples/features/argument.shape @@ -29,7 +29,7 @@ **/ argumentVariation: \ pth origin → [if pth.closed? - 360° * [winding pth origin] + 360° * [Geometry..winding pth origin] { pth0: [[shift ~origin] pth] dStart: pth0.end.p @@ -38,8 +38,8 @@ argumentVariation: \ pth origin → aEnd: { tmp: [angle dEnd] [if tmp ≥ aStart tmp tmp+360°] } aStep: (aEnd - aStart) / 4 - d: [max [abs dStart] [abs dEnd]] * [normalized dStart] - 360° * [winding [[range '1 '3].foldl \ p e → (p--[[rotate e*aStep] d]) pth0]--cycle (0m,0m)] - ( aEnd - aStart ) + d: [Numeric..Math..max [Numeric..Math..abs dStart] [Numeric..Math..abs dEnd]] * [normalized dStart] + 360° * [Geometry..winding [[Data..range '1 '3].foldl \ p e → (p--[[rotate e*aStep] d]) pth0]--cycle (0m,0m)] - ( aEnd - aStart ) }] /** Just for illustration, the path used to compute the winding number is extracted from the function body above. @@ -52,9 +52,9 @@ closedPath: \ pth origin → aEnd: { tmp: [angle dEnd] [if tmp ≥ aStart tmp tmp+360°] } aStep: (aEnd - aStart) / 4 - d: [max [abs dStart] [abs dEnd]] * [normalized dStart] + d: [Numeric..Math..max [Numeric..Math..abs dStart] [Numeric..Math..abs dEnd]] * [normalized dStart] [[shift origin] - [[range '1 '3].foldl \ p e → (p--[[rotate e*aStep] d]) [[shift ~origin] pth]]--cycle] + [[Data..range '1 '3].foldl \ p e → (p--[[rotate e*aStep] d]) [[shift ~origin] pth]]--cycle] } /** This helper function makes an illustration for a single path. @@ -62,10 +62,10 @@ closedPath: \ pth origin → **/ helper: \ pth → ( newGroup - << @stroking:RGB_RED | [stroke [Geometry..circle 1mm]] - << @dash:[dashpattern 2bp 2bp] | [stroke [closedPath pth (0m,0m)]] - << [stroke pth head:[Graphics..ShapesArrow width:10 ...]] - << [[shift (0cm,~1cm)] (newText << [sprintf `%.1f°´ [argumentVariation pth (0m,0m)]/1°])]) + << @stroking:Traits..RGB..RED | [Graphics..stroke [Geometry..circle 1mm]] + << @dash:[dashpattern 2bp 2bp] | [Graphics..stroke [closedPath pth (0m,0m)]] + << [Graphics..stroke pth head:[Graphics..ShapesArrow width:10 ...]] + << [[shift (0cm,~1cm)] (Text..newText << [String..sprintf `%.1f°´ [argumentVariation pth (0m,0m)]/1°])]) /** All examples will be constructed as simple variations of this path. **/ @@ -73,7 +73,7 @@ pth: (~1cm,~1cm)>(1%C^100°)--(1%C^)<(2cm,2cm)>(1%C^)--(1%C^)<(1cm,1cm)>(1%C^)-- /** Finally, apply the helper on some paths. **/ -•page << [helper pth] - << [helper [reverse pth]] >> [shift (7cm,0cm)] +IO..•page << [helper pth] + << [helper [Geometry..reverse pth]] >> [shift (7cm,0cm)] << [helper [[shift (~1.5cm,~1cm)] pth]] >> [shift (0cm,~7cm)] - << [helper [reverse [[shift (~1.5cm,~1cm)] pth]]] >> [shift (7cm,~7cm)] + << [helper [Geometry..reverse [[shift (~1.5cm,~1cm)] pth]]] >> [shift (7cm,~7cm)] diff --git a/examples/features/array.shape b/examples/features/array.shape index 62756546..e11da0e0 100644 --- a/examples/features/array.shape +++ b/examples/features/array.shape @@ -23,11 +23,11 @@ v: { N: '36 /** Number of elements we plan to put in the array. **/ - •tmp: newArray /** Create empty array state. **/ + •tmp: Data..newArray /** Create empty array state. **/ •tmp.[reserve N] /** Reserve space for all the elements; not necessary, but efficient. **/ - /** Initialize by tacking on values from the sin function. **/ - [[range '0 N-'1].foldsl - \ p e •dst → { •dst << [sin e*(360°/N)] p } + /** Initialize by tacking on values from the Numeric..Math..sin function. **/ + [[Data..range '0 N-'1].foldsl + \ p e •dst → { •dst << [Numeric..Math..sin e*(360°/N)] p } void •tmp] /** Then make some random access changes... **/ @@ -38,6 +38,6 @@ v: } /** Illustrate the array by plotting it as a function. **/ -[stroke [[range '0 v.size-'1].foldl +[Graphics..stroke [[Data..range '0 v.size-'1].foldl \ p e → p--(e*2mm,[v e]*10mm) - emptypath]] + Geometry..emptypath]] diff --git a/examples/features/arrowdemo.shape b/examples/features/arrowdemo.shape index e39e8f9e..88509a11 100644 --- a/examples/features/arrowdemo.shape +++ b/examples/features/arrowdemo.shape @@ -29,19 +29,19 @@ dynamic @demoArrows identity dynamic ( - [stroke (0cm,1dy)--(+(5cm,0cm)) head:[Graphics..ShapesArrow rearAngle:240° ...]] - & [stroke (0cm,0cm)--(+(5cm,0cm)) head:Graphics..ShapesArrow] - & [stroke (0cm,~1dy)--(+(5cm,0cm)) head:[Graphics..ShapesArrow rearAngle:180° ...]] - & [stroke [shift (0cm,~1dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:[Graphics..ShapesArrow rearAngle:240° ...]] - & [stroke [shift (0cm,~2dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:Graphics..ShapesArrow] - & ( @stroking:RGB_BLUE | [stroke [shift (5cm,~2dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:MetaPostArrow] ) - & [stroke [shift (0cm,~3dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:[Graphics..ShapesArrow rearAngle:180° ...]] + [Graphics..stroke (0cm,1dy)--(+(5cm,0cm)) head:[Graphics..ShapesArrow rearAngle:240° ...]] + & [Graphics..stroke (0cm,0cm)--(+(5cm,0cm)) head:Graphics..ShapesArrow] + & [Graphics..stroke (0cm,~1dy)--(+(5cm,0cm)) head:[Graphics..ShapesArrow rearAngle:180° ...]] + & [Graphics..stroke [shift (0cm,~1dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:[Graphics..ShapesArrow rearAngle:240° ...]] + & [Graphics..stroke [shift (0cm,~2dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:Graphics..ShapesArrow] + & ( @stroking:Traits..RGB..BLUE | [Graphics..stroke [shift (5cm,~2dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:MetaPostArrow] ) + & [Graphics..stroke [shift (0cm,~3dy)][]{c: [Geometry..circle 3cm] [c 2.4]--[c 3.5]} head:[Graphics..ShapesArrow rearAngle:180° ...]] ) -•page << @width:10bp | @demoArrows -•page << @width:3bp | [[shift (0m,~0.4dy)] @demoArrows] -•page << @width:1bp | [[shift (0m,~0.6dy)] @demoArrows] -•page << @width:0.3bp | [[shift (0m,~0.7dy)] @demoArrows] +IO..•page << @width:10bp | @demoArrows +IO..•page << @width:3bp | [[shift (0m,~0.4dy)] @demoArrows] +IO..•page << @width:1bp | [[shift (0m,~0.6dy)] @demoArrows] +IO..•page << @width:0.3bp | [[shift (0m,~0.7dy)] @demoArrows] /** This example ends with a demonstration of how dynamic definitions of an arrowhead allows the width @@ -50,8 +50,8 @@ dynamic @demoArrows identity dynamic @myHead identity dynamic [Graphics..ShapesArrow width:@width*(1.5+4.5bp/(1bp+@width)) ...] -•page << - [[range 5° 350° 20°].foldl +IO..•page << + [[Data..range 5° 350° 20°].foldl \ p e → - ( p & ( @width:10bp*e/360° | [stroke (12cm,~2cm)--(+[dir e]*4cm) head:@myHead]) ) + ( p & ( @width:10bp*e/360° | [Graphics..stroke (12cm,~2cm)--(+[dir e]*4cm) head:@myHead]) ) null] diff --git a/examples/features/asymmetric-notation.shape b/examples/features/asymmetric-notation.shape index 410fa354..14355991 100644 --- a/examples/features/asymmetric-notation.shape +++ b/examples/features/asymmetric-notation.shape @@ -19,14 +19,14 @@ ##lookin ..Shapes /** Below we combine a set of dynamic bindings using the operator & .**/ -f0: @text_font:FONT_COURIER & @text_size:15bp & @text_horizontalscaling:1.4 -slim: @text_horizontalscaling:0.8 +f0: Text..@font:Text..Font..COURIER & Text..@size:15bp & Text..@horizontalscaling:1.4 +slim: Text..@horizontalscaling:0.8 /** Paint some text with the standard font f0. **/ -•page << f0 | [shift (0cm,0cm)] [] ( newText << `Standard font´ ) +IO..•page << f0 | [shift (0cm,0cm)] [] ( Text..newText << `Standard font´ ) /** Now we would like to change one of the text state parameters of f0. Then we might to like this: **/ -•page << f0 | slim | [shift (0cm,~1cm)] [] ( newText << `Slim font using nested scopes´ ) +IO..•page << f0 | slim | [shift (0cm,~1cm)] [] ( Text..newText << `Slim font using nested scopes´ ) /** ** But what if we would like to have a new binding for the text state bindings we just used? @@ -34,11 +34,11 @@ slim: @text_horizontalscaling:0.8 **/ |**f1: f0 & slim /** - ** The reason is that @text_horizontalscaling is bound in both arguments to & . + ** The reason is that Text..@horizontalscaling is bound in both arguments to & . ** This is what we have to do: **/ f1: f0 &| slim -•page << f1 | [shift (0cm,~2cm)] [] ( newText << `Slim font in one scope´ ) +IO..•page << f1 | [shift (0cm,~2cm)] [] ( Text..newText << `Slim font in one scope´ ) /** ** Note how the operator &| reminds of how the operator | could have been used unless we wanted a diff --git a/examples/features/basic3d.shape b/examples/features/basic3d.shape index 75b5c7a5..53de59c4 100644 --- a/examples/features/basic3d.shape +++ b/examples/features/basic3d.shape @@ -17,10 +17,11 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -tf: [scale3D x:1.3] +tf: [Geometry3D..scale x:1.3] -rot: [rotate3D (1,1,1) 30°] +rot: [Geometry3D..rotate (1,1,1) 30°] pth: (0cm,0cm,0cm)--(0cm,1cm,0cm)--(1cm,1cm,0cm)--(1cm,0cm,0cm)--(1cm,0cm,1cm)--(1cm,1cm,1cm)--(0cm,1cm,1cm)--(0cm,0cm,1cm) @@ -34,16 +35,16 @@ screw2: [rot screw] @eyez:10cm | { -•stderr << `Length of screw in 3D: ´ << [duration screw] << "{n} -•stderr << `Length of screw view: ´ << [duration [view screw]] << "{n} +IO..•stderr << `Length of screw in 3D: ´ << [Geometry..duration screw] << "{n} +IO..•stderr << `Length of screw view: ´ << [Geometry..duration [view screw]] << "{n} -•page << [stroke [view pth2]] -•page << [stroke [view screw2]] +IO..•page << [Graphics..stroke [view pth2]] +IO..•page << [Graphics..stroke [view screw2]] -mark: \ z → ( @stroking:RGB_RED & @width:0.3bp | ( [stroke [view (z-(0.5mm,0.5mm,0mm))--(z+(0.5mm,0.5mm,0mm))]] & [stroke [view (z+(~0.5mm,0.5mm,0mm))--(z+(0.5mm,~0.5mm,0mm))]] ) ) +mark: \ z → ( @stroking:Traits..RGB..RED & @width:0.3bp | ( [Graphics..stroke [view (z-(0.5mm,0.5mm,0mm))--(z+(0.5mm,0.5mm,0mm))]] & [Graphics..stroke [view (z+(~0.5mm,0.5mm,0mm))--(z+(0.5mm,~0.5mm,0mm))]] ) ) -•page << [[range 0.15 [duration pth2]*1-1 0.3].foldl \ p e → ( p & [mark [pth2 e].p] ) null] -•page << [[range 0.15 [duration screw2]*1-1 0.3].foldl \ p e → ( p & [mark [screw2 e].p] ) null] +IO..•page << [[Data..range 0.15 [Geometry..duration pth2]*1-1 0.3].foldl \ p e → ( p & [mark [pth2 e].p] ) null] +IO..•page << [[Data..range 0.15 [Geometry..duration screw2]*1-1 0.3].foldl \ p e → ( p & [mark [screw2 e].p] ) null] -|** •page << @eyez:∞ | [view [stroke pth]] +|** IO..•page << @eyez:∞ | [view [Graphics..stroke pth]] } diff --git a/examples/features/bendtext.shape b/examples/features/bendtext.shape index 45f7b5ea..aca6ca4e 100644 --- a/examples/features/bendtext.shape +++ b/examples/features/bendtext.shape @@ -19,19 +19,19 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout -message: @text_size:5mm | [kern `Hi, Dro´ 0.3 `oler!´] +message: Text..@size:5mm | [kern `Hi, Dro´ 0.3 `oler!´] -•page << ( newText << message ) +IO..•page << ( Text..newText << message ) -baseline: @defaultunit:1%f | (0cm,~1cm)>(^45°)--(1.5cm^180°)<(3cm,~2cm) -•page << @stroking:RGB_RED | [stroke baseline] +baseline: Geometry..@defaultunit:1%f | (0cm,~1cm)>(^45°)--(1.5cm^180°)<(3cm,~2cm) +IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke baseline] -•page << +IO..•page << [message.list.foldl \ pile distChar → { - c: ( newText << distChar.cdr ) - sl: [baseline distChar.car + 0.5*[xmax [bbox c]]] + c: ( Text..newText << distChar.cdr ) + sl: [baseline distChar.car + 0.5*[xmax [Layout..bbox c]]] pile & [[shift sl.p]()[rotate [angle sl.T]] [Layout..center_x c] ] diff --git a/examples/features/bleed.shape b/examples/features/bleed.shape index 93898940..f694861a 100644 --- a/examples/features/bleed.shape +++ b/examples/features/bleed.shape @@ -21,10 +21,10 @@ helper: \ obj → ( newGroup - << @nonstroking:[gray 0.5] | [fill [bbox obj 'bleed]] - << @nonstroking:GRAY_WHITE | [fill [bbox obj]] + << @nonstroking:[gray 0.5] | [Graphics..fill [Layout..bbox obj 'bleed]] + << @nonstroking:Traits..BW..WHITE | [Graphics..fill [Layout..bbox obj]] << obj ) -•page << [helper [TeX `O´]] - << [shift (2cm,0cm)] [] [helper [Layout..enlarge_bleedbox [TeX `O´] (2bp,2bp)]] - << @TeX_bleed:3bp | [shift (3cm,3cm)] [] [helper [bboxed_enlarge [TeX `O´] (~1bp,~1bp)]] +IO..•page << [helper [Graphics..TeX `O´]] + << [shift (2cm,0cm)] [] [helper [enlarge_bleedbox [Graphics..TeX `O´] (2bp,2bp)]] + << @TeX_bleed:3bp | [shift (3cm,3cm)] [] [helper [bboxed_enlarge [Graphics..TeX `O´] (~1bp,~1bp)]] diff --git a/examples/features/blend.shape b/examples/features/blend.shape index 64c8cb3c..c6b0d88d 100644 --- a/examples/features/blend.shape +++ b/examples/features/blend.shape @@ -21,23 +21,23 @@ r: 1cm -|** •page << [shift (0*4*r,0*4*r)] [] -|** ( @blend: BLEND_LIGHTEN +|** IO..•page << [shift (0*4*r,0*4*r)] [] +|** ( @blend: Traits..Blend..LIGHTEN |** | -|** ( newGroup << @nonstroking:RGB_RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill -|** << @nonstroking:RGB_GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill -|** << @nonstroking:RGB_BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill +|** ( newGroup << @nonstroking:Traits..RGB..RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill +|** << @nonstroking:Traits..RGB..GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill +|** << @nonstroking:Traits..RGB..BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill |** ) |** ) -•page << [shift (1*4*r,0*4*r)] [] - ( @blend: BLEND_LIGHTEN +IO..•page << [shift (1*4*r,0*4*r)] [] + ( @blend: Traits..Blend..LIGHTEN & - @blendspace: DEVICE_GRAY + @blendspace: Traits..Device..GRAY | - ( newGroup << @nonstroking:RGB_RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill - << [tgroup ( newGroup << @nonstroking:RGB_GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill - << @nonstroking:RGB_BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill ) + ( newGroup << @nonstroking:Traits..RGB..RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill + << [Graphics..tgroup ( newGroup << @nonstroking:Traits..RGB..GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill + << @nonstroking:Traits..RGB..BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill ) ] ) ) diff --git a/examples/features/boxedeq.shape b/examples/features/boxedeq.shape index d1a2a472..1963a82c 100644 --- a/examples/features/boxedeq.shape +++ b/examples/features/boxedeq.shape @@ -21,7 +21,7 @@ ##lookin ..Shapes -•page << [TeX ` +IO..•page << [Graphics..TeX ` \fbox{\begin{Beqnarray*} &\begin{aligned} x &= 1 \\ diff --git a/examples/features/characters.shape b/examples/features/characters.shape index d3429767..37953899 100644 --- a/examples/features/characters.shape +++ b/examples/features/characters.shape @@ -18,15 +18,15 @@ ##lookin ..Shapes -helper: \ c s •dst → { •dst << `The character ´ << c << `(´ << s << `) is Unicode U+´ << c.code.bits_hex << "{n} } +helper: \ c s •dst → { •dst << `The character ´ << c << `(´ << s << `) is String..Unicode U+´ << c.code.bits_hex << "{n} } -[helper '"A `A´ •stdout] -[helper '"• `•´ •stdout] -[helper '"§ `§´ •stdout] -[helper '"ä `ä´ •stdout] -[helper '&U+0060; "{{`}} •stdout] -[helper [`åäö´.UTF8select '1] `ä´ •stdout] -[helper [Unicode '0x00E0 + '10] `ê´ •stdout] +[helper '"A `A´ IO..•stdout ] +[helper '"• `•´ IO..•stdout ] +[helper '"§ `§´ IO..•stdout ] +[helper '"ä `ä´ IO..•stdout ] +[helper '&U+0060; "{{`}} IO..•stdout ] +[helper [`åäö´.UTF8select '1] `ä´ IO..•stdout ] +[helper [String..Unicode '0x00E0 + '10] `ê´ IO..•stdout ] @spot diff --git a/examples/features/clipping.shape b/examples/features/clipping.shape index e40d1bb7..716a4e71 100644 --- a/examples/features/clipping.shape +++ b/examples/features/clipping.shape @@ -19,7 +19,7 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry -bg: @nonstroking:RGB_RED | [fill [rectangle (0cm,0cm) (3cm,3cm)]] +bg: @nonstroking:Traits..RGB..RED | [Graphics..fill [rectangle (0cm,0cm) (3cm,3cm)]] -•page << [clip bg ( [[shift (0.4cm,1.6cm)] [Geometry..circle 0.3cm]] & [[shift (0.9cm,1.6cm)] [Geometry..circle 0.3cm]] )] -•page << [clipodd bg ( [Geometry..circle 1.5cm] & [rectangle (1cm,1cm) (2cm,2cm)] )] +IO..•page << [Graphics..clip bg ( [[shift (0.4cm,1.6cm)] [Geometry..circle 0.3cm]] & [[shift (0.9cm,1.6cm)] [Geometry..circle 0.3cm]] )] +IO..•page << [Graphics..clipodd bg ( [Geometry..circle 1.5cm] & [rectangle (1cm,1cm) (2cm,2cm)] )] diff --git a/examples/features/colorinterpolator.shape b/examples/features/colorinterpolator.shape index e77d84c0..2f2955f5 100644 --- a/examples/features/colorinterpolator.shape +++ b/examples/features/colorinterpolator.shape @@ -24,9 +24,9 @@ rgbinterp: ( newColorInterpolator << 2.5 << [rgb 0 0 1] << 3.0 << [rgb 0 1 0] ) -•page << - [[range 0 100 1].foldl - \ p e → p & ( @nonstroking:[rgbinterp 4/100*e] | [[shift (e*2mm,0)] [fill [rectangle (0mm,0mm) (5mm,5mm)]]] ) +IO..•page << + [[Data..range 0 100 1].foldl + \ p e → p & ( @nonstroking:[rgbinterp 4/100*e] | [[shift (e*2mm,0)] [Graphics..fill [Geometry..rectangle (0mm,0mm) (5mm,5mm)]]] ) null] grayinterp: ( newColorInterpolator @@ -35,10 +35,10 @@ grayinterp: ( newColorInterpolator << 2.5 << [gray 0] << 3.0 << [gray 0.3] ) -•page << +IO..•page << [[shift (0, 5mm)] - [[range 0 100 1].foldl - \ p e → p & ( @nonstroking:[grayinterp 4/100*e] | [[shift (e*2mm,0)] [fill [rectangle (0mm,0mm) (5mm,5mm)]]] ) + [[Data..range 0 100 1].foldl + \ p e → p & ( @nonstroking:[grayinterp 4/100*e] | [[shift (e*2mm,0)] [Graphics..fill [Geometry..rectangle (0mm,0mm) (5mm,5mm)]]] ) null]] cmykinterp: ( newColorInterpolator @@ -47,8 +47,8 @@ cmykinterp: ( newColorInterpolator << 2.5 << [cmyk 0 0 1 0] << 3.0 << [cmyk 0 1 0 0] ) -•page << +IO..•page << [[shift (0mm, 10mm)] - [[range 0 100 1].foldl - \ p e → p & ( @nonstroking:[cmykinterp 4/100*e] | [[shift (e*2mm,0)] [fill [rectangle (0mm,0mm) (5mm,5mm)]]] ) + [[Data..range 0 100 1].foldl + \ p e → p & ( @nonstroking:[cmykinterp 4/100*e] | [[shift (e*2mm,0)] [Graphics..fill [Geometry..rectangle (0mm,0mm) (5mm,5mm)]]] ) null]] diff --git a/examples/features/cond-impl.blank b/examples/features/cond-impl.blank index 1b184a66..baa26a27 100644 --- a/examples/features/cond-impl.blank +++ b/examples/features/cond-impl.blank @@ -31,33 +31,33 @@ |** ![error `No matching cond clause.´] |** }) -•stdout +IO..•stdout << `cond: ´ - << [cond [cons 1=0 `Doesn't happen, but not evaluated anyway.´] - [cons 1=0 [error 'bad `(while testing cond)´ `This should never be evaluated (false case)!´]] - [cons 1=1 `This is the correct answer.´] - [cons 1=1 [error 'bad `(while testing cond)´ `This should never be evaluated (after true case)!´]] - [cons true `This is the default, in case no other case is true.´]] + << [cond [Data..cons 1=0 `Doesn't happen, but not evaluated anyway.´] + [Data..cons 1=0 [error 'bad `(while testing cond)´ `This should never be evaluated (false case)!´]] + [Data..cons 1=1 `This is the correct answer.´] + [Data..cons 1=1 [error 'bad `(while testing cond)´ `This should never be evaluated (after true case)!´]] + [Data..cons true `This is the default, in case no other case is true.´]] << "{n} purecond: \ <>cases → { tmp: [(list []<>cases).foldr - \ p e → [if [typeof p] = §Void + \ p e → [if [typeof p] = Data..Type..§Void [if e.car e p] p] void] - [if [typeof tmp] = §Void + [if [typeof tmp] = Data..Type..§Void [error 'misc VARNAME `No matching cond clause.´] tmp.cdr] } -•stdout +IO..•stdout << `purecond: ´ - << [purecond [cons 1=0 `Doesn't happen, but not evaluated anyway.´] - [cons 1=0 [error 'bad `(while testing purecond)´ `This should never be evaluated (false case)!´]] - [cons 1=1 `This is the correct answer.´] - [cons 1=1 [error 'bad `(while testing purecond)´ `This should never be evaluated (after true case)!´]] - [cons true `This is the default, in case no other case is true.´]] + << [purecond [Data..cons 1=0 `Doesn't happen, but not evaluated anyway.´] + [Data..cons 1=0 [error 'bad `(while testing purecond)´ `This should never be evaluated (false case)!´]] + [Data..cons 1=1 `This is the correct answer.´] + [Data..cons 1=1 [error 'bad `(while testing purecond)´ `This should never be evaluated (after true case)!´]] + [Data..cons true `This is the default, in case no other case is true.´]] << "{n} diff --git a/examples/features/cornerpoint.shape b/examples/features/cornerpoint.shape index 76f7a059..d1df4320 100644 --- a/examples/features/cornerpoint.shape +++ b/examples/features/cornerpoint.shape @@ -20,24 +20,24 @@ ##lookin ..Shapes..Graphics { - pth: @defaultunit:5mm | (0cm,0cm)>(^)--(^)<(1cm,0cm^45°)>(^)--(^)<(2cm,0cm) + pth: Geometry..@defaultunit:5mm | (0cm,0cm)>(^)--(^)<(1cm,0cm^45°)>(^)--(^)<(2cm,0cm) sl: [pth 1] - •page << @stroking:RGB_RED | [stroke sl.p--(+ ~4mm*sl.rT)] - << [stroke pth head:Graphics..ShapesArrow] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke sl.p--(+ ~4mm*sl.rT)] + << [Graphics..stroke pth head:Graphics..ShapesArrow] } { - pth: @defaultunit:1%C | (0cm,~1cm)>(^)--(^)<(1cm,~1cm^~45°)>(^)--(^)<(2cm,~1cm) + pth: Geometry..@defaultunit:1%C | (0cm,~1cm)>(^)--(^)<(1cm,~1cm^~45°)>(^)--(^)<(2cm,~1cm) sl: [pth 1] - •page << @stroking:RGB_RED | [stroke sl.p--(+ ~4mm*sl.rT)] - << [stroke pth head:Graphics..ShapesArrow] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke sl.p--(+ ~4mm*sl.rT)] + << [Graphics..stroke pth head:Graphics..ShapesArrow] } { - pth: @defaultunit:1%F | (0cm,~9mm)>(5mm^0°)--(5mm^~90°)<(1cm,~0.5cm ^ )>(10mm^)--(5mm^~90°)<(0cm,~1mm) + pth: Geometry..@defaultunit:1%F | (0cm,~9mm)>(5mm^0°)--(5mm^~90°)<(1cm,~0.5cm ^ )>(10mm^)--(5mm^~90°)<(0cm,~1mm) sl: [pth 1] - •page << @stroking:RGB_RED | [stroke sl.p--(+ ~4mm*sl.rT)] - << [stroke pth head:Graphics..ShapesArrow] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke sl.p--(+ ~4mm*sl.rT)] + << [Graphics..stroke pth head:Graphics..ShapesArrow] } diff --git a/examples/features/curry.blank b/examples/features/curry.blank index 3bbb1ba7..0909443e 100644 --- a/examples/features/curry.blank +++ b/examples/features/curry.blank @@ -20,12 +20,12 @@ foo: \ a b c → a + b + c -•stdout << [foo `1´ `2´ `3´] << "{n} +IO..•stdout << [foo `1´ `2´ `3´] << "{n} bar: [foo b:`BAR´ ...] ofo: [bar `ofo´ ...] -•stdout << [ofo `2´] << "{n} -•stdout << [bar `1´ `3´] << "{n} -•stdout << [foo [...] b:`2´ [...] `1´ [...] `3´] << "{n} +IO..•stdout << [ofo `2´] << "{n} +IO..•stdout << [bar `1´ `3´] << "{n} +IO..•stdout << [foo [...] b:`2´ [...] `1´ [...] `3´] << "{n} diff --git a/examples/features/curvature.shape b/examples/features/curvature.shape index d42a004c..92874b81 100644 --- a/examples/features/curvature.shape +++ b/examples/features/curvature.shape @@ -21,18 +21,18 @@ pth: (0cm,0cm)>(1cm,0cm)--(0cm,2cm)<(1cm,2cm) -•page << [stroke pth] +IO..•page << [Graphics..stroke pth] -•page << +IO..•page << ( -@width:0.3bp & @stroking:RGB_RED +@width:0.3bp & @stroking:Traits..RGB..RED | -[[range 0.1 0.9 0.2].foldl +[[Data..range 0.1 0.9 0.2].foldl \ p e → { sl: [pth e] [if (|sl.ik|) < 50cm - ( p & [stroke [shift sl.p+sl.N*sl.ik] [] [Geometry..circle sl.ik]] ) + ( p & [Graphics..stroke [shift sl.p+sl.N*sl.ik] [] [Geometry..circle sl.ik]] ) p] } null] diff --git a/examples/features/data-strings.blank b/examples/features/data-strings.blank index 0aad5d6e..0275f361 100644 --- a/examples/features/data-strings.blank +++ b/examples/features/data-strings.blank @@ -22,7 +22,7 @@ AringPiAlpha: "{C3A5CF80CEB1} junk: "{C3A5 0C80 CEB1} data: "{C3A5 0080 CEB1} -•stdout << `String #1: This string is partly outside ASCII (åπα), but most characters {UFT code points} are ASCII.´ << "{n} +IO..•stdout << `String #1: This string is partly outside ASCII (åπα), but most characters {UFT code points} are ASCII.´ << "{n} << "{{String #2: This string is partly outside ASCII (}C3A5 CF80 CEB1{), but most characters }7B{UFT code points}7D{ are ASCII.}} << "{n} << `It is easy to generate strings by writing all characters in hex: ´ << AringPiAlpha << "{n} << `Shapes, is ´ << ("`") << AringPiAlpha << ("´") << ` valid UTF-8? → ´ << AringPiAlpha.UTF8? << "{n} diff --git a/examples/features/distance.shape b/examples/features/distance.shape index c4ce0ab3..7858e943 100644 --- a/examples/features/distance.shape +++ b/examples/features/distance.shape @@ -21,9 +21,9 @@ helper: \ pth1 pth2 → ( newGroup - << [stroke pth1] << [stroke pth2] - << [Geometry..circle 3mm] >> [shift [approximator pth1 pth2].p] >> stroke ) + << [Graphics..stroke pth1] << [Graphics..stroke pth2] + << [circle 3mm] >> [shift [approximator pth1 pth2].p] >> stroke ) -•page << [helper [Geometry..circle 2cm] [Geometry..circle 3cm] >> [shift (4cm,5cm)]] +IO..•page << [helper [circle 2cm] [circle 3cm] >> [shift (4cm,5cm)]] -•page << [helper [Geometry..circle 2cm] [Geometry..circle 3cm] >> [shift (5mm,3mm)]] >> [shift (5cm,0)] +IO..•page << [helper [circle 2cm] [circle 3cm] >> [shift (5mm,3mm)]] >> [shift (5cm,0)] diff --git a/examples/features/distance3d.shape b/examples/features/distance3d.shape index 89a2eac8..2cb49400 100644 --- a/examples/features/distance3d.shape +++ b/examples/features/distance3d.shape @@ -18,13 +18,14 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry +##lookin ..Shapes..Geometry3D -tfView: [rotate3D dir:(1,0,0) angle:~70°]*[rotate3D dir:(0,0,1) angle:20°] +tfView: [Geometry3D..rotate dir:(1,0,0) angle:~70°]*[Geometry3D..rotate dir:(0,0,1) angle:20°] helper: \ pth1 pth2 → -( newGroup3D - << [stroke pth1] << [stroke pth2] - << [facing [stroke [Geometry..circle 3mm]]] >> [shift [approximator pth1 pth2].p] ) +( Graphics3D..newGroup + << [Graphics..stroke pth1] << [Graphics..stroke pth2] + << [facing [Graphics..stroke [Geometry..circle 3mm]]] >> [shift [Geometry..approximator pth1 pth2].p] ) eyew: 5cm @@ -40,7 +41,7 @@ viewStereo: \ obj → @eyez:25cm | { - •page << [helper [Geometry..circle 20u]>>immerse [Geometry..circle 30u]>>immerse >> [rotate3D dir:(1,1,0) angle:30°] >> [shift (40u,50u,10u)]] >> tfView >> viewStereo + IO..•page << [helper [Geometry..circle 20u]>>immerse [Geometry..circle 30u]>>immerse >> [Geometry3D..rotate dir:(1,1,0) angle:30°] >> [shift (40u,50u,10u)]] >> tfView >> viewStereo - •page << [helper [Geometry..circle 20u]>>immerse [Geometry..circle 30u]>>immerse >> [rotate3D dir:(1,1,0) angle:30°] >> [shift (5u,3u,0u)]] >> [shift (0u,0u,~50u)] >> tfView >> viewStereo + IO..•page << [helper [Geometry..circle 20u]>>immerse [Geometry..circle 30u]>>immerse >> [Geometry3D..rotate dir:(1,1,0) angle:30°] >> [shift (5u,3u,0u)]] >> [shift (0u,0u,~50u)] >> tfView >> viewStereo } diff --git a/examples/features/dynamic.blank b/examples/features/dynamic.blank index b2999275..2ec03fc6 100644 --- a/examples/features/dynamic.blank +++ b/examples/features/dynamic.blank @@ -26,9 +26,9 @@ dynamic @a identity 8 f: \ b → @a + b -•stdout << [f 2] << "{n} -•stdout << @a:6 | [f 2] << "{n} -•stdout << [f 2] << "{n} +IO..•stdout << [f 2] << "{n} +IO..•stdout << @a:6 | [f 2] << "{n} +IO..•stdout << [f 2] << "{n} /** ** Note that the default value is delayed, so we can require that a dynamic variable must be bound by the user. @@ -39,10 +39,10 @@ f: \ b → @a + b **/ dynamic @a_noDefault identity [error `Dynamic variable has no default binding.´] -•stdout << @a_noDefault:9 | @a_noDefault << ` No error, see?´ << "{n} +IO..•stdout << @a_noDefault:9 | @a_noDefault << ` No error, see?´ << "{n} -dynamic @a_logDefault identity [debuglog_before `The default value was used.´+"{n} ~9] -•stdout << @a_logDefault << ` Check out the debug log!´ << "{n} +dynamic @a_logDefault identity [Debug..log_before `The default value was used.´+"{n} ~9] +IO..•stdout << @a_logDefault << ` Check out the debug log!´ << "{n} /** @@ -56,7 +56,7 @@ dynamic @b identity dynamic @a + 5 & @c: 20 | { - •stdout << `@b: ´ << @b << "{n} + IO..•stdout << `@b: ´ << @b << "{n} } @@ -76,31 +76,31 @@ b1: @width:1mm & @b:11 & @c:12 /** ** Combine b0 and b1 with priority to the bindings in b1: **/ -b01: locate [] b0 &| b1 +b01: Debug..locate [] b0 &| b1 b01 | { - •stdout << [sourceof b01] << ` :´ << "{n} - •stdout << `@a: ´ << @a << "{n} - •stdout << `@b: ´ << @b << "{n} - •stdout << `@c: ´ << @c << "{n} - •stdout << `@width: ´ << @width << "{n} - •stdout << `@stroking: ´ << @stroking << "{n} + IO..•stdout << [Debug..sourceof b01] << ` :´ << "{n} + IO..•stdout << `@a: ´ << @a << "{n} + IO..•stdout << `@b: ´ << @b << "{n} + IO..•stdout << `@c: ´ << @c << "{n} + IO..•stdout << `@width: ´ << @width << "{n} + IO..•stdout << `@stroking: ´ << @stroking << "{n} } /** ** Combine b0 and b1 with priority to the bindings in b0: **/ -b10: locate [] b1 &| b0 +b10: Debug..locate [] b1 &| b0 b10 | { - •stdout << [sourceof b10] << ` :´ << "{n} - •stdout << `@a: ´ << @a << "{n} - •stdout << `@b: ´ << @b << "{n} - •stdout << `@c: ´ << @c << "{n} - •stdout << `@width: ´ << @width << "{n} - •stdout << `@stroking: ´ << @stroking << "{n} + IO..•stdout << [Debug..sourceof b10] << ` :´ << "{n} + IO..•stdout << `@a: ´ << @a << "{n} + IO..•stdout << `@b: ´ << @b << "{n} + IO..•stdout << `@c: ´ << @c << "{n} + IO..•stdout << `@width: ´ << @width << "{n} + IO..•stdout << `@stroking: ´ << @stroking << "{n} } diff --git a/examples/features/error.blank b/examples/features/error.blank index 6d7ece90..b943b752 100644 --- a/examples/features/error.blank +++ b/examples/features/error.blank @@ -29,8 +29,8 @@ **/ factorial: \ i → { - ![if [typeof i] ≠ §Integer - [error 'type_mismatch VARNAME §Integer.name (indexof i) i]] + ![if [typeof i] ≠ Data..Type..§Integer + [error 'type_mismatch VARNAME Data..Type..§Integer.name (indexof i) i]] ![if i < '0 [error 'out_of_range VARNAME `The factorial is not defined for negative values.´ (indexof i)]] [if i = '0 @@ -50,18 +50,18 @@ ext_factorial: \ i → >> \ ball → [Control..cond - [cons ball.kind = 'out_of_range + [Data..cons ball.kind = 'out_of_range '~1] - [cons ball.kind = 'dtmin + [Data..cons ball.kind = 'dtmin [error 'misc VARNAME `Why on earth did we get a dtmin error here?!´]] - [cons true + [Data..cons true (escape_continue error ball)]]) /** Try the new function! **/ -•stdout << [ext_factorial '10] << "{n} -•stdout << [ext_factorial '~10] << "{n} +IO..•stdout << [ext_factorial '10] << "{n} +IO..•stdout << [ext_factorial '~10] << "{n} /** But don't do this, since the type mismatch error will be re-thrown by ext_factorial: **/ -|**•stdout << [ext_factorial 10] << "{n} +|**IO..•stdout << [ext_factorial 10] << "{n} diff --git a/examples/features/escape.blank b/examples/features/escape.blank index 6a678297..1f0254c1 100644 --- a/examples/features/escape.blank +++ b/examples/features/escape.blank @@ -18,15 +18,15 @@ ##lookin ..Shapes -lst: [list 1 2 3 4 5 6] +lst: [Data..list 1 2 3 4 5 6] -•stdout << [lst.foldr (+) 0] << "{n} +IO..•stdout << [lst.foldr (+) 0] << "{n} -•stdout << 10 + [lst.foldsr (\ p e •dst → { •dst << e << ` ´ p }) - 20 •stdout] +IO..•stdout << 10 + [lst.foldsr (\ p e •dst → { •dst << e << ` ´ p }) + 20 IO..•stdout ] << ` OK!´ << "{n} -•stdout << 10 + (escape_continuation leave +IO..•stdout << 10 + (escape_continuation leave [lst.foldsr (\ p e •dst → [if e = 4 (escape_continue leave e) { •dst << e << ` ´ p }]) - 20 •stdout]) + 20 IO..•stdout ]) << ` OK!´ << "{n} diff --git a/examples/features/evalorder.blank b/examples/features/evalorder.blank index 43b77ac7..07876b42 100644 --- a/examples/features/evalorder.blank +++ b/examples/features/evalorder.blank @@ -21,16 +21,16 @@ /** The order in which the variable bindings are evaluated can be seen by looking ** in the debug log file. ** - ** The order in which •stdout is mutated is just as expected; the same as the + ** The order in which IO..•stdout is mutated is just as expected; the same as the ** left-to-right order of the non-pure expressions. **/ -a: [debuglog_before `1´ 1] -•stdout << a << "{n} +a: [Debug..log_before `1´ 1] +IO..•stdout << a << "{n} -b: [debuglog_before `2´ 2] -c: [debuglog_before `3´ 3] -d: ![debuglog_before `4´ 4] -•stdout << c << "{n} -•stdout << b << "{n} -•stdout << d << "{n} +b: [Debug..log_before `2´ 2] +c: [Debug..log_before `3´ 3] +d: ![Debug..log_before `4´ 4] +IO..•stdout << c << "{n} +IO..•stdout << b << "{n} +IO..•stdout << d << "{n} diff --git a/examples/features/facefun.shape b/examples/features/facefun.shape index 8f7c402b..63a2e58e 100644 --- a/examples/features/facefun.shape +++ b/examples/features/facefun.shape @@ -20,30 +20,31 @@ ##lookin ..Shapes ##lookin ..Shapes..Graphics +##lookin ..Shapes..Geometry3D ahLength:2.5mm strokeWithFlatHead: \ p → - [facing \ tf → [stroke [view [tf p]] head:[MetaPostArrow ahLength:ahLength ...]]] + [facing \ tf → [Graphics..stroke [view [tf p]] head:[MetaPostArrow ahLength:ahLength ...]]] @width:0.5bp | { -•page << -( newGroup3D - << [strokeWithFlatHead (0cm,0cm,0cm)--(1cm,0cm,0cm)] - << [strokeWithFlatHead (0cm,0cm,0cm)--(0cm,1cm,0cm)] - << [strokeWithFlatHead (0cm,0cm,0cm)--(0cm,0cm,1cm)] +IO..•page << +( Graphics3D..newGroup + << [Graphics..strokeWithFlatHead (0cm,0cm,0cm)--(1cm,0cm,0cm)] + << [Graphics..strokeWithFlatHead (0cm,0cm,0cm)--(0cm,1cm,0cm)] + << [Graphics..strokeWithFlatHead (0cm,0cm,0cm)--(0cm,0cm,1cm)] ) - >> [rotate3D dir:(1,0,0) angle:~70°]*[rotate3D dir:(0,0,1) angle:~15°] >> view + >> [Geometry3D..rotate dir:(1,0,0) angle:~70°]*[Geometry3D..rotate dir:(0,0,1) angle:~15°] >> view -•page << -( newGroup3D - << [stroke (0cm,0cm,0cm)--(1cm,0cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,0,1) ...]] - << [stroke (0cm,0cm,0cm)--(0cm,1cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,0,1) ...]] - << [stroke (0cm,0cm,0cm)--(0cm,0cm,1cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,1,0) ...]] +IO..•page << +( Graphics3D..newGroup + << [Graphics..stroke (0cm,0cm,0cm)--(1cm,0cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,0,1) ...]] + << [Graphics..stroke (0cm,0cm,0cm)--(0cm,1cm,0cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,0,1) ...]] + << [Graphics..stroke (0cm,0cm,0cm)--(0cm,0cm,1cm) head:[Graphics3D..MetaPostArrow ahLength:ahLength normal:(0,1,0) ...]] ) - >> [rotate3D dir:(1,0,0) angle:~70°]*[rotate3D dir:(0,0,1) angle:~15°] >> view >> [shift (1cm,0cm)] + >> [Geometry3D..rotate dir:(1,0,0) angle:~70°]*[Geometry3D..rotate dir:(0,0,1) angle:~15°] >> view >> [shift (1cm,0cm)] } diff --git a/examples/features/folds.blank b/examples/features/folds.blank index e4154ed0..be973f7b 100644 --- a/examples/features/folds.blank +++ b/examples/features/folds.blank @@ -18,19 +18,19 @@ ##lookin ..Shapes -lst: [range begin:'4 end:'10] +lst: [Data..range begin:'4 end:'10] /** ** We can measure the length of a list by folding a function that adds one for each element. **/ -•stdout << `Length: ´ << [lst.foldl (\ p e → '1+p) '0] << "{n} +IO..•stdout << `Length: ´ << [lst.foldl (\ p e → '1+p) '0] << "{n} /** ** This is to show the order in which the state is modified when folding with state from left and right. **/ -[lst.foldsl \ p e •dst → { •dst << e p } void •stdout] -[lst.foldsr \ p e •dst → { •dst << e p } void •stdout] -•stdout << "{n} +[lst.foldsl \ p e •dst → { •dst << e p } void IO..•stdout ] +[lst.foldsr \ p e •dst → { •dst << e p } void IO..•stdout ] +IO..•stdout << "{n} /** ** To show how the laziness of the cons-pair allows us to define infinite streams, we @@ -38,18 +38,18 @@ lst: [range begin:'4 end:'10] ** ** To add two streams is easy. **/ -stream_add: \ s1 s2 → [cons s1.car+s2.car [stream_add s1.cdr s2.cdr]] +stream_add: \ s1 s2 → [Data..cons s1.car+s2.car [stream_add s1.cdr s2.cdr]] /** ** To map infinite streams require some care. Note that the usual map defined in terms ** of a right fold cannot be used on infinite lists. Instead, we must define the operation ** from scratch. **/ -stream_map: \ f lst → [if [null? lst] [list] [cons [f lst.car] [stream_map f lst.cdr]]] +stream_map: \ f lst → [if [Data..null? lst] [Data..list] [Data..cons [f lst.car] [stream_map f lst.cdr]]] /** ** A classic stream example -- the Fibonacci numbers. **/ -Fib: [cons '0 [cons '1 [stream_add Fib Fib.cdr]]] +Fib: [Data..cons '0 [Data..cons '1 [stream_add Fib Fib.cdr]]] /** ** We square each number in the stream. @@ -59,14 +59,14 @@ Fib2: [stream_map (\ x → x*x) Fib] nth: \ lst n → [if n = '0 lst.car [nth lst.cdr n-'1]] -•stdout << `A short sequence of Fibonacci numbers:´ << "{n} +IO..•stdout << `A short sequence of Fibonacci numbers:´ << "{n} -•stdout << [nth Fib '4] << "{n} -•stdout << [nth Fib '5] << "{n} -•stdout << [nth Fib '6] << "{n} +IO..•stdout << [nth Fib '4] << "{n} +IO..•stdout << [nth Fib '5] << "{n} +IO..•stdout << [nth Fib '6] << "{n} -•stdout << `... and the same sequence squared:´ << "{n} +IO..•stdout << `... and the same sequence squared:´ << "{n} -•stdout << [nth Fib2 '4] << "{n} -•stdout << [nth Fib2 '5] << "{n} -•stdout << [nth Fib2 '6] << "{n} +IO..•stdout << [nth Fib2 '4] << "{n} +IO..•stdout << [nth Fib2 '5] << "{n} +IO..•stdout << [nth Fib2 '6] << "{n} diff --git a/examples/features/fontmeterdemo.shape b/examples/features/fontmeterdemo.shape index 1e8a5a98..7c132a82 100644 --- a/examples/features/fontmeterdemo.shape +++ b/examples/features/fontmeterdemo.shape @@ -18,23 +18,23 @@ ##lookin ..Shapes -myFont: @text_font:FONT_HELVETICA & @text_size:2cm +myFont: Text..@font:Text..Font..HELVETICA & Text..@size:2cm bbdraw: \ •dst obj → { - •dst << obj << @stroking:[gray 0.5] & @width:0.3bp | [stroke [bbox obj]] + •dst << obj << @stroking:[gray 0.5] & @width:0.3bp | [Graphics..stroke [Layout..bbox obj]] } -[bbdraw •page [[shift (20cm,0)]()[rotate 5°] myFont | (newText << `ÖöÅåÄäÉé´ )]] +[bbdraw IO..•page [[shift (20cm,0)]()[rotate 5°] myFont | (Text..newText << `ÖöÅåÄäÉé´ )]] -[bbdraw •page [[shift (20cm,~5cm)] myFont | (newText << [kerning `AU´+"{n}+`ÄU´+"{n} [kern `AU´+"{n}+`ÄU´]] )]] +[bbdraw IO..•page [[shift (20cm,~5cm)] myFont | (Text..newText << [kerning `AU´+"{n}+`ÄU´+"{n} [kern `AU´+"{n}+`ÄU´]] )]] -[bbdraw •page [[shift (0,~3cm)]*[rotate ~15°] myFont | (newText << `Hej´ << @text_rise:0.5 | [kerning `mar´] << [kerning `d´ ~0.5 `u bra?´] )]] +[bbdraw IO..•page [[shift (0,~3cm)]*[rotate ~15°] myFont | (Text..newText << `Hej´ << Text..@rise:0.5 | [kerning `mar´] << [kerning `d´ ~0.5 `u bra?´] )]] -[bbdraw •page [[shift (2.5cm,2cm)] myFont | (newText << [shift (6cm,~3cm)]*[rotate 30°] << [kerning `brY´ 0.3 `n´+"{n}+`RadX´] )]] +[bbdraw IO..•page [[shift (2.5cm,2cm)] myFont | (Text..newText << [shift (6cm,~3cm)]*[rotate 30°] << [kerning `brY´ 0.3 `n´+"{n}+`RadX´] )]] -[bbdraw •page [[shift (0,~7cm)]*[rotate ~5°] myFont & @text_leading:1.5 | (newText << `Rad1 e lång´+"{n}+`Rad2´ )]] +[bbdraw IO..•page [[shift (0,~7cm)]*[rotate ~5°] myFont & Text..@leading:1.5 | (Text..newText << `Rad1 e lång´+"{n}+`Rad2´ )]] -[bbdraw •page [[shift (4cm,3cm)] myFont & @text_horizontalscaling:0.8 & @text_characterspacing:10bp & @text_wordspacing:50bp | (newText << [kerning `sparse words´] )]] -[bbdraw •page [[shift (4cm,5cm)] myFont | (newText << [kern `AUTOMATIC (automatic kerning)´] )]] -[bbdraw •page [[shift (4cm,7cm)] myFont | (newText << [kerning `AUTOMATIC (no kerning)´] )]] +[bbdraw IO..•page [[shift (4cm,3cm)] myFont & Text..@horizontalscaling:0.8 & Text..@characterspacing:10bp & Text..@wordspacing:50bp | (Text..newText << [kerning `sparse words´] )]] +[bbdraw IO..•page [[shift (4cm,5cm)] myFont | (Text..newText << [kern `AUTOMATIC (automatic kerning)´] )]] +[bbdraw IO..•page [[shift (4cm,7cm)] myFont | (Text..newText << [kerning `AUTOMATIC (no kerning)´] )]] diff --git a/examples/features/formresources.shape b/examples/features/formresources.shape index 9d45fd3d..c3bafac1 100644 --- a/examples/features/formresources.shape +++ b/examples/features/formresources.shape @@ -20,19 +20,20 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry +##lookin ..Shapes..Graphics..PDF r: 1cm -mask: @blendspace: DEVICE_GRAY | [tgroup @blend:BLEND_MULTIPLY & @nonstroking:[gray 0.5] | ( newGroup << [fill [Geometry..circle 0.3*r]] << [fill [Geometry..circle 0.7*r]] )] +mask: @blendspace: Traits..Device..GRAY | [Graphics..tgroup @blend:Traits..Blend..MULTIPLY & @nonstroking:[gray 0.5] | ( newGroup << [Graphics..fill [Geometry..circle 0.3*r]] << [Graphics..fill [Geometry..circle 0.7*r]] )] -|** •page << [shift (0cm,2*r)] [] mask +|** IO..•page << [shift (0cm,2*r)] [] mask obj: - [clip + [Graphics..clip ( - @blend: BLEND_MULTIPLY + @blend: Traits..Blend..MULTIPLY & - @blendspace: DEVICE_GRAY + @blendspace: Traits..Device..GRAY & @nonstroking:[gray 0.5] | @@ -42,10 +43,10 @@ obj: ) [luminositymask mask]] -•page << obj +IO..•page << obj -•page << obj >> [shift ~(1*4*r,0)] >> formxo +IO..•page << obj >> [shift ~(1*4*r,0)] >> formxo -•page << obj >> [shift ~(1*4*r,0)] >> formxo >> [shift (1*4*r,0)] +IO..•page << obj >> [shift ~(1*4*r,0)] >> formxo >> [shift (1*4*r,0)] -•page << obj >> formxo >> [shift (1*4*r,0)] +IO..•page << obj >> formxo >> [shift (1*4*r,0)] diff --git a/examples/features/glyph-outline.shape b/examples/features/glyph-outline.shape index ccc4a6a5..93ec1083 100644 --- a/examples/features/glyph-outline.shape +++ b/examples/features/glyph-outline.shape @@ -21,18 +21,18 @@ ##lookin ..Shapes..Layout berl: [font `Berlin Sans FB´] -@text_size:5cm +Text..@size:5cm | { c: '"ä glyph: [berl.glyph c] - •page << @text_font:berl | (newText << (newString << c)) - •page << @width:0.1bp & @stroking:RGB_RED | [stroke glyph.paths] - •page << @stroking:RGB_GREEN | [glyph.paths.list.foldl - \ p e -> [if [abs e] > 0.2*@text_size ( p & [stroke e.begin--[e 0.1*@text_size] head:Graphics..ShapesArrow] ) p] + IO..•page << Text..@font:berl | (Text..newText << (String..newString << c)) + IO..•page << @width:0.1bp & @stroking:Traits..RGB..RED | [Graphics..stroke glyph.paths] + IO..•page << @stroking:Traits..RGB..GREEN | [glyph.paths.list.foldl + \ p e -> [if [Numeric..Math..abs e] > 0.2*Text..@size ( p & [Graphics..stroke e.begin--[e 0.1*Text..@size] head:Graphics..ShapesArrow] ) p] null] - •page << @width:0.3bp & @stroking:RGB_RED | [stroke (0cm,0cm)--(+(glyph.advance,0cm)) head:Graphics..ShapesArrow] + IO..•page << @width:0.3bp & @stroking:Traits..RGB..RED | [Graphics..stroke (0cm,0cm)--(+(glyph.advance,0cm)) head:Graphics..ShapesArrow] } -[Layout..enlarge_bleedbox (•page) (2mm,2mm)] +[Layout..enlarge_bleedbox (IO..•page) (2mm,2mm)] diff --git a/examples/features/hulls.shape b/examples/features/hulls.shape index 8a99e3cf..a0946357 100644 --- a/examples/features/hulls.shape +++ b/examples/features/hulls.shape @@ -19,18 +19,18 @@ ##lookin ..Shapes randPath: \ •state n → - [[range '1 n].foldsl + [[Data..range '1 n].foldsl •state - \ •st pile e → pile--( ^ )<(1cm*[random2D •st])>( 2mm * (1+[random1D•st]) ^ 180°*[random1D•st] ) + \ •st pile e → pile--( ^ )<(1cm*[Random..ball2D •st])>( 2mm * (1+[Random..ball1D•st]) ^ 180°*[Random..ball1D•st] ) emptypath] { - •rand: [newRandom (•time)] + •rand: [Random..newRandom (•time)] sh: [shift (0cm,0cm)] pth: sh [] [randPath •rand '10] - •page << [stroke pth] - •page << @stroking:RGB_RED | [stroke controlling [] pth] - hull: [controlling_hull pth] - •page << @width:0.3bp | [stroke hull] + IO..•page << [Graphics..stroke pth] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke controlling [] pth] + hull: [Geometry..controlling_hull pth] + IO..•page << @width:0.3bp | [Graphics..stroke hull] } diff --git a/examples/features/if.blank b/examples/features/if.blank index 6ed26172..a4c5b72e 100644 --- a/examples/features/if.blank +++ b/examples/features/if.blank @@ -18,9 +18,9 @@ ##lookin ..Shapes -•stdout << [if 1 = 0 4+4 4+5 ] << "{n} +IO..•stdout << [if 1 = 0 4+4 4+5 ] << "{n} -•stdout << [if false [error `Not to be evaluated!´] `Fine´] << "{n} +IO..•stdout << [if false [error `Not to be evaluated!´] `Fine´] << "{n} foo: [if false ...] -•stdout << [foo [error `Not to be evaluated!´] `Fine´] << "{n} +IO..•stdout << [foo [error `Not to be evaluated!´] `Fine´] << "{n} diff --git a/examples/features/imports.shape b/examples/features/imports.shape index d3d3ff6c..41700628 100644 --- a/examples/features/imports.shape +++ b/examples/features/imports.shape @@ -19,9 +19,9 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout -pic: [import `multipage.pdf´] [] '0 |** import all pages, and select page 0 +pic: [Graphics..import `multipage.pdf´] [] '0 |** import all pages, and select page 0 { - bb: [bbox pic] - •page << [scale 20cm/([xmax bb] - [xmin bb])] [] pic + bb: [Layout..bbox pic] + IO..•page << [scale 20cm/([xmax bb] - [xmin bb])] [] pic } diff --git a/examples/features/intersections-other.shape b/examples/features/intersections-other.shape index c0d3c934..145715ee 100644 --- a/examples/features/intersections-other.shape +++ b/examples/features/intersections-other.shape @@ -20,38 +20,38 @@ ##lookin ..Shapes..Geometry ##lookin ..Shapes..Graphics -pth1: @defaultunit:1%C | (0cm,0cm)>(^0°)--(^)<(1cm,1cm)>(^0°)--(^)<(2cm,~1cm)>(^0°)--(^180°)<(3cm,0cm) +pth1: Geometry..@defaultunit:1%C | (0cm,0cm)>(^0°)--(^)<(1cm,1cm)>(^0°)--(^)<(2cm,~1cm)>(^0°)--(^180°)<(3cm,0cm) line: (~1cm,1cm)--(0cm,1cm)--(1cm,~1cm) -sl1Mark: @width:2bp & @stroking:RGB_RED | [stroke [Geometry..circle 2mm]] -sl2Mark: @width:0.7bp & @stroking:RGB_BLUE | [stroke [Geometry..circle 2mm]] -sla1Mark: @width:2bp & @stroking:RGB_RED | [stroke [Geometry..circle 3mm]] -sla2Mark: @width:0.7bp & @stroking:RGB_BLUE | [stroke [Geometry..circle 3mm]] +sl1Mark: @width:2bp & @stroking:Traits..RGB..RED | [Graphics..stroke [Geometry..circle 2mm]] +sl2Mark: @width:0.7bp & @stroking:Traits..RGB..BLUE | [Graphics..stroke [Geometry..circle 2mm]] +sla1Mark: @width:2bp & @stroking:Traits..RGB..RED | [Graphics..stroke [Geometry..circle 3mm]] +sla2Mark: @width:0.7bp & @stroking:Traits..RGB..BLUE | [Graphics..stroke [Geometry..circle 3mm]] fixedHead: [Graphics..ShapesArrow width:3bp ...] helper: \ pth1 pth2 → { - sl: [intersection pth1 pth2] - sla: [approximator pth1 pth2] + sl: [Geometry..intersection pth1 pth2] + sla: [Geometry..approximator pth1 pth2] ( newGroup - << [stroke pth1 head:fixedHead] - << @width:0.3bp | [stroke pth2 head:fixedHead] + << [Graphics..stroke pth1 head:fixedHead] + << @width:0.3bp | [Graphics..stroke pth2 head:fixedHead] << sl1Mark >> [shift sl.p] << sl2Mark >> [shift sl.info.other.p] << sla1Mark >> [shift sla.p] << sla2Mark >> [shift sla.info.other.p] - << ( newText << ( newString << [abs sl.p - sl.info.other.p] ) ) >> [shift (0,~15mm)] - << ( newText << ( newString << [abs sla.p - sla.info.other.p] ) ) >> [shift (0,~20mm)] + << ( Text..newText << ( String..newString << [Numeric..Math..abs sl.p - sl.info.other.p] ) ) >> [shift (0,~15mm)] + << ( Text..newText << ( String..newString << [Numeric..Math..abs sla.p - sla.info.other.p] ) ) >> [shift (0,~20mm)] ) } ##unit d = 5cm helper2: \ pth1 pth2 → ( [helper pth1 pth2] & [[shift (1d,0)] [helper pth2 pth1]] ) -helper8: \ pth1 pth2 → ( [helper2 pth1 pth2] & [[shift (0,~1d)] [helper2 pth1 [reverse pth2]]] & [[shift (0,~2d)] [helper2 [reverse pth1] pth2]] & [[shift (0,~3d)] [helper2 [reverse pth1] [reverse pth2]]] ) +helper8: \ pth1 pth2 → ( [helper2 pth1 pth2] & [[shift (0,~1d)] [helper2 pth1 [Geometry..reverse pth2]]] & [[shift (0,~2d)] [helper2 [Geometry..reverse pth1] pth2]] & [[shift (0,~3d)] [helper2 [Geometry..reverse pth1] [Geometry..reverse pth2]]] ) -•page << [helper8 pth1 line] >> [shift (0d,0cm)] +IO..•page << [helper8 pth1 line] >> [shift (0d,0cm)] << [helper8 [shift (5mm,0)]*[scale x:~1][]line line] >> [shift (2d,0cm)] << [helper8 [shift (~5mm,0)]*[scale x:~1][]line line] >> [shift (4d,0cm)] << [helper8 pth1 [shift (0.5cm,~1cm)]*[rotate 60°][]pth1] >> [shift (6d,0cm)] diff --git a/examples/features/intersections.shape b/examples/features/intersections.shape index 954ac0b9..f318a797 100644 --- a/examples/features/intersections.shape +++ b/examples/features/intersections.shape @@ -21,9 +21,9 @@ ##lookin ..Shapes..Graphics intersectionCircle: \ pth1 pth2 → - ( @stroking:RGB_RED | [stroke [shift [intersection pth1 pth2].p] [] [Geometry..circle 2mm]] ) + ( @stroking:Traits..RGB..RED | [Graphics..stroke [shift [intersection pth1 pth2].p] [] [circle 2mm]] ) -•page << [shift (0cm,4cm)] [] [TeX `\parbox{4cm}{Lines start at black circles, and at their first intersection there's a red circle.}´] +IO..•page << [shift (0cm,4cm)] [] [Graphics..TeX `\parbox{4cm}{Lines start at black circles, and at their first intersection there's a red circle.}´] |** pth1straight: (0cm,0cm)--(3cm,4cm) |** |** pth1curved: (0cm,0cm)>(1%c^0°)--(3cm,4cm) @@ -33,25 +33,25 @@ intersectionCircle: \ pth1 pth2 → |** |** pth2curved: (1cm,~2cm)>(1%c^0°)--(2cm,5cm) |** pth2curved: (3cm,0cm)>(2cm,0cm)--(0cm,4cm) -|** •page << [stroke pth1straight] -|** •page << [stroke pth1curved] -|** •page << [stroke pth2straight] -|** •page << [stroke pth2curved] +|** IO..•page << [Graphics..stroke pth1straight] +|** IO..•page << [Graphics..stroke pth1curved] +|** IO..•page << [Graphics..stroke pth2straight] +|** IO..•page << [Graphics..stroke pth2curved] -|** •page << [intersectionCircle pth1straight pth2straight] -|** •page << [intersectionCircle pth1straight pth2curved] -|** •stdout << `t: ´ << [intersection pth1curved pth2straight].time << "{n} -|** •page << [intersectionCircle pth1curved pth2straight] -|** •page << [intersectionCircle pth1curved pth2curved] +|** IO..•page << [intersectionCircle pth1straight pth2straight] +|** IO..•page << [intersectionCircle pth1straight pth2curved] +|** IO..•stdout << `t: ´ << [intersection pth1curved pth2straight].time << "{n} +|** IO..•page << [intersectionCircle pth1curved pth2straight] +|** IO..•page << [intersectionCircle pth1curved pth2curved] |** pth3faraway: (5cm,5cm)>(5cm,6cm)--(7cm,7cm) -|** •page << [stroke pth3faraway] +|** IO..•page << [Graphics..stroke pth3faraway] |** /** This will break the program by means of the default @handler_NoIntersection: **/ -|** |** •page << [intersectionCircle pth1curved pth3faraway] +|** |** IO..•page << [intersectionCircle pth1curved pth3faraway] |** /** This will draw nothing, since the handler returns NULL to the insertion continuation. **/ -|** •page << (continuation cont +|** IO..•page << (continuation cont |** @handler_NoIntersection: \ pth1 pth2 → (continue cont NULL) |** | |** [intersectionCircle pth1curved pth3faraway] @@ -59,38 +59,38 @@ intersectionCircle: \ pth1 pth2 → randPath: \ n •state → [scale 5] [] - [[range '1 n].foldsl - \ pile e •st → pile--( ^ )<(1cm*[random2D •st])>( 2mm * (1+[random1D •st]) ^ 180°*[random1D •st] ) - emptypath •state] + [[Data..range '1 n].foldsl + \ pile e •st → pile--( ^ )<(1cm*[Random..ball2D •st])>( 2mm * (1+[Random..ball1D •st]) ^ 180°*[Random..ball1D •st] ) + Geometry..emptypath •state] { - •rand: [newRandom (•time)] + •rand: [Random..newRandom (•time)] sh: [shift (5cm,0cm)] pth: sh [] [randPath '10 •rand] - •page << @stroking:RGB_RED | [stroke pth head: ShapesArrow] -|** •page << @stroking:[gray 0.7] | [stroke controlling [] pth] + IO..•page << @stroking:Traits..RGB..RED | [Graphics..stroke pth head: ShapesArrow] +|** IO..•page << @stroking:[gray 0.7] | [Graphics..stroke controlling [] pth] - •page << + IO..•page << ( @width: 0.2bp | - [[range '1 '10].foldsl + [[Data..range '1 '10].foldsl \ pile e •st → { pth2: sh [] [randPath '4 •st] pile - & [stroke pth2 tail: \ p → (> picture:[stroke [shift p.begin.p][][Geometry..circle 3mm]] cut:0mm <)] -|** & ( @stroking:[gray 0.7] | [stroke controlling [] pth2] ) + & [Graphics..stroke pth2 tail: \ p → (> picture:[Graphics..stroke [shift p.begin.p][][circle 3mm]] cut:0mm <)] +|** & ( @stroking:[gray 0.7] | [Graphics..stroke controlling [] pth2] ) & (escape_continuation cont - @handler_NoIntersection: ( \ pth1 pth2 → (escape_continue cont [stroke [shift pth1.begin.p][][Geometry..circle 4mm]]) ) + @handler_NoIntersection: ( \ pth1 pth2 → (escape_continue cont [Graphics..stroke [shift pth1.begin.p][][circle 4mm]]) ) | [intersectionCircle pth2 pth] ) - >> [debuglog_after ( newString << `pth: ´ << [pth 2].p << `>(´ << [pth 2].v << `^´ << [angle [pth 2].T]/1° << `°)´ << "{n} ) ...] - >> [debuglog_after ( newString << `pth: ´ << [pth 3].p << `>(´ << [pth 3].rv << `^´ << [angle [pth 3].rT]/1° << `°)´ << "{n} ) ...] - >> [debuglog_after ( newString << `pth2: ´ << [pth2 0].p << `>(´ << [pth2 0].v << `^´ << [angle [pth2 0].T]/1° << `°)´ << "{n} ) ...] - >> [debuglog_after ( newString << `pth2: ´ << [pth2 1].p << `>(´ << [pth2 1].rv << `^´ << [angle [pth2 1].rT]/1° << `°)´ << "{n} ) ...] + >> [Debug..log_after ( String..newString << `pth: ´ << [pth 2].p << `>(´ << [pth 2].v << `^´ << [angle [pth 2].T]/1° << `°)´ << "{n} ) ...] + >> [Debug..log_after ( String..newString << `pth: ´ << [pth 3].p << `>(´ << [pth 3].rv << `^´ << [angle [pth 3].rT]/1° << `°)´ << "{n} ) ...] + >> [Debug..log_after ( String..newString << `pth2: ´ << [pth2 0].p << `>(´ << [pth2 0].v << `^´ << [angle [pth2 0].T]/1° << `°)´ << "{n} ) ...] + >> [Debug..log_after ( String..newString << `pth2: ´ << [pth2 1].p << `>(´ << [pth2 1].rv << `^´ << [angle [pth2 1].rT]/1° << `°)´ << "{n} ) ...] } null •rand diff --git a/examples/features/latin1.shape b/examples/features/latin1.shape index 9b1a93bb..0f843729 100644 --- a/examples/features/latin1.shape +++ b/examples/features/latin1.shape @@ -18,4 +18,4 @@ ##lookin ..Shapes -•page << [TeX `\parbox{8cm}{Gauß was a mathematician.\\ Åström is in automatic control.}´] +IO..•page << [Graphics..TeX `\parbox{8cm}{Gauß was a mathematician.\\ Åström is in automatic control.}´] diff --git a/examples/features/lightdemo.shape b/examples/features/lightdemo.shape index bbb5d54f..49afe170 100644 --- a/examples/features/lightdemo.shape +++ b/examples/features/lightdemo.shape @@ -18,8 +18,9 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout +##lookin ..Shapes..Geometry3D -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf r: 10cm ##unit w = 3.4cm @@ -30,12 +31,12 @@ obj: & @autoscattering:[phong 0.2] & @facetresolution:2cm | - [facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle] + [Graphics3D..facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle] -[[range 20° 360° 20°].foldsl +[[Data..range 20° 360° 20°].foldsl \ p e •st → !{ - •st << [rotate3D (0,1,0) ~e] [] obj + •st << [Geometry3D..rotate (0,1,0) ~e] [] obj p } void @@ -47,7 +48,7 @@ obj: zbuf: •zbuf; -tmp: [bboxed_enlarge [view [rotate3D (1,0,0) 20°]*[rotate3D (0,1,0) 1°] [] zbuf] (5mm,5mm)] +tmp: [bboxed_enlarge [view [Geometry3D..rotate (1,0,0) 20°]*[Geometry3D..rotate (0,1,0) 1°] [] zbuf] (5mm,5mm)] -•page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]] -•page << tmp +IO..•page << @nonstroking:Traits..BW..BLACK | [Graphics..fill [Layout..bbox tmp]] +IO..•page << tmp diff --git a/examples/features/lightdemo2.shape b/examples/features/lightdemo2.shape index a23bc146..b55e9507 100644 --- a/examples/features/lightdemo2.shape +++ b/examples/features/lightdemo2.shape @@ -18,8 +18,9 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout +##lookin ..Shapes..Geometry3D -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf r: 10cm ##unit w = 3.4cm @@ -31,14 +32,14 @@ obj: & @shadeorder:'0 & @facetresolution:1cm | - [facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle - [facetnormal (r,0cm,~1cm) [normalized (r,0cm,~1cm)]] - [facetnormal (r,0cm,1cm) [normalized (r,0cm,1cm)]]] + [Graphics3D..facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle + [Graphics3D..facetnormal (r,0cm,~1cm) [normalized (r,0cm,~1cm)]] + [Graphics3D..facetnormal (r,0cm,1cm) [normalized (r,0cm,1cm)]]] -[[range 20° 360° 20°].foldsl +[[Data..range 20° 360° 20°].foldsl \ p e •st → !{ - •st << [rotate3D (0,1,0) ~e] [] obj + •st << [Geometry3D..rotate (0,1,0) ~e] [] obj p } void @@ -49,7 +50,7 @@ obj: zbuf: •zbuf; -tmp: [bboxed_enlarge [view [rotate3D (0,1,0) 15°] [] zbuf] (5mm,5mm)] +tmp: [bboxed_enlarge [view [Geometry3D..rotate (0,1,0) 15°] [] zbuf] (5mm,5mm)] -•page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]] -•page << tmp +IO..•page << @nonstroking:Traits..BW..BLACK | [Graphics..fill [Layout..bbox tmp]] +IO..•page << tmp diff --git a/examples/features/lightdemo3.shape b/examples/features/lightdemo3.shape index e9837c9a..9075f500 100644 --- a/examples/features/lightdemo3.shape +++ b/examples/features/lightdemo3.shape @@ -18,8 +18,9 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout +##lookin ..Shapes..Geometry3D -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf r: 10cm ##unit w = 3.4cm @@ -31,15 +32,15 @@ obj: & @shadeorder:'2 & @facetresolution:1cm | - [facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle - [facetnormal (r,0cm,~1cm) [normalized (r,0cm,~1cm)]] - [facetnormal (r,0cm,1cm) [normalized (r,0cm,1cm)]] - [facetnormal (r,5cm,0cm) [normalized (r,5cm,0cm)]]] + [Graphics3D..facet (r,~5cm,~0.5w)--(r,5cm,~0.5w)--(r,5cm,0.5w)--(r,~5cm,0.5w)--cycle + [Graphics3D..facetnormal (r,0cm,~1cm) [normalized (r,0cm,~1cm)]] + [Graphics3D..facetnormal (r,0cm,1cm) [normalized (r,0cm,1cm)]] + [Graphics3D..facetnormal (r,5cm,0cm) [normalized (r,5cm,0cm)]]] -[[range 20° 160° 20°].foldsl +[[Data..range 20° 160° 20°].foldsl \ p e •st → !{ - •st << [rotate3D (0,1,0) ~e] [] obj + •st << [Geometry3D..rotate (0,1,0) ~e] [] obj p } void @@ -51,5 +52,5 @@ zbuf: •zbuf; tmp: [bboxed_enlarge [view zbuf] (5mm,5mm)] -•page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]] -•page << tmp +IO..•page << @nonstroking:Traits..BW..BLACK | [Graphics..fill [Layout..bbox tmp]] +IO..•page << tmp diff --git a/examples/features/lightdemo3b.shape b/examples/features/lightdemo3b.shape index 8049e903..0c087c5f 100644 --- a/examples/features/lightdemo3b.shape +++ b/examples/features/lightdemo3b.shape @@ -18,8 +18,9 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout +##lookin ..Shapes..Geometry3D -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf interp: ( newColorInterpolator << 0.0 << [rgb 0.8 0 0] @@ -38,7 +39,7 @@ interp: ( newColorInterpolator yMin: ~5cm yMax: 5cm -makeNormal: \ p → ( @nonstroking:[interp (p.y-yMin)/(yMax-yMin)] | [debuglog_before [sprintf `%g´+"{n} (p.y-yMin)/(yMax-yMin)] [facetnormal p [normalized (p.x,p.y,0bp)]]] ) +makeNormal: \ p → ( @nonstroking:[interp (p.y-yMin)/(yMax-yMin)] | [Debug..log_before [String..sprintf `%g´+"{n} (p.y-yMin)/(yMax-yMin)] [Graphics3D..facetnormal p [normalized (p.x,p.y,0bp)]]] ) r: 6cm ##unit w = 1cm @@ -50,22 +51,22 @@ obj: & @shadeorder:'2 & @facetresolution:1cm | - [[range 0 0.9999-delta delta].foldl + [[Data..range 0 0.9999-delta delta].foldl \ p e → { y1: yMin + e * ( yMax - yMin ) y2: yMin + ( e + delta ) * ( yMax - yMin ) p & - [facet (r,y1,~0.5w)--(r,y2,~0.5w)--(r,y2,0.5w)--(r,y1,0.5w)--cycle + [Graphics3D..facet (r,y1,~0.5w)--(r,y2,~0.5w)--(r,y2,0.5w)--(r,y1,0.5w)--cycle [makeNormal (r,y1,~1cm)] [makeNormal (r,y1,1cm)] [makeNormal (r,y2,0cm)]] } - null3D] + Graphics3D..null] -[[range 10° 170° 10°].foldsl +[[Data..range 10° 170° 10°].foldsl \ p e •st → !{ - •st << [rotate3D (0,1,0) ~e] [] obj + •st << [Geometry3D..rotate (0,1,0) ~e] [] obj p } void @@ -77,5 +78,5 @@ zbuf: •zbuf; tmp: [bboxed_enlarge [view zbuf] (5mm,5mm)] -•page << @nonstroking:GRAY_BLACK | [fill [bbox tmp]] -•page << tmp +IO..•page << @nonstroking:Traits..BW..BLACK | [Graphics..fill [Layout..bbox tmp]] +IO..•page << tmp diff --git a/examples/features/multipage.shape b/examples/features/multipage.shape index ae2ff08c..0d68bbb5 100644 --- a/examples/features/multipage.shape +++ b/examples/features/multipage.shape @@ -18,6 +18,7 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry +##lookin ..Shapes..Graphics..PDF clock: \ hour minute → { @@ -27,16 +28,16 @@ clock: \ hour minute → hourAngle: 90° - (hour/12)*360° minuteAngle: 90° - (minute/60)*360° - [stroke (0cm,0cm)--(hourLength*[dir hourAngle])] + [Graphics..stroke (0cm,0cm)--(hourLength*[dir hourAngle])] & - [stroke (0cm,0cm)--(minuteLength*[dir minuteAngle])] + [Graphics..stroke (0cm,0cm)--(minuteLength*[dir minuteAngle])] } -•catalog.[setpagelabel prefix:`Am ´ number:'8] -•catalog.[setbboxgroup 'clock] -•stdout << `First page's label: ´ << •catalog.[nextpagelabel] << "{n} +IO..•catalog.[setpagelabel prefix:`Am ´ number:'8] +IO..•catalog.[setbboxgroup 'clock] +IO..•stdout << `First page's label: ´ << IO..•catalog.[nextpagelabel] << "{n} -•catalog << [clock 8 0] +IO..•catalog << [clock 8 0] & [destination level:'0 text:`Morning´ color:[rgb 0.5 0.5 0] open:true] & [destination level:'1 text:`Eight´] & { @@ -51,19 +52,19 @@ clock: \ hour minute → << [clock 9 0] & [destination level:'1 text:`Nine´] -•catalog.[setpagelabel number:•catalog.[nextpagenumber]+'1] -•stdout << `Skipping to page: ´ << •catalog.[nextpagenumber] << "{n} +IO..•catalog.[setpagelabel number:IO..•catalog.[nextpagenumber]+'1] +IO..•stdout << `Skipping to page: ´ << IO..•catalog.[nextpagenumber] << "{n} -•catalog << [clock •catalog.[nextpagenumber]*1 0] +IO..•catalog << [clock IO..•catalog.[nextpagenumber]*1 0] /** Note how the various part of the page label may be set independently of each other. **/ -•catalog.[setpagelabel prefix:`Pm ´] -•catalog.[setpagelabel number:'33] -•catalog.[setpagelabel style:'alphabet] -•stdout << `Later page's label: ´ << •catalog.[nextpagelabel] << "{n} +IO..•catalog.[setpagelabel prefix:`Pm ´] +IO..•catalog.[setpagelabel number:'33] +IO..•catalog.[setpagelabel style:'alphabet] +IO..•stdout << `Later page's label: ´ << IO..•catalog.[nextpagelabel] << "{n} -•catalog << [clock 3 10] +IO..•catalog << [clock 3 10] & [destination level:'0 text:`Afternoon´ italic:true] << [clock 4 10] & [destination name:`four in the afternoon´] diff --git a/examples/features/myfontdemo.shape b/examples/features/myfontdemo.shape index 5087a84f..f3c675e9 100644 --- a/examples/features/myfontdemo.shape +++ b/examples/features/myfontdemo.shape @@ -24,26 +24,26 @@ •myfont: newFont -•myfont << [tag 'FontName 'Honko] << [tag 'FullName `Honko Ponko´] -•myfont << [tag 'ItalicAngle ~10°] -•myfont << [tag 'size 1cm] -•myfont << [basicglyph char:'"a width:1.1cm glyph:[stroke (0cm,0cm)--(1cm,1cm)]] -•myfont << [basicglyph char:'"b width:1.1cm glyph:[stroke (0cm,1cm)--(1cm,0cm)]] -•myfont << [basicglyph char:'"å width:0.1cm glyph:(@width:1mm | [stroke (0cm,~0.1cm)--(0cm,1.1cm)])] +•myfont << [Graphics..Tag..tag 'FontName 'Honko] << [Graphics..Tag..tag 'FullName `Honko Ponko´] +•myfont << [Graphics..Tag..tag 'ItalicAngle ~10°] +•myfont << [Graphics..Tag..tag 'size 1cm] +•myfont << [basicglyph char:'"a width:1.1cm glyph:[Graphics..stroke (0cm,0cm)--(1cm,1cm)]] +•myfont << [basicglyph char:'"b width:1.1cm glyph:[Graphics..stroke (0cm,1cm)--(1cm,0cm)]] +•myfont << [basicglyph char:'"å width:0.1cm glyph:(@width:1mm | [Graphics..stroke (0cm,~0.1cm)--(0cm,1.1cm)])] |** This glyph is not given a character code, only a name. It will not be measurable... -•myfont << [basicglyph name:'foobar width:0.2cm glyph:(@width:1mm | [stroke (0cm,~0.1cm)--(0cm,1.1cm)])] +•myfont << [basicglyph name:'foobar width:0.2cm glyph:(@width:1mm | [Graphics..stroke (0cm,~0.1cm)--(0cm,1.1cm)])] |** This glyph gets its name from a character: -•myfont << [basicglyph name:`ä´ width:0.3cm glyph:(@width:1mm | [stroke (0cm,~0.1cm)--(0cm,1.1cm)])] +•myfont << [basicglyph name:`ä´ width:0.3cm glyph:(@width:1mm | [Graphics..stroke (0cm,~0.1cm)--(0cm,1.1cm)])] myfont: •myfont; -•page << @text_font:myfont | ( newText << [kerning `aåa´ 1 `b´] ) +IO..•page << Text..@font:myfont | ( Text..newText << [kerning `aåa´ 1 `b´] ) /** What follows is not implemented yet: **/ |** yourfont: [importfont `yourfont.pdf´] |** -|** •page << [shift (0,1cm)] [] ( @text_font:yourfont | ( newText << `abaabb´ ) ) +|** IO..•page << [shift (0,1cm)] [] ( Text..@font:yourfont | ( Text..newText << `abaabb´ ) ) diff --git a/examples/features/namespaces.blank b/examples/features/namespaces.blank index cdfc977b..fee8565b 100644 --- a/examples/features/namespaces.blank +++ b/examples/features/namespaces.blank @@ -68,18 +68,18 @@ ##lookin ..Shapes a: 0 /** Place a in global namespace **/ -•stdout << a << "{n} /** Refer to a using relative identifier (as if there were no namespaces). **/ -•stdout << ..a << "{n} /** The global namespace is indicated by a double dot, and this called an absolute identifier. **/ +IO..•stdout << a << "{n} /** Refer to a using relative identifier (as if there were no namespaces). **/ +IO..•stdout << ..a << "{n} /** The global namespace is indicated by a double dot, and this called an absolute identifier. **/ /** A namespace must be opened and closed within the same code bracket. **/ ##push MyExtension /** Any identifier may serve as namespace name **/ a: 1 /** Place a in MyExtension. **/ -•stdout << a << "{n} /** Refer to a as usual when inside MyExtension. **/ +IO..•stdout << a << "{n} /** Refer to a as usual when inside MyExtension. **/ ##pop MyExtension -•stdout << MyExtension..a << "{n} /** Reference to a from outside MyExtension. **/ +IO..•stdout << MyExtension..a << "{n} /** Reference to a from outside MyExtension. **/ /** A namespace can be opened several times. **/ @@ -88,12 +88,12 @@ a: 1 /** Place a in MyExtension. **/ { /** The namespace doesn't change when opening a code bracket. **/ /** Still in MyExtension **/ b: 2 /** Place b in MyExtension. **/ - •stdout << b << "{n} + IO..•stdout << b << "{n} /** It would be an error to be in a different namespace than MyExtension upon leaving the code bracket. **/ } /** b is not in lexical scope here. **/ -|** •stdout << b << "{n} +|** IO..•stdout << b << "{n} /** Open a new namespace inside MyExtension. **/ ##push Restricted @@ -101,23 +101,23 @@ a: 1 /** Place a in MyExtension. **/ c: 3 /** Place c in MyExtension..Restricted. **/ /** Since a is not found in the current namespace, it is searched recursively in the surrounding namespaces, and found in MyExtension. **/ -•stdout << a + c << "{n} +IO..•stdout << a + c << "{n} ##pop Restricted ##push Internal /** Since Restricted..c is not found in the current namespace, it is searched recursively in the surrounding namespaces, and found in MyExtension. - ** That is, we find MyExtension..Restricted..c. + ** That is, we Graphics..Tag..find MyExtension..Restricted..c. **/ -•stdout << Restricted..c << "{n} +IO..•stdout << Restricted..c << "{n} a: 5 /** Place another a in MyExtension..Internal. **/ -•stdout << a << "{n} /** Refer to MyExtension..Internal..a. **/ -•stdout << ..MyExtension..a << "{n} /** Reference relative to global namespace (this is called using the absolute identifier). **/ +IO..•stdout << a << "{n} /** Refer to MyExtension..Internal..a. **/ +IO..•stdout << ..MyExtension..a << "{n} /** Reference relative to global namespace (this is called using the absolute identifier). **/ /** Source code reflection. **/ -•stdout << (resolved_identifier_string Restricted..c) << "{n} /** Will print ..MyExtension..Restricted..a. **/ +IO..•stdout << (resolved_identifier_string Restricted..c) << "{n} /** Will print ..MyExtension..Restricted..a. **/ f: 7 /** This binding is exposed using an alias in MyExtension. **/ @@ -134,7 +134,7 @@ e: 4 /** Place e in MyExtension..-. **/ ##push - /** There is just one private namespace inside each named namespace, so this works: **/ -•stdout << e << "{n} /** Refer to MyExtension..-..e (also known as -..e). **/ +IO..•stdout << e << "{n} /** Refer to MyExtension..-..e (also known as -..e). **/ ##pop - @@ -172,7 +172,7 @@ foo: 1 ** things in the new namespace... (What a waste!) **/ -•stdout << `foo in ExtA: ´ << ExtA..foo << `, also available as: ´ << ImportA..MyPackage..foo << "{n} +IO..•stdout << `foo in ExtA: ´ << ExtA..foo << `, also available as: ´ << ImportA..MyPackage..foo << "{n} /** Identifiers are searched along two axes, and one has to be given priority. @@ -184,12 +184,12 @@ x: 2 /** Here is ..A..x **/ { x: 3 /** Here is another ..x **/ ##push A - •stdout << `Resolving ..x is easy: ´ << ..x << ` (expexed 3)´ << "{n} - •stdout << `Resolving A..x is easy: ´ << A..x << ` (expexed 2)´ << "{n} + IO..•stdout << `Resolving ..x is easy: ´ << ..x << ` (expexed 3)´ << "{n} + IO..•stdout << `Resolving A..x is easy: ´ << A..x << ` (expexed 2)´ << "{n} /** There is no ..A..x in the current bracket, so resolving x here forces us to search both ** surrounding brackets and enclosing namespaces. **/ - •stdout << `Resolving x is less obvious: ´ << x << ` (expected what?)´ << "{n} + IO..•stdout << `Resolving x is less obvious: ´ << x << ` (expected what?)´ << "{n} ##pop A } /** To understand how to resolve the last case above, consider how the situation could arise when working @@ -216,7 +216,7 @@ x: 2 /** Here is ..A..x **/ |** ** variables. |** ** To complete the story, it would be good to come up with an example where it actually makes more sense |** ** to give code bracket priority over namespace. In the example above, giving the code bracket priority -|** ** means that we find the x that is lexically closer (fewer characters away in the source). +|** ** means that we Graphics..Tag..find the x that is lexically closer (fewer characters away in the source). |** ** Note that the roles of namespace and code bracket in the example cannot be switched, because a namespace |** ** can be opened in more than one location, but a closed code bracket can never be opened again in a |** ** different location. diff --git a/examples/features/needs.blank b/examples/features/needs.blank index d75a2aee..c3074966 100644 --- a/examples/features/needs.blank +++ b/examples/features/needs.blank @@ -94,7 +94,7 @@ ** ** For example, the Shapes project is the namespace authority responsible for ..Shapes, with a list or reserved namespaces published at ** lang-shapes.sourceforge.net/doc/namespace-Shapes.html. - ** There, one will find namsepaces such as + ** There, one will Graphics..Tag..find namsepaces such as ** ..Shapes..Core ** ..Shapes..2D ** ..Shapes..3D diff --git a/examples/features/opacity.shape b/examples/features/opacity.shape index 8308b050..33d565c6 100644 --- a/examples/features/opacity.shape +++ b/examples/features/opacity.shape @@ -19,6 +19,6 @@ ##lookin ..Shapes ##lookin ..Shapes..Geometry -•page << @nonstroking:RGB_RED | [fill [Geometry..circle 2cm]] -•page << @nonstroking:RGB_BLACK & @nonstrokingalpha:[alphaopacity 0.3] | [fill [shift (2cm,0)] [] [Geometry..circle 2cm]] -•page << @nonstroking:RGB_WHITE & @nonstrokingalpha:[alphashape 0.3] | [fill [shift (0,~2cm)] [] [Geometry..circle 2cm]] +IO..•page << @nonstroking:Traits..RGB..RED | [Graphics..fill [Geometry..circle 2cm]] +IO..•page << @nonstroking:Traits..RGB..BLACK & @nonstrokingalpha:[alphaopacity 0.3] | [Graphics..fill [shift (2cm,0)] [] [Geometry..circle 2cm]] +IO..•page << @nonstroking:Traits..RGB..WHITE & @nonstrokingalpha:[alphashape 0.3] | [Graphics..fill [shift (0,~2cm)] [] [Geometry..circle 2cm]] diff --git a/examples/features/orthogonal.blank b/examples/features/orthogonal.blank index 6b12105c..ad70dc7e 100644 --- a/examples/features/orthogonal.blank +++ b/examples/features/orthogonal.blank @@ -17,28 +17,29 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry { v: (1,0.1,~0.1) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } { v: (0.1,1,0.1) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } { v: (~0.1,~0.1,1) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } { v: (1,0,~0) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } { v: (0,1,0) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } { v: (~0,~0,1) - •stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} + IO..•stdout << `Orthogonal vectors in 3D: ´ << v << `, ´ << [orthogonal v] << "{n} } diff --git a/examples/features/paint3d.shape b/examples/features/paint3d.shape index c81643f8..02a0bdda 100644 --- a/examples/features/paint3d.shape +++ b/examples/features/paint3d.shape @@ -17,10 +17,11 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -tf: [scale3D x:1.3] +tf: [Geometry3D..scale x:1.3] -rot: [rotate3D (1,1,1) 30°] +rot: [Geometry3D..rotate (1,1,1) 30°] pth: (~1cm,~1cm,~1cm)--(~1cm,1cm,~1cm)--(1cm,1cm,~1cm)--(1cm,~1cm,~1cm)--(1cm,~1cm,1cm)--(1cm,1cm,1cm)--(~1cm,1cm,1cm)--(~1cm,~1cm,1cm) @@ -31,4 +32,4 @@ deeper: \ n → [shift (0cm,0cm,n*~2cm)] screw: (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle screw2: [rot screw] -•page << @eyez:5cm|[view [stroke pth]] +IO..•page << @eyez:5cm|[view [Graphics..stroke pth]] diff --git a/examples/features/pathconstruction.shape b/examples/features/pathconstruction.shape index 137f6464..fb38f356 100644 --- a/examples/features/pathconstruction.shape +++ b/examples/features/pathconstruction.shape @@ -30,12 +30,12 @@ r: 4mm |** This is a corner radius ** ** Then stroke the path joined with its reverse mirrored in the y-axis. **/ -pth: @defaultunit:1%c | (0,h)--(w-r,(+0m))>(^)--(^)<(+(r,~r))--((+0m),~h+r)>(^)--(^0°)<(0,~h) +pth: Geometry..@defaultunit:1%c | (0,h)--(w-r,(+0m))>(^)--(^)<(+(r,~r))--((+0m),~h+r)>(^)--(^0°)<(0,~h) -•page << [stroke pth--[[scale x:~1] [reverse pth]]] +IO..•page << [Graphics..stroke pth--[[scale x:~1] [Geometry..reverse pth]]] /** ** Allow for some space around the path we want to see! **/ -•page << [stroke [rectangle (~1.5*w,~1.5*h) (1.5*w,1.5*h)]] +IO..•page << [Graphics..stroke [Geometry..rectangle (~1.5*w,~1.5*h) (1.5*w,1.5*h)]] diff --git a/examples/features/png_array.shape b/examples/features/png_array.shape index 0d4713db..5f029468 100644 --- a/examples/features/png_array.shape +++ b/examples/features/png_array.shape @@ -41,69 +41,69 @@ dy: 5cm checkers: { side: 0.1*dx - square: @nonstroking:[gray 0.9] | [fill [rectangle (0m,0m) (side,side)]] - ( @nonstroking:[gray 0.7] | [fill [rectangle (0m,0m) (dx,dy)]] ) + square: @nonstroking:[gray 0.9] | [Graphics..fill [Geometry..rectangle (0m,0m) (side,side)]] + ( @nonstroking:[gray 0.7] | [Graphics..fill [Geometry..rectangle (0m,0m) (dx,dy)]] ) & - [[range 0m dx-0.5*side side].foldl - \ p x → [[range [if [mod x+0.5*side 2*side] < side 0m side] dx-0.5*side 2*side].foldl + [[Data..range 0m dx-0.5*side side].foldl + \ p x → [[Data..range [if [Numeric..Math..mod x+0.5*side 2*side] < side 0m side] dx-0.5*side 2*side].foldl \ p y → ( p & ( square >> [shift (x,y)] ) ) p] null] } >> center >> [scale 0.7] -colorStrs: [vector `-bw´ `´] -depthStrs: [vector '1 '2 '4 '8 '16] +colorStrs: [Data..vector `-bw´ `´] +depthStrs: [Data..vector '1 '2 '4 '8 '16] helper: \ img → { [Layout..center checkers & [Layout..center img] (0,~1)] - & [Layout..center ( newText << ( newString << img.space << ` ´ << img.depth ) ) (0,1)] + & [Layout..center ( Text..newText << ( String..newString << img.space << ` ´ << img.depth ) ) (0,1)] } -|** •page << -|** [[range '0 colorStrs.size-'1].foldl +|** IO..•page << +|** [[Data..range '0 colorStrs.size-'1].foldl |** \ p i → -|** ( p & [[shift (0,~i*dy)] [[range '0 depthStrs.size-'1].foldl +|** ( p & [[shift (0,~i*dy)] [[Data..range '0 depthStrs.size-'1].foldl |** \ p j → ( p -|** & [[shift (j*dx,0)] [helper [import_raster (newString << `logo´ << [colorStrs i] << [sprintf `-%d´ [depthStrs j]] << `.png´ ) resolution:0.2bp]]] ) +|** & [[shift (j*dx,0)] [helper [Graphics..import_raster (String..newString << `logo´ << [colorStrs i] << [String..sprintf `-%d´ [depthStrs j]] << `.png´ ) resolution:0.2bp]]] ) |** p]] ) |** null] suite_helper: \ filename resolution:2bp → { - img: [import_raster `raster_data/PngSuite/´ + filename + `.png´ resolution:resolution override:false] - [Layout..center checkers & [Layout..center img] & (@dash:[dashpattern 1mm 1mm] | [stroke [bbox [Layout..center img]]])(0,~1)] - & [Layout..center ( newText << ( newString << img.space << ` ´ << img.depth << "{n} << filename << "{n} ) ) (0,1)] + img: [Graphics..import_raster `raster_data/PngSuite/´ + filename + `.png´ resolution:resolution override:false] + [Layout..center checkers & [Layout..center img] & (@dash:[dashpattern 1mm 1mm] | [Graphics..stroke [Layout..bbox [Layout..center img]]])(0,~1)] + & [Layout..center ( Text..newText << ( String..newString << img.space << ` ´ << img.depth << "{n} << filename << "{n} ) ) (0,1)] } -|** •page << [suite_helper `palette_text_1´ resolution:0.5bp] >> [shift (0*dx,~3*dy)] -|** •page << [suite_helper `alpha_text_8´ resolution:0.5bp] >> [shift (1*dx,~3*dy)] - -•page << [suite_helper `bgai4a08´] >> [shift (0*dx,~4*dy)] -•page << [suite_helper `bgai4a16´] >> [shift (1*dx,~4*dy)] -•page << [suite_helper `bgan6a08´] >> [shift (2*dx,~4*dy)] -•page << [suite_helper `bgan6a16´] >> [shift (3*dx,~4*dy)] - -•page << [suite_helper `basn0g01´] >> [shift (0*dx,~5*dy)] -•page << [suite_helper `basn2c08´] >> [shift (1*dx,~5*dy)] -•page << [suite_helper `basn2c16´] >> [shift (2*dx,~5*dy)] - -•page << [suite_helper `basn0g02´] >> [shift (0*dx,~6*dy)] -•page << [suite_helper `basn0g04´] >> [shift (1*dx,~6*dy)] -•page << [suite_helper `basn0g08´] >> [shift (2*dx,~6*dy)] -•page << [suite_helper `basn0g16´] >> [shift (3*dx,~6*dy)] - -•page << [suite_helper `basn3p01´] >> [shift (0*dx,~7*dy)] -•page << [suite_helper `basn3p02´] >> [shift (1*dx,~7*dy)] -•page << [suite_helper `basn3p04´] >> [shift (2*dx,~7*dy)] -•page << [suite_helper `basn3p08´] >> [shift (3*dx,~7*dy)] - -•page << [suite_helper `basn4a08´] >> [shift (0*dx,~8*dy)] -•page << [suite_helper `basn4a16´] >> [shift (1*dx,~8*dy)] -•page << [suite_helper `basn6a08´] >> [shift (2*dx,~8*dy)] -•page << [suite_helper `basn6a16´] >> [shift (3*dx,~8*dy)] - -•page << [suite_helper `cdfn2c08´] >> [shift (0*dx,~9*dy)] -•page << [suite_helper `cdhn2c08´] >> [shift (1*dx,~9*dy)] -•page << [suite_helper `cdsn2c08´] >> [shift (2*dx,~9*dy)] -•page << [suite_helper `cdun2c08´] >> [shift (3*dx,~9*dy)] +|** IO..•page << [suite_helper `palette_text_1´ resolution:0.5bp] >> [shift (0*dx,~3*dy)] +|** IO..•page << [suite_helper `alpha_text_8´ resolution:0.5bp] >> [shift (1*dx,~3*dy)] + +IO..•page << [suite_helper `bgai4a08´] >> [shift (0*dx,~4*dy)] +IO..•page << [suite_helper `bgai4a16´] >> [shift (1*dx,~4*dy)] +IO..•page << [suite_helper `bgan6a08´] >> [shift (2*dx,~4*dy)] +IO..•page << [suite_helper `bgan6a16´] >> [shift (3*dx,~4*dy)] + +IO..•page << [suite_helper `basn0g01´] >> [shift (0*dx,~5*dy)] +IO..•page << [suite_helper `basn2c08´] >> [shift (1*dx,~5*dy)] +IO..•page << [suite_helper `basn2c16´] >> [shift (2*dx,~5*dy)] + +IO..•page << [suite_helper `basn0g02´] >> [shift (0*dx,~6*dy)] +IO..•page << [suite_helper `basn0g04´] >> [shift (1*dx,~6*dy)] +IO..•page << [suite_helper `basn0g08´] >> [shift (2*dx,~6*dy)] +IO..•page << [suite_helper `basn0g16´] >> [shift (3*dx,~6*dy)] + +IO..•page << [suite_helper `basn3p01´] >> [shift (0*dx,~7*dy)] +IO..•page << [suite_helper `basn3p02´] >> [shift (1*dx,~7*dy)] +IO..•page << [suite_helper `basn3p04´] >> [shift (2*dx,~7*dy)] +IO..•page << [suite_helper `basn3p08´] >> [shift (3*dx,~7*dy)] + +IO..•page << [suite_helper `basn4a08´] >> [shift (0*dx,~8*dy)] +IO..•page << [suite_helper `basn4a16´] >> [shift (1*dx,~8*dy)] +IO..•page << [suite_helper `basn6a08´] >> [shift (2*dx,~8*dy)] +IO..•page << [suite_helper `basn6a16´] >> [shift (3*dx,~8*dy)] + +IO..•page << [suite_helper `cdfn2c08´] >> [shift (0*dx,~9*dy)] +IO..•page << [suite_helper `cdhn2c08´] >> [shift (1*dx,~9*dy)] +IO..•page << [suite_helper `cdsn2c08´] >> [shift (2*dx,~9*dy)] +IO..•page << [suite_helper `cdun2c08´] >> [shift (3*dx,~9*dy)] diff --git a/examples/features/random.shape b/examples/features/random.shape index b444622e..a0af28df 100644 --- a/examples/features/random.shape +++ b/examples/features/random.shape @@ -17,21 +17,22 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Numeric..Random -•stdout << `Now is ´ << [sprintf `%H:%M´ (•time)] << "{n} +IO..•stdout << `Now is ´ << [String..sprintf `%H:%M´ (•time)] << "{n} -•stdout << (•randomdevice) << `, ´ << (•randomdevice) << `, ´ << (•randomdevice) << `, ´ << (•randomdevice) << "{n} +IO..•stdout << (•randomdevice) << `, ´ << (•randomdevice) << `, ´ << (•randomdevice) << `, ´ << (•randomdevice) << "{n} seed: [newRandom (•time)] •rand1: seed •rand2: seed |**•rand3: [newRandom (•time)] •rand3: [devRandom •randomdevice] -•stdout << (•rand1) << `=´ << (•rand2) << `, ´ << (•rand1) << `=´ << (•rand2) << "{n} -•stdout << (•rand3) << `, ´ << [random2D •rand3] << "{n} -•stdout << [random1D •rand1] << `=´ << [random1D •rand2] << `, ´ << [random2D •rand1] << `=´ << [random2D •rand2] << "{n} +IO..•stdout << (•rand1) << `=´ << (•rand2) << `, ´ << (•rand1) << `=´ << (•rand2) << "{n} +IO..•stdout << (•rand3) << `, ´ << [ball2D •rand3] << "{n} +IO..•stdout << [ball1D •rand1] << `=´ << [ball1D •rand2] << `, ´ << [ball2D •rand1] << `=´ << [ball2D •rand2] << "{n} -•page << [stroke - [[range '0 '12].foldsl \ pth i •st → pth--(i*1cm,[random1D •st]*1cm) - emptypath +IO..•page << [Graphics..stroke + [[Data..range '0 '12].foldsl \ pth i •st → pth--(i*1cm,[ball1D •st]*1cm) + Geometry..emptypath •rand3]] diff --git a/examples/features/ranges.blank b/examples/features/ranges.blank index 89541bb1..686bd995 100644 --- a/examples/features/ranges.blank +++ b/examples/features/ranges.blank @@ -20,8 +20,8 @@ helper: \ •dst rng → { - •dst << `== ´ << [sourceof rng] << ` ==´ << "{n} << `-->´ - << [rng.foldl \ p e → ( p + ` ´ + [show e] ) `´] + •dst << `== ´ << [Debug..sourceof rng] << ` ==´ << "{n} << `-->´ + << [rng.foldl \ p e → ( p + ` ´ + [String..show e] ) `´] << "{nn} } @@ -29,20 +29,20 @@ helper: \ •dst rng → /** ** Note that the end value is included in the range of integers... **/ - [helper •stdout locate[][range '3 '10]] + [helper IO..•stdout Debug..locate[][Data..range '3 '10]] } { /** ** ... while it may not be in the range of floats (depending on how the rounding errors come out). **/ - [helper •stdout locate[][range 3 10]] + [helper IO..•stdout Debug..locate[][Data..range 3 10]] } { /** ** Lengths are just like floats, but one must provide the step length: **/ - [helper •stdout locate[][range 3mm 10mm 1mm]] + [helper IO..•stdout Debug..locate[][Data..range 3mm 10mm 1mm]] } @@ -51,9 +51,9 @@ helper: \ •dst rng → **/ { - [helper •stdout locate[][range ~4cm 4cm count:'11]] + [helper IO..•stdout Debug..locate[][Data..range ~4cm 4cm count:'11]] } { - [helper •stdout locate[][range end:'10 step:'~3 count:'5]] + [helper IO..•stdout Debug..locate[][Data..range end:'10 step:'~3 count:'5]] } diff --git a/examples/features/raster_jpeg.shape b/examples/features/raster_jpeg.shape index 0e6fc558..91e5ead3 100644 --- a/examples/features/raster_jpeg.shape +++ b/examples/features/raster_jpeg.shape @@ -23,12 +23,12 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout -img: [import_raster `raster_data/logo-low.jpg´ resolution:3bp] /** Load image with large pixels so that the lossy compression becomes obvious. **/ -imgNatural: [import_raster `raster_data/logo-low.jpg´ override:false] /** Load image with resolution according to file. However, if the file **/ -sq: [fill [rectangle (0cm,0cm) (1cm,1cm)]] -bb: [bbox img] +img: [Graphics..import_raster `raster_data/logo-low.jpg´ resolution:3bp] /** Load image with large pixels so that the lossy compression becomes obvious. **/ +imgNatural: [Graphics..import_raster `raster_data/logo-low.jpg´ override:false] /** Load image with resolution according to file. However, if the file **/ +sq: [Graphics..fill [Geometry..rectangle (0cm,0cm) (1cm,1cm)]] +bb: [Layout..bbox img] -•page << @nonstroking:[gray 0.5] | [fill [bbox [bboxed_enlarge img (7mm,7mm)]]] /** Make gray background, so that the boundary of the raster image becomes visible. **/ +IO..•page << @nonstroking:[gray 0.5] | [Graphics..fill [Layout..bbox [bboxed_enlarge img (7mm,7mm)]]] /** Make gray background, so that the boundary of the raster image becomes visible. **/ << img << sq >> [Layout..center z:(1,1) ...] >> [shift ([xmin bb],[ymin bb])] << sq >> [Layout..center z:(~1,1) ...] >> [shift ([xmax bb],[ymin bb])] diff --git a/examples/features/raster_png.shape b/examples/features/raster_png.shape index 7d41dc2f..12103b32 100644 --- a/examples/features/raster_png.shape +++ b/examples/features/raster_png.shape @@ -32,23 +32,23 @@ img: (escape_continuation return (escape_continuation error (escape_continue return - [import_raster the_filename resolution:1bp])) + [Graphics..import_raster the_filename resolution:1bp])) >> \ ball → - [cond [cons ball.kind = 'out_of_range and ball.details = '0 /** This is the error thrown if there was a problem finding or opening the file. **/ + [cond [Data..cons ball.kind = 'out_of_range and ball.details = '0 /** This is the error thrown if there was a problem finding or opening the file. **/ /** Generate a picture indicating a missing image. **/ - ( @stroking:GRAY_BLACK & @nonstroking:[gray 0.9] & @width:1bp | [fillstroke [rectangle (~1cm,~1cm) (1cm,1cm)]] ) + ( @stroking:Traits..BW..BLACK & @nonstroking:[gray 0.9] & @width:1bp | [Graphics..fillstroke [Geometry..rectangle (~1cm,~1cm) (1cm,1cm)]] ) & - ( @stroking:RGB_RED & @width:1bp | [stroke (~1cm,~1cm)--(1cm,1cm) & (~1cm,1cm)--(1cm,~1cm)] )] - [cons true /** In case we didn't handle the error, we just pass it on. **/ + ( @stroking:Traits..RGB..RED & @width:1bp | [Graphics..stroke (~1cm,~1cm)--(1cm,1cm) & (~1cm,1cm)--(1cm,~1cm)] )] + [Data..cons true /** In case we didn't handle the error, we just pass it on. **/ (escape_continue error ball)]]) -sq: [fill [rectangle (0cm,0cm) (1cm,1cm)]] -bb: [bbox img] +sq: [Graphics..fill [Geometry..rectangle (0cm,0cm) (1cm,1cm)]] +bb: [Layout..bbox img] -imgNatural: [import_raster the_filename override:false] /** Load image with resolution according to file. **/ +imgNatural: [Graphics..import_raster the_filename override:false] /** Load image with resolution according to file. **/ -•page << @nonstroking:[gray 0.5] | [fill [bbox [bboxed_enlarge img (7mm,7mm)]]] /** Make gray background, so that the boundary of the raster image becomes visible. **/ +IO..•page << @nonstroking:[gray 0.5] | [Graphics..fill [Layout..bbox [bboxed_enlarge img (7mm,7mm)]]] /** Make gray background, so that the boundary of the raster image becomes visible. **/ << img << sq >> [Layout..center z:(1,1) ...] >> [shift ([xmin bb],[ymin bb])] << sq >> [Layout..center z:(~1,1) ...] >> [shift ([xmax bb],[ymin bb])] diff --git a/examples/features/remove.shape b/examples/features/remove.shape index 5e7a27b9..28038bda 100644 --- a/examples/features/remove.shape +++ b/examples/features/remove.shape @@ -20,19 +20,19 @@ •stuff: newGroup -•catalog.[setbboxgroup 'all] +IO..•catalog.[setbboxgroup 'all] -•stuff << [tag 'a ( newText << `A´ )] -•catalog << (•stuff) +•stuff << [Graphics..Tag..tag 'a ( Text..newText << `A´ )] +IO..•catalog << (•stuff) -•stuff << [tag 'b [shift (1cm,0cm)] [] ( newText << `B´ )] -•catalog << (•stuff) +•stuff << [Graphics..Tag..tag 'b [shift (1cm,0cm)] [] ( Text..newText << `B´ )] +IO..•catalog << (•stuff) -•stuff << [tag 'c [shift (2cm,0cm)] [] ( newText << `C´ )] -•catalog << (•stuff) +•stuff << [Graphics..Tag..tag 'c [shift (2cm,0cm)] [] ( Text..newText << `C´ )] +IO..•catalog << (•stuff) •stuff.[remove 'a] -•catalog << (•stuff) +IO..•catalog << (•stuff) /** Now, we just demonstrate how we can make a function that calls the "remove" method on its argument. ** Instead of writing @@ -42,7 +42,7 @@ ** we use the special syntax for creating functions such as the one above. **/ •stuff << >>.[remove 'b] -•catalog << (•stuff) +IO..•catalog << (•stuff) •stuff.[remove 'c] -•catalog << (•stuff) +IO..•catalog << (•stuff) diff --git a/examples/features/rotations.shape b/examples/features/rotations.shape index 0ea9c138..e0f4c1f3 100644 --- a/examples/features/rotations.shape +++ b/examples/features/rotations.shape @@ -18,6 +18,7 @@ ##lookin ..Shapes ##lookin ..Shapes..Graphics +##lookin ..Shapes..Geometry3D pth: (~1cm,~1cm,~1cm)--(~1cm,1cm,~1cm)--(1cm,1cm,~1cm)--(1cm,~1cm,~1cm)--(1cm,~1cm,1cm)--(1cm,1cm,1cm)--(~1cm,1cm,1cm)--(~1cm,~1cm,1cm) pt1: (~1cm,~1cm,~1cm) @@ -28,18 +29,18 @@ pt4: (1cm,~1cm,~1cm) theDash: @dash:[dashpattern 2mm 1mm] rottest: \ dir angle → -{ tf:[rotate3D dir:dir angle:angle] +{ tf:[Geometry3D..rotate dir:dir angle:angle] @eyez:10cm & @width:0.3bp | - ( newGroup << theDash|[stroke [view pth]] << [stroke [view (0cm,0cm,0cm)--(1.3cm*[normalized dir])] head:Graphics..ShapesArrow] << [stroke [view [tf pth]]] - << @width:1bp|[stroke [view pt1--[tf pt1]] head:Graphics..ShapesArrow] - << @width:1bp|[stroke [view pt2--[tf pt2]] head:Graphics..ShapesArrow] - << @width:1bp|[stroke [view pt3--[tf pt3]] head:Graphics..ShapesArrow] - << @width:1bp|[stroke [view pt4--[tf pt4]] head:Graphics..ShapesArrow] + ( newGroup << theDash|[Graphics..stroke [view pth]] << [Graphics..stroke [view (0cm,0cm,0cm)--(1.3cm*[normalized dir])] head:Graphics..ShapesArrow] << [Graphics..stroke [view [tf pth]]] + << @width:1bp|[Graphics..stroke [view pt1--[tf pt1]] head:Graphics..ShapesArrow] + << @width:1bp|[Graphics..stroke [view pt2--[tf pt2]] head:Graphics..ShapesArrow] + << @width:1bp|[Graphics..stroke [view pt3--[tf pt3]] head:Graphics..ShapesArrow] + << @width:1bp|[Graphics..stroke [view pt4--[tf pt4]] head:Graphics..ShapesArrow] ) } -•page << [[shift (0cm,0cm)] [rottest (1,0,0) 15°]] -•page << [[shift (5cm,0cm)] [rottest (0,1,0) 15°]] -•page << [[shift (10cm,0cm)] [rottest (0,0,1) 15°]] +IO..•page << [[shift (0cm,0cm)] [rottest (1,0,0) 15°]] +IO..•page << [[shift (5cm,0cm)] [rottest (0,1,0) 15°]] +IO..•page << [[shift (10cm,0cm)] [rottest (0,0,1) 15°]] diff --git a/examples/features/rotlabel.shape b/examples/features/rotlabel.shape index c045317b..8aa4ea12 100644 --- a/examples/features/rotlabel.shape +++ b/examples/features/rotlabel.shape @@ -17,15 +17,16 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -lbl: [immerse [TeX `$\int_{\alpha}^{\beta}$\LaTeX2e´]] +lbl: [immerse [Graphics..TeX `$\int_{\alpha}^{\beta}$\LaTeX2e´]] @eyez:∞ | { -•page << [[shift (0cm,0cm)] [view [[rotate3D dir:(1,0,0) angle:0°] lbl]]] -•page << [[shift (3cm,0cm)] [view [[rotate3D dir:(1,0,0) angle:20°] lbl]]] -•page << [[shift (6cm,0cm)] [view [[rotate3D dir:(1,0,0) angle:40°] lbl]]] -•page << [[shift (9cm,0cm)] [view [[rotate3D dir:(1,0,0) angle:60°] lbl]]] -•page << [[shift (12cm,0cm)] [view [[rotate3D dir:(1,0,0) angle:80°] lbl]]] +IO..•page << [[shift (0cm,0cm)] [view [[Geometry3D..rotate dir:(1,0,0) angle:0°] lbl]]] +IO..•page << [[shift (3cm,0cm)] [view [[Geometry3D..rotate dir:(1,0,0) angle:20°] lbl]]] +IO..•page << [[shift (6cm,0cm)] [view [[Geometry3D..rotate dir:(1,0,0) angle:40°] lbl]]] +IO..•page << [[shift (9cm,0cm)] [view [[Geometry3D..rotate dir:(1,0,0) angle:60°] lbl]]] +IO..•page << [[shift (12cm,0cm)] [view [[Geometry3D..rotate dir:(1,0,0) angle:80°] lbl]]] } diff --git a/examples/features/scopes.blank b/examples/features/scopes.blank index 133f46d9..fb5cea92 100644 --- a/examples/features/scopes.blank +++ b/examples/features/scopes.blank @@ -23,16 +23,16 @@ a: 1 a: 2 { a: 4 - •stdout << `a0 = ´ << a << "{n} - •stdout << `a1 = ´ << ../a << "{n} - •stdout << `a2 = ´ << ../../a << "{n} - •stdout << `a1+a2 = ´ << ../(a+../a) << "{n} + IO..•stdout << `a0 = ´ << a << "{n} + IO..•stdout << `a1 = ´ << ../a << "{n} + IO..•stdout << `a2 = ´ << ../../a << "{n} + IO..•stdout << `a1+a2 = ´ << ../(a+../a) << "{n} } } { odd: \ n → [if n = 0 false [even n-1]] even: \ n → [if n = 0 true [odd n-1]] - •stdout << `Is 0 odd? --> ´ << [odd 0] << "{n} - •stdout << `Is 4 even? --> ´ << [even 4] << "{n} + IO..•stdout << `Is 0 odd? --> ´ << [odd 0] << "{n} + IO..•stdout << `Is 4 even? --> ´ << [even 4] << "{n} } diff --git a/examples/features/shapesarrow-parameters.shape b/examples/features/shapesarrow-parameters.shape index db06ee9b..e356afd7 100644 --- a/examples/features/shapesarrow-parameters.shape +++ b/examples/features/shapesarrow-parameters.shape @@ -25,25 +25,25 @@ lengthMarks: \ n p r:void a:75° → { - the_r: [if [typeof r]=§Void @width*10 r] + the_r: [if [typeof r]=Data..Type..§Void @width*10 r] d: 0.5 * the_r rot: [rotate a] l_p: (|p|) (> picture: - [[range '0 n-'1].foldl + [[Data..range '0 n-'1].foldl \ pile e → pile & { sl: [p 0.5*l_p + ( e*1 - 0.5*(n-'1) ) * d] - [shift sl.p]*rot [] [stroke the_r*sl.T--~the_r*sl.T] + [shift sl.p]*rot [] [Graphics..stroke the_r*sl.T--~the_r*sl.T] } null] cut:0m <) } -•page << [shift (~4cm,~1cm)][][Layout..center [TeX ` +IO..•page << [shift (~4cm,~1cm)][][Layout..center [Graphics..TeX ` \begin{minipage}{6cm} \begin{align*} 2\, \alpha &= \text{\texttt{frontAngle}} @@ -52,9 +52,9 @@ lengthMarks: \ n p r:void a:75° → \\ 2\, w &= \begin{cases} -\text{\texttt{width}}, & \text{if \texttt{width} is a §Length} +\text{\texttt{width}}, & \text{if \texttt{width} is a Data..Type..§Length} \\ -\max \left\{\, 3\,\mathrm{bp},\, \text{\texttt{width}}\, \text{\texttt{@width}} \,\right\}, & \text{if \texttt{width} is a §Float} +\Numeric..Math..max \left\{\, 3\,\mathrm{bp},\, \text{\texttt{width}}\, \text{\texttt{@width}} \,\right\}, & \text{if \texttt{width} is a Data..Type..§Float} \end{cases} \end{align*} \end{minipage} @@ -68,29 +68,29 @@ lengthMarks: \ n p r:void a:75° → /** First we set up variables that mirror the formal parameters of ShapesArrow. **/ - p: [reverse pth] + p: [Geometry..reverse pth] width:3 frontAngle:40° rearAngle:150° /** Show the arrowhead. **/ - •page << @stroking:[gray 0.7] | [stroke pth head:[Graphics..ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]] + IO..•page << @stroking:[gray 0.7] | [Graphics..stroke pth head:[Graphics..ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]] /** Then we paste the implementation of ShapesArrow... **/ z: p.begin.p - lMax: 0.99*[abs p] - w: 0.5*[if [typeof width]=§Float @width*width width] - el: [min w/[sin 0.5*frontAngle] lMax] - l: [min w * ( [cot 0.5*frontAngle] - [cot 0.5*rearAngle] ) lMax] + lMax: 0.99*[Numeric..Math..abs p] + w: 0.5*[if [typeof width]=Data..Type..§Float @width*width width] + el: [Numeric..Math..min w/[Numeric..Math..sin 0.5*frontAngle] lMax] + l: [Numeric..Math..min w * ( [Numeric..Math..cot 0.5*frontAngle] - [Numeric..Math..cot 0.5*rearAngle] ) lMax] e: [p 0]--[p el] >> [shift ~z] sl: [p l] pr: sl.p dr: e.end.p dra: [angle dr] drl: (|dr|) - r: w / [sin 0.5*rearAngle] + r: w / [Numeric..Math..sin 0.5*rearAngle] d1: sl.p + [[rotate 0.5*rearAngle] (r*sl.T)] - z d2: sl.p + [[rotate ~0.5*rearAngle] (r*sl.T)] - z @@ -102,20 +102,20 @@ lengthMarks: \ n p r:void a:75° → /** ... so that we can annotate the result! **/ - •page << @width:3bp & @stroking:[gray 0.8] | [stroke pth] + IO..•page << @width:3bp & @stroking:[gray 0.8] | [Graphics..stroke pth] - @width:1.5bp & @stroking:RGB_BLUE + @width:1.5bp & @stroking:Traits..RGB..BLUE | { - •page << [stroke [shift z][]e] - << [stroke e1] - << [stroke e2] + IO..•page << [Graphics..stroke [shift z][]e] + << [Graphics..stroke e1] + << [Graphics..stroke e2] } - @width:5bp & @stroking:RGB_RED + @width:5bp & @stroking:Traits..RGB..RED | { - •page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p] + IO..•page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p] } hStyle: @width:0.5bp & @stroking:[gray 0.2] @@ -127,75 +127,75 @@ lengthMarks: \ n p r:void a:75° → r0: 1cm r1: 2.5cm r2: 3.5cm - •page << [stroke [shift z][]( e1.begin.T*r0--e1.begin.T*~r1 )] - •page << [stroke [shift z][]( e2.begin.T*r0--e2.begin.T*~r1 )] + IO..•page << [Graphics..stroke [shift z][]( e1.begin.T*r0--e1.begin.T*~r1 )] + IO..•page << [Graphics..stroke [shift z][]( e2.begin.T*r0--e2.begin.T*~r1 )] { rAngle: 0.8*r1 arc: [shift z] [] [Geometry..ccw_arc (0m,0m) [rotate ~(5mm/rAngle)][]e2.begin.T*~r1 e2.begin.T*~r1 rAngle] - •page << [stroke [shift z] [] [Geometry..ccw_arc (0m,0m) e2.begin.T*~r1 e1.begin.T*~r1 rAngle]] - << [stroke [shift z] [] [Geometry..cw_arc (0m,0m) [rotate (5mm/rAngle)][]e1.begin.T*~r1 e1.begin.T*~r1 rAngle] + IO..•page << [Graphics..stroke [shift z] [] [Geometry..ccw_arc (0m,0m) e2.begin.T*~r1 e1.begin.T*~r1 rAngle]] + << [Graphics..stroke [shift z] [] [Geometry..cw_arc (0m,0m) [rotate (5mm/rAngle)][]e1.begin.T*~r1 e1.begin.T*~r1 rAngle] head:angleHead] - << [stroke arc head:angleHead] - << [putlabelRight [TeX `$\approx 2\, \alpha$´] arc.begin.p ~1] + << [Graphics..stroke arc head:angleHead] + << [putlabelRight [Graphics..TeX `$\approx 2\, \alpha$´] arc.begin.p ~1] } { arc1: [shift z] [] [Geometry..cw_arc (0m,0m) e1.begin.T*~r1 p.begin.T*~r1 0.5*(r1+r2)] arc2: [shift z] [] [Geometry..ccw_arc (0m,0m) e2.begin.T*~r1 p.begin.T*~r1 0.5*(r1+r2)] - •page << [stroke z--(+~r2*p.begin.T)] - << [stroke [[shift z]*[rotate 0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]] - << [stroke [[shift z]*[rotate ~0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]] - << [stroke arc1 head:angleHead tail:angleHead] - << [stroke arc2 head:angleHead tail:angleHead] - << [putlabelRight [TeX `$\alpha$´] [Layout..mspoint arc1 0.5] ~1] - << [putlabelRight [TeX `$\alpha$´] [Layout..mspoint arc2 0.5] ~1] + IO..•page << [Graphics..stroke z--(+~r2*p.begin.T)] + << [Graphics..stroke [[shift z]*[rotate 0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]] + << [Graphics..stroke [[shift z]*[rotate ~0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]] + << [Graphics..stroke arc1 head:angleHead tail:angleHead] + << [Graphics..stroke arc2 head:angleHead tail:angleHead] + << [putlabelRight [Graphics..TeX `$\alpha$´] [Layout..mspoint arc1 0.5] ~1] + << [putlabelRight [Graphics..TeX `$\alpha$´] [Layout..mspoint arc2 0.5] ~1] } { p: e1.end.p--pr - •page << [stroke p] - << [putlabelRight [TeX `$r$´] [Layout..mspoint p 0.5] 0] + IO..•page << [Graphics..stroke p] + << [putlabelRight [Graphics..TeX `$r$´] [Layout..mspoint p 0.5] 0] } { p: pr--e2.end.p - •page << [stroke p] - << [putlabelRight [TeX `$r$´] [Layout..mspoint p 0.5] 0] + IO..•page << [Graphics..stroke p] + << [putlabelRight [Graphics..TeX `$r$´] [Layout..mspoint p 0.5] 0] } { - pw: pr + [cos 0.5*rearAngle]*r*sl.T + pw: pr + [Numeric..Math..cos 0.5*rearAngle]*r*sl.T p1: pw--e1.end.p p2: pw--e2.end.p - •page << [stroke p1 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$w$´] [Layout..mspoint p1 0.5] 1] - << [stroke p2 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$w$´] [Layout..mspoint p2 0.5] ~1] + IO..•page << [Graphics..stroke p1 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$w$´] [Layout..mspoint p1 0.5] 1] + << [Graphics..stroke p2 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$w$´] [Layout..mspoint p2 0.5] ~1] } { hLine: pr--(+(1.2*r*sl.T)) arc1: [Geometry..ccw_arc pr hLine.end.p e1.end.p 0.9*r] arc2: [Geometry..cw_arc pr hLine.end.p e2.end.p 0.9*r] - •page << [stroke hLine] - << [stroke arc1 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\beta$´] [Layout..mspoint arc1 0.5] 1] - << [stroke arc2 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\beta$´] [Layout..mspoint arc2 0.5] ~1] + IO..•page << [Graphics..stroke hLine] + << [Graphics..stroke arc1 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\beta$´] [Layout..mspoint arc1 0.5] 1] + << [Graphics..stroke arc2 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\beta$´] [Layout..mspoint arc2 0.5] ~1] } { offset: 5bp arc0: p.begin--[p l] - arc: [Geometry..sidepath2 [upsample_bends 20° arc0] offset] - •page << [stroke arc head:angleHead tail:angleHead] - << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] - << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)] - << [putlabelBelow [TeX `$l$´] [Layout..mspoint arc 0.8] 0] + arc: [Geometry..sidepath2 [Geometry..upsample_bends 20° arc0] offset] + IO..•page << [Graphics..stroke arc head:angleHead tail:angleHead] + << [Graphics..stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] + << [Graphics..stroke arc0.end.p--(+arc0.end.rN*~2*offset)] + << [putlabelBelow [Graphics..TeX `$l$´] [Layout..mspoint arc 0.8] 0] } { offset: ~5bp arc0: [shift z][]e - arc: [Geometry..sidepath2 [upsample_bends 20° arc0] offset] - •page << [stroke arc head:angleHead tail:angleHead] - << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] - << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)] - << [putlabelAbove [TeX `$h$´] [Layout..mspoint arc 0.7] 0] + arc: [Geometry..sidepath2 [Geometry..upsample_bends 20° arc0] offset] + IO..•page << [Graphics..stroke arc head:angleHead tail:angleHead] + << [Graphics..stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] + << [Graphics..stroke arc0.end.p--(+arc0.end.rN*~2*offset)] + << [putlabelAbove [Graphics..TeX `$h$´] [Layout..mspoint arc 0.7] 0] } } @@ -210,29 +210,29 @@ lengthMarks: \ n p r:void a:75° → /** First we set up variables that mirror the formal parameters of ShapesArrow. **/ - p: [reverse pth] + p: [Geometry..reverse pth] width:3 frontAngle:40° rearAngle:150° /** Show the arrowhead. **/ - •page << @stroking:[gray 0.7] | [stroke pth head:[Graphics..ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]] + IO..•page << @stroking:[gray 0.7] | [Graphics..stroke pth head:[Graphics..ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]] /** Then we paste the implementation of ShapesArrow... **/ z: p.begin.p - lMax: 0.99*[abs p] - w: 0.5*[if [typeof width]=§Float @width*width width] - el: [min w/[sin 0.5*frontAngle] lMax] - l: [min w * ( [cot 0.5*frontAngle] - [cot 0.5*rearAngle] ) lMax] + lMax: 0.99*[Numeric..Math..abs p] + w: 0.5*[if [typeof width]=Data..Type..§Float @width*width width] + el: [Numeric..Math..min w/[Numeric..Math..sin 0.5*frontAngle] lMax] + l: [Numeric..Math..min w * ( [Numeric..Math..cot 0.5*frontAngle] - [Numeric..Math..cot 0.5*rearAngle] ) lMax] e: [p 0]--[p el] >> [shift ~z] sl: [p l] pr: sl.p dr: e.end.p dra: [angle dr] drl: (|dr|) - r: w / [sin 0.5*rearAngle] + r: w / [Numeric..Math..sin 0.5*rearAngle] d1: sl.p + [[rotate 0.5*rearAngle] (r*sl.T)] - z d2: sl.p + [[rotate ~0.5*rearAngle] (r*sl.T)] - z @@ -244,20 +244,20 @@ lengthMarks: \ n p r:void a:75° → /** ... so that we can annotate the result! **/ - •page << @width:3bp & @stroking:[gray 0.8] | [stroke pth] + IO..•page << @width:3bp & @stroking:[gray 0.8] | [Graphics..stroke pth] - @width:1.5bp & @stroking:RGB_BLUE + @width:1.5bp & @stroking:Traits..RGB..BLUE | { - •page << [stroke [shift z][]e] - << [stroke e1] - << [stroke e2] + IO..•page << [Graphics..stroke [shift z][]e] + << [Graphics..stroke e1] + << [Graphics..stroke e2] } - @width:5bp & @stroking:RGB_RED + @width:5bp & @stroking:Traits..RGB..RED | { - •page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p] + IO..•page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p] } hStyle: @width:0.5bp & @stroking:[gray 0.2] @@ -270,60 +270,60 @@ lengthMarks: \ n p r:void a:75° → rLbl: 2cm arc1: [Geometry..ccw_arc z pr e1.end.p rLbl] arc2: [Geometry..cw_arc z pr e2.end.p rLbl] - •page << [stroke arc1 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\alpha$´] [Layout..mspoint arc1 0.5] 0] - << [stroke arc2 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\alpha$´] [Layout..mspoint arc2 0.5] ~0.5] + IO..•page << [Graphics..stroke arc1 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\alpha$´] [Layout..mspoint arc1 0.5] 0] + << [Graphics..stroke arc2 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\alpha$´] [Layout..mspoint arc2 0.5] ~0.5] } { p: e1.end.p--pr - •page << [stroke p] - << [putlabelRight [TeX `$r$´] [Layout..mspoint p 0.5] 0] + IO..•page << [Graphics..stroke p] + << [putlabelRight [Graphics..TeX `$r$´] [Layout..mspoint p 0.5] 0] } { p: pr--e2.end.p - •page << [stroke p] - << [putlabelRight [TeX `$r$´] [Layout..mspoint p 0.5] 0] + IO..•page << [Graphics..stroke p] + << [putlabelRight [Graphics..TeX `$r$´] [Layout..mspoint p 0.5] 0] } { - pw: pr + [cos 0.5*rearAngle]*r*sl.T + pw: pr + [Numeric..Math..cos 0.5*rearAngle]*r*sl.T p1: pw--e1.end.p p2: pw--e2.end.p - •page << [stroke p1 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$w$´] [Layout..mspoint p1 0.5] 1] - << [stroke p2 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$w$´] [Layout..mspoint p2 0.5] ~1] + IO..•page << [Graphics..stroke p1 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$w$´] [Layout..mspoint p1 0.5] 1] + << [Graphics..stroke p2 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$w$´] [Layout..mspoint p2 0.5] ~1] } { hLine: pr--(+(1.2*r*sl.T)) arc1: [Geometry..ccw_arc pr hLine.end.p e1.end.p 0.9*r] arc2: [Geometry..cw_arc pr hLine.end.p e2.end.p 0.9*r] - •page << [stroke hLine] - << [stroke arc1 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\beta$´] [Layout..mspoint arc1 0.5] 1] - << [stroke arc2 head:angleHead tail:angleHead] - << [putlabelLeft [TeX `$\beta$´] [Layout..mspoint arc2 0.5] ~1] + IO..•page << [Graphics..stroke hLine] + << [Graphics..stroke arc1 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\beta$´] [Layout..mspoint arc1 0.5] 1] + << [Graphics..stroke arc2 head:angleHead tail:angleHead] + << [putlabelLeft [Graphics..TeX `$\beta$´] [Layout..mspoint arc2 0.5] ~1] } { offset: 5bp arc0: p.begin--[p l] - arc: [Geometry..sidepath [upsample_bends 20° arc0] offset] - •page << [stroke arc head:angleHead tail:angleHead] - << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] - << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)] - << [putlabelBelow [TeX `$l$´] [Layout..mspoint arc 0.8] 0] + arc: [Geometry..sidepath [Geometry..upsample_bends 20° arc0] offset] + IO..•page << [Graphics..stroke arc head:angleHead tail:angleHead] + << [Graphics..stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] + << [Graphics..stroke arc0.end.p--(+arc0.end.rN*~2*offset)] + << [putlabelBelow [Graphics..TeX `$l$´] [Layout..mspoint arc 0.8] 0] } { offset: ~5bp arc0: [shift z][]e - arc: [Geometry..sidepath [upsample_bends 20° arc0] offset] - •page << [stroke arc head:angleHead tail:angleHead] - << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] - << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)] - << [putlabelAbove [TeX `$h$´] [Layout..mspoint arc 0.7] 0] - << [putlabelBelow [TeX `$h$´] [Layout..mspoint e1 0.7] 0] - << [putlabelAbove [TeX `$h$´] [Layout..mspoint e2 0.7] 0] + arc: [Geometry..sidepath [Geometry..upsample_bends 20° arc0] offset] + IO..•page << [Graphics..stroke arc head:angleHead tail:angleHead] + << [Graphics..stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)] + << [Graphics..stroke arc0.end.p--(+arc0.end.rN*~2*offset)] + << [putlabelAbove [Graphics..TeX `$h$´] [Layout..mspoint arc 0.7] 0] + << [putlabelBelow [Graphics..TeX `$h$´] [Layout..mspoint e1 0.7] 0] + << [putlabelAbove [Graphics..TeX `$h$´] [Layout..mspoint e2 0.7] 0] } } diff --git a/examples/features/shortcut.blank b/examples/features/shortcut.blank index 008e935d..eb50509b 100644 --- a/examples/features/shortcut.blank +++ b/examples/features/shortcut.blank @@ -18,12 +18,12 @@ ##lookin ..Shapes -•stdout << [(and)] << "{n} -•stdout << [(and) 1=0] << "{n} -•stdout << (true and true) << "{n} +IO..•stdout << [(and)] << "{n} +IO..•stdout << [(and) 1=0] << "{n} +IO..•stdout << (true and true) << "{n} -•stdout << [if [(or) false false (1 = 1) (false = 28)] `Good´ `Bad´] << "{n} +IO..•stdout << [if [(or) false false (1 = 1) (false = 28)] `Good´ `Bad´] << "{n} -•stdout << [if not( true and true and (1 = 0) and (false = 28)) `good´ `bad´] << "{n} +IO..•stdout << [if not( true and true and (1 = 0) and (false = 28)) `good´ `bad´] << "{n} -•stdout << (escape_continuation esc [if [(and) 1 = 1 (escape_continue esc `Good:escape´) true] `Bad:true´ `Bad:false´]) << "{n} +IO..•stdout << (escape_continuation esc [if [(and) 1 = 1 (escape_continue esc `Good:escape´) true] `Bad:true´ `Bad:false´]) << "{n} diff --git a/examples/features/show.blank b/examples/features/show.blank index bdaa2673..c47800d6 100644 --- a/examples/features/show.blank +++ b/examples/features/show.blank @@ -21,31 +21,34 @@ ##lookin ..Shapes ##lookin ..Shapes..Alternative -•stdout << ` +IO..•stdout << ` Hi shaper! ´ -•stdout << `These are all the same: ´ << '"ä << ` ´ << '&U+00E4; << ` ´ << '&G+adieresis; << ` ´ << [Unicode '0xE*'16+'4] << ` ´ << [AdobeGlyphList 'adieresis] << "{n} -•stdout << `The value of pi is ´ << 180deg << "{n} + +IO..•stdout << Data..Type..§Color << "{n} + +IO..•stdout << `These are all the same: ´ << '"ä << ` ´ << '&U+00E4; << ` ´ << '&G+adieresis; << ` ´ << [String..Unicode '0xE*'16+'4] << ` ´ << [String..AdobeGlyphList 'adieresis] << "{n} +IO..•stdout << `The value of pi is ´ << 180deg << "{n} add: \ x → \ y → x + y -•stdout << add << [[add 1cm] 2cm] << "{n} -•stdout << `Bye´ << "{n} +IO..•stdout << add << [[add 1cm] 2cm] << "{n} +IO..•stdout << `Bye´ << "{n} { add: \ x → 2*x - •stdout << [add 5] << [debuglog_after `This string goes to the log file, the next string is returned.´+"{n} "{n}] + IO..•stdout << [add 5] << [Debug..log_after `This string goes to the log file, the next string is returned.´+"{n} "{n}] } -•stdout << [[add '5] '8] << "{n} +IO..•stdout << [[add '5] '8] << "{n} { - a: { •stdout << `Initializing a´ << "{n} + a: { IO..•stdout << `Initializing a´ << "{n} 4 } - b: !{ •stdout << `Initializing b´ << "{n} + b: !{ IO..•stdout << `Initializing b´ << "{n} 5 } - c: { •stdout << `Initializing c´ << "{n} + c: { IO..•stdout << `Initializing c´ << "{n} 6 } - •stdout << c << a << b << "{n} + IO..•stdout << c << a << b << "{n} } -•stdout << `A very short length: ´ << 1.3*^~5cm << "{n} -•stdout << `A very big number: ´ << 5.7*^8 << "{n} +IO..•stdout << `A very short length: ´ << 1.3*^~5cm << "{n} +IO..•stdout << `A very big number: ´ << 5.7*^8 << "{n} diff --git a/examples/features/sidepaths.shape b/examples/features/sidepaths.shape index f2db910f..a7e66607 100644 --- a/examples/features/sidepaths.shape +++ b/examples/features/sidepaths.shape @@ -19,60 +19,61 @@ ##needs ..Shapes..Geometry / pathmapping ##lookin ..Shapes +##lookin ..Shapes..Geometry pathpoints: { - helper: \ sl → [if sl.looped [list] [cons sl [helper sl+1]]] + helper: \ sl → [if sl.looped [Data..list] [Data..cons sl [helper sl+1]]] \ pth → [helper pth.begin] } sstroke: \ pth → -( (@stroking:RGB_BLACK | [[pathpoints pth].foldl \ p sl → ( p & [stroke [shift sl.p][]( (sl.N*6*@width)--(sl.N*~5*@width) )] ) null]) +( (@stroking:Traits..RGB..BLACK | [[pathpoints pth].foldl \ p sl → ( p & [Graphics..stroke [shift sl.p][]( (sl.N*6*@width)--(sl.N*~5*@width) )] ) null]) & - [stroke pth] + [Graphics..stroke pth] ) cstroke: \ pth → ( - (@stroking:RGB_GREEN & @width:(2*@width) | [stroke [controlling pth]] ) + (@stroking:Traits..RGB..GREEN & @width:(2*@width) | [Graphics..stroke [Geometry..controlling pth]] ) & [sstroke pth] ) -testPth: @defaultunit:1%C | (0cm,0cm)>(^~30°)--(^)<(2cm,3cm)>(^45°)--(^)<(5cm,2cm)>(^0°)--(6cm,2cm)--(8cm,4cm) +testPth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^~30°)--(^)<(2cm,3cm)>(^45°)--(^)<(5cm,2cm)>(^0°)--(6cm,2cm)--(8cm,4cm) test: \ •dst pth method → ( @width: 0.5bp | { - •dst << @stroking:RGB_RED | [cstroke pth] - •dst << [debuglog_after `1´ ...][][stroke [method pth 2mm]] - •dst << [debuglog_after `1´ ...][][stroke [method pth ~2mm]] + •dst << @stroking:Traits..RGB..RED | [cstroke pth] + •dst << [Debug..log_after `1´ ...][][Graphics..stroke [method pth 2mm]] + •dst << [Debug..log_after `1´ ...][][Graphics..stroke [method pth ~2mm]] { pth: [shift (0,~5cm)][][upsample_inflections ../pth] - •dst << @stroking:RGB_RED | [cstroke pth] - •dst << [debuglog_after `2´ ...][][stroke [method pth 2mm]] - •dst << [debuglog_after `2´ ...][][stroke [method pth ~2mm]] + •dst << @stroking:Traits..RGB..RED | [cstroke pth] + •dst << [Debug..log_after `2´ ...][][Graphics..stroke [method pth 2mm]] + •dst << [Debug..log_after `2´ ...][][Graphics..stroke [method pth ~2mm]] } { pth: ../pth >> upsample_inflections >> upsample_balance >> [shift (0,~10cm)] - •dst << @stroking:RGB_RED | [cstroke pth] - •dst << [debuglog_after `3´ ...][][stroke [method pth 2mm]] - •dst << [debuglog_after `3´ ...][][stroke [method pth ~2mm]] + •dst << @stroking:Traits..RGB..RED | [cstroke pth] + •dst << [Debug..log_after `3´ ...][][Graphics..stroke [method pth 2mm]] + •dst << [Debug..log_after `3´ ...][][Graphics..stroke [method pth ~2mm]] } { pth: [shift (0,~15cm)][][upsample_bends 20° ../pth] - •dst << @stroking:RGB_RED | [cstroke pth] - •dst << [debuglog_after `4´ ...][][stroke [method pth 2mm]] - •dst << [debuglog_after `4´ ...][][stroke [method pth ~2mm]] + •dst << @stroking:Traits..RGB..RED | [cstroke pth] + •dst << [Debug..log_after `4´ ...][][Graphics..stroke [method pth 2mm]] + •dst << [Debug..log_after `4´ ...][][Graphics..stroke [method pth ~2mm]] } } ) -[debuglog_before `Geometry..sidepath´+"{n} ...][][test •page testPth Geometry..sidepath] -|**[debuglog_before `Geometry..sidepath2´+"{n} ...][][test •page [shift (9cm,0)][]testPth Geometry..sidepath2] +[Debug..log_before `sidepath´+"{n} ...][][test IO..•page testPth sidepath] +|**[Debug..log_before `sidepath2´+"{n} ...][][test IO..•page [shift (9cm,0)][]testPth sidepath2] diff --git a/examples/features/sliders.shape b/examples/features/sliders.shape index 515b03a9..b0c64e08 100644 --- a/examples/features/sliders.shape +++ b/examples/features/sliders.shape @@ -17,15 +17,16 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -•rand: [newRandom (•time)] +•rand: [Random..newRandom (•time)] -pth: @defaultunit:1%C | (0cm,0cm)>(^1)--(^~1.3)<(3cm,0cm)--(^~0.5)<(1cm,3cm)--cycle +pth: Geometry..@defaultunit:1%C | (0cm,0cm)>(^1)--(^~1.3)<(3cm,0cm)--(^~0.5)<(1cm,3cm)--cycle { - •page << [stroke pth] + IO..•page << [Graphics..stroke pth] - c0: [stroke [Geometry..circle 3bp]] - c1: [stroke [Geometry..circle 5bp]] + c0: [Graphics..stroke [Geometry..circle 3bp]] + c1: [Graphics..stroke [Geometry..circle 5bp]] test: \ t0 delta → ( @@ -34,21 +35,21 @@ pth: @defaultunit:1%C | (0cm,0cm)>(^1)--(^~1.3)<(3cm,0cm)--(^~0.5)<(1cm,3cm)--cy [[shift ([pth t0] + delta).p] c1] ) - •page << - [[range '0 '15].foldsl - \ p e •st → ( p & [test 40*[random1D •st] 20cm*[random1D •st]] ) + IO..•page << + [[Data..range '0 '15].foldsl + \ p e •st → ( p & [test 40*[Random..ball1D •st] 20cm*[Random..ball1D •st]] ) null •rand] } { - pth: @defaultunit:1%C | (4cm,0cm,0cm)>(5cm,0cm,1cm)--(3cm,1cm,0cm)<(7cm,0cm,2cm)--(5.5cm,1.5cm,~1cm)<(5cm,3cm,~1cm)--cycle + pth: Geometry..@defaultunit:1%C | (4cm,0cm,0cm)>(5cm,0cm,1cm)--(3cm,1cm,0cm)<(7cm,0cm,2cm)--(5.5cm,1.5cm,~1cm)<(5cm,3cm,~1cm)--cycle |** pth: [immerse [shift (4cm,0)] [] ../pth] - c0: [stroke [Geometry..circle 3bp]] - c1: [stroke [Geometry..circle 5bp]] + c0: [Graphics..stroke [Geometry..circle 3bp]] + c1: [Graphics..stroke [Geometry..circle 5bp]] - •page << view [] [stroke pth] + IO..•page << view [] [Graphics..stroke pth] test: \ t0 delta → ( @@ -57,9 +58,9 @@ pth: @defaultunit:1%C | (0cm,0cm)>(^1)--(^~1.3)<(3cm,0cm)--(^~0.5)<(1cm,3cm)--cy [[shift view [] ([pth t0] + delta).p] c1] ) - •page << - [[range '0 '15].foldsl - \ p e •st → ( p & [test 40*[random1D •st] 20cm*[random1D •st]] ) + IO..•page << + [[Data..range '0 '15].foldsl + \ p e •st → ( p & [test 40*[Random..ball1D •st] 20cm*[Random..ball1D •st]] ) null •rand] } diff --git a/examples/features/softmask.shape b/examples/features/softmask.shape index 3ce07318..719ca85a 100644 --- a/examples/features/softmask.shape +++ b/examples/features/softmask.shape @@ -20,18 +20,18 @@ r: 1cm -mask: @blendspace: DEVICE_GRAY | [tgroup - @blend: BLEND_LIGHTEN +mask: @blendspace: Traits..Device..GRAY | [Graphics..tgroup + @blend: Traits..Blend..LIGHTEN | - ( newGroup << @nonstroking:RGB_RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill - << @nonstroking:RGB_GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill - << @nonstroking:RGB_BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill + ( newGroup << @nonstroking:Traits..RGB..RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill + << @nonstroking:Traits..RGB..GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill + << @nonstroking:Traits..RGB..BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill ) ] -•page << [shift (1*5*r,0)] [] mask +IO..•page << [shift (1*5*r,0)] [] mask -•page << [clip @nonstroking:RGB_GREEN | [fill [bbox mask]] [alphamask mask] ] -•page << [shift (0,~1*5*r)] [] [clip @nonstroking:RGB_GREEN | [fill [bbox mask]] [luminositymask mask] ] -|**•page << [shift (0*4*r,1*5*r)] [] [clip @nonstroking:RGB_GREEN | [fill [bbox mask]] [luminositymask mask] ] -|**•page << ( @softmask:[alphamask mask] & @nonstroking:RGB_GREEN | [fill [bbox mask]] ) >> formxo >> [shift (1*4*r,1*5*r)] +IO..•page << [Graphics..clip @nonstroking:Traits..RGB..GREEN | [Graphics..fill [Layout..bbox mask]] [alphamask mask] ] +IO..•page << [shift (0,~1*5*r)] [] [Graphics..clip @nonstroking:Traits..RGB..GREEN | [Graphics..fill [Layout..bbox mask]] [luminositymask mask] ] +|**IO..•page << [shift (0*4*r,1*5*r)] [] [Graphics..clip @nonstroking:Traits..RGB..GREEN | [Graphics..fill [Layout..bbox mask]] [luminositymask mask] ] +|**IO..•page << ( @softmask:[alphamask mask] & @nonstroking:Traits..RGB..GREEN | [Graphics..fill [Layout..bbox mask]] ) >> formxo >> [shift (1*4*r,1*5*r)] diff --git a/examples/features/speedtest.shape b/examples/features/speedtest.shape index a82240a7..5390d445 100644 --- a/examples/features/speedtest.shape +++ b/examples/features/speedtest.shape @@ -30,17 +30,17 @@ pth: [rotate 1][][Geometry..circle 5cm] @width:0.1bp | { -•page << @stroking:RGB_RED|[stroke [controlling pth]] -•page << [stroke pth] +IO..•page << @stroking:Traits..RGB..RED|[Graphics..stroke [Geometry..controlling pth]] +IO..•page << [Graphics..stroke pth] -•page << [[range '1 '5].foldr +IO..•page << [[Data..range '1 '5].foldr \ p i → { t: 1 / i a: (pth.begin.p+pth.begin.T*pth.begin.v*t) p - & [stroke [pth t].p--a] - & [[shift a] (@stroking:RGB_BLUE|[stroke [Geometry..circle 1mm]])] - & [[shift a + (2mm,2mm)] [TeX [sprintf `$1/%d$´ i]]] + & [Graphics..stroke [pth t].p--a] + & [[shift a] (@stroking:Traits..RGB..BLUE|[Graphics..stroke [Geometry..circle 1mm]])] + & [[shift a + (2mm,2mm)] [Graphics..TeX [String..sprintf `$1/%d$´ i]]] } null] } diff --git a/examples/features/states.blank b/examples/features/states.blank index d4f3e71c..2a91efc2 100644 --- a/examples/features/states.blank +++ b/examples/features/states.blank @@ -21,8 +21,8 @@ /** Basic use of states includes defining new states, tacking on to them, and finally using the result. **/ -•str: newString -•msg: newString +•str: String..newString +•msg: String..newString •str << `Say´ << ` ´ •msg << `Say´ << ` ´ •str << `hello!´ @@ -39,7 +39,7 @@ str: •str; /** We can also peek at the state. This is a potentially expensive operation, depending on ** the implementation of this particular kind of state. **/ -•stdout << str << "{n} << (•msg) << "{n} +IO..•stdout << str << "{n} << (•msg) << "{n} /** The following is legal: **/ @@ -47,10 +47,10 @@ str: •str; /** States can also be created temporary without giving them names. This has the following syntax, - ** where newString is used to spawn the unnamed state. The state is frozen at the end of the + ** where String..newString is used to spawn the unnamed state. The state is frozen at the end of the ** insertion sequence within parentheses, and the final value is returned. **/ -•stdout << ( newString << `a ´ << `b´ << "{n} ) +IO..•stdout << ( String..newString << `a ´ << `b´ << "{n} ) /** Next, we turn to the scoping rules for lexical access of states. The rule is that states @@ -65,20 +65,20 @@ str: •str; **/ fun: \ a → { - •s: newString + •s: String..newString •s << a << `Hey!´ << a •s; } -•stdout << [fun `--´] << "{n} +IO..•stdout << [fun `--´] << "{n} -/** The following would be illegal, since •stdout is in the global environment, +/** The following would be illegal, since IO..•stdout is in the global environment, ** which is outside the function boundary. **/ |** badFun: \ a → |** { -|** •stdout << a +|** IO..•stdout << a |** `Hej!´ |** } @@ -91,4 +91,4 @@ fun: \ a → writeHello: \ •dst → { •dst << `Hello!´ << "{n} } -[writeHello •stdout] +[writeHello IO..•stdout ] diff --git a/examples/features/static_errors.blank b/examples/features/static_errors.blank index 7490bac6..cfff476d 100644 --- a/examples/features/static_errors.blank +++ b/examples/features/static_errors.blank @@ -18,12 +18,12 @@ ##lookin ..Shapes -•stdout << b << "{n} -•stdout << c << "{n} +IO..•stdout << b << "{n} +IO..•stdout << c << "{n} foo: \ a → { - •stdout << a + IO..•stdout << a } [foo 9] diff --git a/examples/features/streams.blank b/examples/features/streams.blank index b5e0f08c..c5cd929b 100644 --- a/examples/features/streams.blank +++ b/examples/features/streams.blank @@ -19,22 +19,22 @@ ##lookin ..Shapes /** -fibsFrom: \ n1 n2 → [cons n2 [fibsFrom n2 n1+n2]] +fibsFrom: \ n1 n2 → [Data..cons n2 [fibsFrom n2 n1+n2]] fib: [fibsFrom 0 1] **/ -streamadd: \ s1 s2 → [cons s1.car+s2.car [streamadd s1.cdr s2.cdr]] +streamadd: \ s1 s2 → [Data..cons s1.car+s2.car [streamadd s1.cdr s2.cdr]] nth: \ lst n → [if n = 0 lst.car [nth lst.cdr n-1]] -fib : [cons 0 [cons 1 [streamadd fib fib.cdr]]] +fib : [Data..cons 0 [Data..cons 1 [streamadd fib fib.cdr]]] -•stdout << [nth fib 0] << "{n} -•stdout << [nth fib 1] << "{n} -•stdout << [nth fib 2] << "{n} -•stdout << [nth fib 3] << "{n} +IO..•stdout << [nth fib 0] << "{n} +IO..•stdout << [nth fib 1] << "{n} +IO..•stdout << [nth fib 2] << "{n} +IO..•stdout << [nth fib 3] << "{n} @@ -42,12 +42,12 @@ fib : [cons 0 [cons 1 [streamadd fib fib.cdr]]] randoms: { - helper: \ •state → [cons [random1D •state] [helper •state]] + helper: \ •state → [Data..cons [Random..ball1D •state] [helper •state]] |** Remember that the state must be named like this; it cannot be generated as part of the expression below. - •rand: [newRandom (•time)] + •rand: [Random..newRandom (•time)] [helper •rand] } -•stdout << [nth randoms 0] << ` ´ << [nth randoms 1] << ` ´ << [nth randoms 2] << ` ´ << [nth randoms 3] << "{n} -•stdout << [nth randoms 0] << ` ´ << [nth randoms 1] << ` ´ << [nth randoms 2] << ` ´ << [nth randoms 3] << "{n} +IO..•stdout << [nth randoms 0] << ` ´ << [nth randoms 1] << ` ´ << [nth randoms 2] << ` ´ << [nth randoms 3] << "{n} +IO..•stdout << [nth randoms 0] << ` ´ << [nth randoms 1] << ` ´ << [nth randoms 2] << ` ´ << [nth randoms 3] << "{n} diff --git a/examples/features/strokes.shape b/examples/features/strokes.shape index 67b00074..a3ddb300 100644 --- a/examples/features/strokes.shape +++ b/examples/features/strokes.shape @@ -18,6 +18,6 @@ ##lookin ..Shapes -•page << [stroke (0cm,0cm)--(1cm,1cm)] -•page << @width:1mm & @dash:[dashpattern 1mm 1mm] | [stroke (0cm,1cm)--(1cm,0cm)] -•page << [stroke (0.5cm,0cm)--(0.5cm,1cm)] +IO..•page << [Graphics..stroke (0cm,0cm)--(1cm,1cm)] +IO..•page << @width:1mm & @dash:[dashpattern 1mm 1mm] | [Graphics..stroke (0cm,1cm)--(1cm,0cm)] +IO..•page << [Graphics..stroke (0.5cm,0cm)--(0.5cm,1cm)] diff --git a/examples/features/subpaths.shape b/examples/features/subpaths.shape index 04f9b929..6c0cee2a 100644 --- a/examples/features/subpaths.shape +++ b/examples/features/subpaths.shape @@ -17,44 +17,45 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -cstroke: \ pth → ( newGroup << @stroking:RGB_RED|[stroke [controlling pth]] << [stroke pth] ) +cstroke: \ pth → ( newGroup << @stroking:Traits..RGB..RED|[Graphics..stroke [Geometry..controlling pth]] << [Graphics..stroke pth] ) -|** •page << cstroke [] +|** IO..•page << cstroke [] |** { |** c: [Geometry..circle 3cm] |** [c 0.6]--[c 3.4] |** } -|** •page << +|** IO..•page << |** { |** c0: [Geometry..circle 3cm] >> [shift (4cm,0)] >> immerse |** c: c0.begin--[c0 3.5] -|** ( @stroking:RGB_BLUE | view [] [stroke c] ) +|** ( @stroking:Traits..RGB..BLUE | view [] [Graphics..stroke c] ) |** & |** [cstroke [view (+(~1cm,0cm,0cm))<[c 0.6]--[c 3.4]>(+(1cm,0cm,0cm))--cycle]] |** } -•page << +IO..•page << { c: [shift (4cm,0)] [] [Geometry..circle 3cm] - ( @stroking:RGB_BLUE | [stroke c] ) + ( @stroking:Traits..RGB..BLUE | [Graphics..stroke c] ) & [cstroke (0.5cm^)<[c 0.6]--[c 3.4]>(+(1cm,0))--cycle] } -•page << +IO..•page << { c: (0cm,0cm)>(1cm,0cm)--(1cm,1cm)<(0cm,1cm)>(~1cm,1cm)--(~1cm,2cm)<(0cm,2cm) - ( @stroking:RGB_BLUE | [stroke c] ) + ( @stroking:Traits..RGB..BLUE | [Graphics..stroke c] ) & [cstroke (0cm,~0.5cm)<[c 0.2]--[c 1.8]>(0cm,2.5cm)] } -•page << +IO..•page << { c: [shift (3cm,0)] [] (0cm,0cm)>(1cm,0cm)--(1%C^)<(0cm,1cm)>(1%C^1)--(~1cm,2cm)<(0cm,2cm) - ( @stroking:RGB_BLUE | [stroke c] ) + ( @stroking:Traits..RGB..BLUE | [Graphics..stroke c] ) & [cstroke (0cm,~0.5cm)<[c 0.2]--[c 1.8]>(0cm,2.5cm)] } diff --git a/examples/features/svg_path.shape b/examples/features/svg_path.shape index 95a89678..1101ef6b 100644 --- a/examples/features/svg_path.shape +++ b/examples/features/svg_path.shape @@ -18,7 +18,7 @@ ##lookin ..Shapes -pth: [svg_path multi:false singletons:false +pth: [Geometry..svg_path multi:false singletons:false d:`M 73.75,145.50C 73.75,145.50 84.51,146.38 84.51,146.38 84.51,146.38 125.22,146.38 125.22,146.38 125.22,146.38 122.31,163.82 122.31,163.82 @@ -96,5 +96,5 @@ pth: [svg_path multi:false singletons:false 185.99,211.80 181.63,231.29 180.18,262.40M 153.72,191.16M 154.59,192.03M 183.38,252.22 ´] -•stdout << `Length: ´ << [if [typeof pth]=§Path [abs pth] `(multi)´] << "{n} -•page << [stroke pth] +IO..•stdout << `Length: ´ << [if [typeof pth]=Data..Type..§Path [Numeric..Math..abs pth] `(multi)´] << "{n} +IO..•page << [Graphics..stroke pth] diff --git a/examples/features/tagtest.shape b/examples/features/tagtest.shape index bf5ff668..a59297bc 100644 --- a/examples/features/tagtest.shape +++ b/examples/features/tagtest.shape @@ -18,11 +18,11 @@ ##lookin ..Shapes -obj: ( newGroup << [stroke [Geometry..circle 2cm]] << [tag 'foo (0.5cm,1cm)] << [tag 'bar (~0.5cm,1cm)] ) +obj: ( newGroup << [Graphics..stroke [Geometry..circle 2cm]] << [Graphics..Tag..tag 'foo (0.5cm,1cm)] << [Graphics..Tag..tag 'bar (~0.5cm,1cm)] ) obj2: [shift (3cm,3cm)] [] obj -•page << obj << obj2 +IO..•page << obj << obj2 -•page << stroke [] [find obj 'foo]--[find obj2 'foo] -•page << stroke [] [find obj 'bar]--[find obj2 'bar] +IO..•page << stroke [] [Graphics..Tag..find obj 'foo]--[Graphics..Tag..find obj2 'foo] +IO..•page << stroke [] [Graphics..Tag..find obj 'bar]--[Graphics..Tag..find obj2 'bar] diff --git a/examples/features/textmodes.shape b/examples/features/textmodes.shape index e7878907..18e1589a 100644 --- a/examples/features/textmodes.shape +++ b/examples/features/textmodes.shape @@ -18,10 +18,10 @@ ##lookin ..Shapes -myFont: @text_font:FONT_HELVETICA & @text_size:2cm & @nonstroking:[gray 0.6] & @stroking:RGB_RED & @width:2bp +myFont: Text..@font:Text..Font..HELVETICA & Text..@size:2cm & @nonstroking:[gray 0.6] & @stroking:Traits..RGB..RED & @width:2bp ##unit dy = 12mm -•page << myFont & @text_rendering:[textmode stroke:true] | (newText << `Shapes´ ) -•page << myFont & @text_rendering:[textmode fill:true] | (newText << `Shapes´ ) >> [shift (0,~1dy)] -•page << myFont & @text_rendering:[textmode fill:true stroke:true] | (newText << `Shapes´ ) >> [shift (0,~2dy)] +IO..•page << myFont & Text..@rendering:[textmode stroke:true] | (Text..newText << `Shapes´ ) +IO..•page << myFont & Text..@rendering:[textmode fill:true] | (Text..newText << `Shapes´ ) >> [shift (0,~1dy)] +IO..•page << myFont & Text..@rendering:[textmode fill:true stroke:true] | (Text..newText << `Shapes´ ) >> [shift (0,~2dy)] diff --git a/examples/features/tiebreakers.shape b/examples/features/tiebreakers.shape index edac8252..c1e61907 100644 --- a/examples/features/tiebreakers.shape +++ b/examples/features/tiebreakers.shape @@ -17,16 +17,17 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf -square: \ r → [rectangle (~r,~r) (r,r)] +square: \ r → [Geometry..rectangle (~r,~r) (r,r)] -•zbuf << @nonstroking:[gray 0.3] | [fill [square 1cm] >> [shift (0cm,0cm)] >> immerse tiebreaker:0bp] -•zbuf << @nonstroking:[gray 0.7] | [fill [square 1cm] >> [shift (0.5cm,0.5cm)] >> immerse tiebreaker:1bp] +•zbuf << @nonstroking:[gray 0.3] | [Graphics..fill [square 1cm] >> [shift (0cm,0cm)] >> immerse tiebreaker:0bp] +•zbuf << @nonstroking:[gray 0.7] | [Graphics..fill [square 1cm] >> [shift (0.5cm,0.5cm)] >> immerse tiebreaker:1bp] -•zbuf << @nonstroking:[gray 0.3] | [fill [square 1cm] >> [shift (3cm,0cm)] >> immerse tiebreaker:1bp] -•zbuf << @nonstroking:[gray 0.7] | [fill [square 1cm] >> [shift (3.5cm,0.5cm)] >> immerse tiebreaker:0bp] +•zbuf << @nonstroking:[gray 0.3] | [Graphics..fill [square 1cm] >> [shift (3cm,0cm)] >> immerse tiebreaker:1bp] +•zbuf << @nonstroking:[gray 0.7] | [Graphics..fill [square 1cm] >> [shift (3.5cm,0.5cm)] >> immerse tiebreaker:0bp] zbuf: •zbuf; [view zbuf] diff --git a/examples/features/transforms.blank b/examples/features/transforms.blank index 5b27b9f7..467d92f9 100644 --- a/examples/features/transforms.blank +++ b/examples/features/transforms.blank @@ -18,9 +18,9 @@ ##lookin ..Shapes -tf: [affinetransform3D (1,2,~1) (3,4,4) (1,1,1) (~3.5cm,~4.5cm,1cm)] -•stdout << tf << "{n} +tf: [Geometry3D..affinetransform (1,2,~1) (3,4,4) (1,1,1) (~3.5cm,~4.5cm,1cm)] +IO..•stdout << tf << "{n} tfi: [inverse tf] -•stdout << tfi << "{n} -•stdout << tfi * tf << "{n} -•stdout << tf * tfi << "{n} +IO..•stdout << tfi << "{n} +IO..•stdout << tfi * tf << "{n} +IO..•stdout << tf * tfi << "{n} diff --git a/examples/features/unicode.blank b/examples/features/unicode.blank index 411419ad..596f30d3 100644 --- a/examples/features/unicode.blank +++ b/examples/features/unicode.blank @@ -20,5 +20,5 @@ π: 180° -•stdout << π << "{n} -•stdout << ∞ << "{n} +IO..•stdout << π << "{n} +IO..•stdout << ∞ << "{n} diff --git a/examples/features/units.shape b/examples/features/units.shape index 12561e08..ac23cdfe 100644 --- a/examples/features/units.shape +++ b/examples/features/units.shape @@ -21,9 +21,9 @@ ##unit turns = 360° ##unit feet = 12in -•stdout << `The value of pi is ´ << 0.5turns << "{n} +IO..•stdout << `The value of pi is ´ << 0.5turns << "{n} -•stdout << `One foot equals ´ << 1feet << "{n} +IO..•stdout << `One foot equals ´ << 1feet << "{n} /** Prevent empty output error. **/ @spot diff --git a/examples/features/upsample.shape b/examples/features/upsample.shape dissimilarity index 68% index 345e6fed..9915cb1e 100644 --- a/examples/features/upsample.shape +++ b/examples/features/upsample.shape @@ -1,126 +1,127 @@ -/** This file is part of Shapes. - ** - ** Shapes is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** any later version. - ** - ** Shapes is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Shapes. If not, see . - ** - ** Copyright 2008, 2010, 2014 Henrik Tidefelt - **/ - -##lookin ..Shapes - -pathpoints: -{ - helper: \ sl → [if sl.looped [list] [cons sl [helper sl+1]]] - \ pth → [helper pth.begin] -} - - -sstroke: \ pth → -( (@stroking:RGB_RED & @width:(0.5*@width) | [[pathpoints pth].foldl \ p sl → ( p & [stroke [shift sl.p][]( (sl.N*3*@width)--(sl.N*~3*@width) )] ) null]) - & - [stroke pth] -) - -cstroke: \ pth → -( - (@stroking:RGB_GREEN & @width:(2*@width) | [stroke [controlling pth]] ) - & - (@stroking:RGB_RED & @width:(0.5*@width) | [[pathpoints pth].foldl \ p sl → ( p & [stroke [shift sl.p][]( (sl.N*3*@width)--(sl.N*~3*@width) )] ) null]) - & - [stroke pth] -) - -{ - pth: (~2cm,0cm)<(0cm,0cm)>(2cm,~1cm)--(1cm,3cm)<(2cm,1cm)>(3cm,1cm) - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} - -{ - pth: [[shift (0,~2cm)] (0cm,0cm)>(~2cm,0.2cm)--(3cm,~0.2cm)<(2cm,0cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} -{ - pth: [[shift (0,~3cm)] (0cm,0cm)>(~2cm,0.2cm)--(3cm,0.2cm)<(2cm,0.1cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} -{ - pth: [[shift (0,~4cm)] (0cm,0cm)>(~2cm,0cm)--(3cm,0cm)<(2cm,0cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} - -{ - pth: [[shift (0,~7cm)] (~1cm,~0.5cm)--(2cm,1cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} - -{ - pth: [[shift (0,~10cm)] (~2cm,0cm)<(0cm,0cm)>(2cm,~1cm)--(1cm,3cm)<(2cm,1cm)>(3cm,1cm)--cycle] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} - -{ - pth: [[shift (0,~13cm)] [Geometry..circle 2cm]] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_bends 40° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} - -{ - pth: [[shift (0,~17cm)] (0cm,0cm)>(2.5cm^45°)--(2.5cm^135°)<(2cm,0cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} -{ - pth: [[shift (0,~19cm)] (0cm,0cm)>(2cm,2cm)--(0cm,2cm)<(2cm,0cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} -{ - pth: [[shift (0,~21cm)] (0cm,0cm)>(4cm^45°)--(4cm^135°)<(2cm,0cm)] - •page << [sstroke pth] - •page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] - •page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] - •page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] - •page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] -} +/** This file is part of Shapes. + ** + ** Shapes is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** any later version. + ** + ** Shapes is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Shapes. If not, see . + ** + ** Copyright 2008, 2010, 2014 Henrik Tidefelt + **/ + +##lookin ..Shapes +##lookin ..Shapes..Geometry + +pathpoints: +{ + helper: \ sl → [if sl.looped [Data..list] [Data..cons sl [helper sl+1]]] + \ pth → [helper pth.begin] +} + + +sstroke: \ pth → +( (@stroking:Traits..RGB..RED & @width:(0.5*@width) | [[pathpoints pth].foldl \ p sl → ( p & [Graphics..stroke [shift sl.p][]( (sl.N*3*@width)--(sl.N*~3*@width) )] ) null]) + & + [Graphics..stroke pth] +) + +cstroke: \ pth → +( + (@stroking:Traits..RGB..GREEN & @width:(2*@width) | [Graphics..stroke [Geometry..controlling pth]] ) + & + (@stroking:Traits..RGB..RED & @width:(0.5*@width) | [[pathpoints pth].foldl \ p sl → ( p & [Graphics..stroke [shift sl.p][]( (sl.N*3*@width)--(sl.N*~3*@width) )] ) null]) + & + [Graphics..stroke pth] +) + +{ + pth: (~2cm,0cm)<(0cm,0cm)>(2cm,~1cm)--(1cm,3cm)<(2cm,1cm)>(3cm,1cm) + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} + +{ + pth: [[shift (0,~2cm)] (0cm,0cm)>(~2cm,0.2cm)--(3cm,~0.2cm)<(2cm,0cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} +{ + pth: [[shift (0,~3cm)] (0cm,0cm)>(~2cm,0.2cm)--(3cm,0.2cm)<(2cm,0.1cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} +{ + pth: [[shift (0,~4cm)] (0cm,0cm)>(~2cm,0cm)--(3cm,0cm)<(2cm,0cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} + +{ + pth: [[shift (0,~7cm)] (~1cm,~0.5cm)--(2cm,1cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} + +{ + pth: [[shift (0,~10cm)] (~2cm,0cm)<(0cm,0cm)>(2cm,~1cm)--(1cm,3cm)<(2cm,1cm)>(3cm,1cm)--cycle] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} + +{ + pth: [[shift (0,~13cm)] [circle 2cm]] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_bends 40° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} + +{ + pth: [[shift (0,~17cm)] (0cm,0cm)>(2.5cm^45°)--(2.5cm^135°)<(2cm,0cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} +{ + pth: [[shift (0,~19cm)] (0cm,0cm)>(2cm,2cm)--(0cm,2cm)<(2cm,0cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} +{ + pth: [[shift (0,~21cm)] (0cm,0cm)>(4cm^45°)--(4cm^135°)<(2cm,0cm)] + IO..•page << [sstroke pth] + IO..•page << [cstroke [upsample_balance [shift (~5cm,0)][]pth]] + IO..•page << [sstroke [upsample_inflections [shift (5cm,0cm)][]pth]] + IO..•page << [sstroke [upsample_bends 60° [shift (10cm,0)][]pth]] + IO..•page << [sstroke [upsample_every 1cm [shift (15cm,0)][]pth]] +} diff --git a/examples/features/values.blank b/examples/features/values.blank index f61d2e52..d63a18f7 100644 --- a/examples/features/values.blank +++ b/examples/features/values.blank @@ -35,7 +35,7 @@ /** Note the special syntax used to call a function with the values expanded: **/ - •stdout << user [] <>[multi 5] << "{n} + IO..•stdout << user [] <>[multi 5] << "{n} } /** In the next example, some values are simply put in a certain order, and we combine this @@ -46,7 +46,7 @@ user: \ a1 a2 a3 a4 → 1000*a4 + 100*a1 + 10*a2 + a3 - •stdout << user [...] <>[multi 5] [] 9<< "{n} + IO..•stdout << user [...] <>[multi 5] [] 9<< "{n} } @@ -61,19 +61,19 @@ { •dst << 100*a1 + 10*a2 + a3 << "{n} } - [(user [...] <>bunch) •stdout] + [(user [...] <>bunch) IO..•stdout ] /** The following syntax might be supported in the future. For now, ** it is considered a risk of ambiguity to mix the two forms of ** function application. **/ -|** [user •stdout <>bunch] +|** [user IO..•stdout <>bunch] - •stdout << `Field access: a2 = ´ << bunch.a2 << "{n} + IO..•stdout << `Field access: a2 = ´ << bunch.a2 << "{n} /** By the way, parts that are not named cannot be accessed in a similar way. However, ** note that we can always to this: **/ - •stdout << `The first argument is: a1 = ´ << ( \ a1 a2 a3 → a1 ) [] <>bunch << "{n} + IO..•stdout << `The first argument is: a1 = ´ << ( \ a1 a2 a3 → a1 ) [] <>bunch << "{n} /** ... but note that this requires that we know the names of the named parts of , for ** otherwise there will be an error when the function is applied. **/ @@ -91,14 +91,14 @@ •out << `a = ´ << args.a << `, b = ´ << args.b << "{n} } - [foo •stdout b:2 a:1] + [foo IO..•stdout b:2 a:1] bar: \ •out a <> args → { •out << `a = ´ << a << `, b = ´ << args.b << `, c = ´ << args.c << "{n} } - [bar •stdout 0 c:2 b:1] + [bar IO..•stdout 0 c:2 b:1] /** Sinks themselves cannot be passed as a named argument. Hence, the name of the sink can be used without @@ -110,7 +110,7 @@ •out << `args = ´ << args.args << "{n} } - [boo •stdout args:7] + [boo IO..•stdout args:7] } /** Next, we turn to how parts of a structure can conveniently be given names in the local scope. @@ -127,7 +127,7 @@ /** Just like in a function call, we can receive the parts of a structure by order: **/ (< x y z >): bunch - •stdout << `x = ´ << x << `, y = ´ << y << `, z = ´ << z << "{n} + IO..•stdout << `x = ´ << x << `, y = ´ << y << `, z = ´ << z << "{n} } { @@ -139,7 +139,7 @@ **/ (< x y <> rest >): bunch (< z >): rest - •stdout << `From the sink, z = ´ << z << "{n} + IO..•stdout << `From the sink, z = ´ << z << "{n} } { @@ -147,7 +147,7 @@ **/ (< x y z w:14 >): bunch - •stdout << `w = ´ << w << "{n} + IO..•stdout << `w = ´ << w << "{n} } } @@ -171,7 +171,7 @@ y:.a2 >): bunch - •stdout << `x = ´ << x << `, y = ´ << y << "{n} + IO..•stdout << `x = ´ << x << `, y = ´ << y << "{n} } { @@ -179,7 +179,7 @@ ** as a low level syntax sugar. **/ (< a2:." a3:." >): bunch - •stdout << `a2 = ´ << a2 << `, a3 = ´ << a3 << "{n} + IO..•stdout << `a2 = ´ << a2 << `, a3 = ´ << a3 << "{n} } { @@ -187,7 +187,7 @@ **/ def: 1000 (< a2:." a4:.":def >): bunch - •stdout << `a2 = ´ << a2 << `, a4 = ´ << a4 << "{n} + IO..•stdout << `a2 = ´ << a2 << `, a4 = ´ << a4 << "{n} } } @@ -200,12 +200,12 @@ { (< x y:.a2 a3:." >): bunch - •stdout << `x = ´ << x << `, y = ´ << y << `, a3 = ´ << a3 << "{n} + IO..•stdout << `x = ´ << x << `, y = ´ << y << `, a3 = ´ << a3 << "{n} } { (< x y:1000 >): bunch - •stdout << `x = ´ << x << `, y = ´ << y << "{n} + IO..•stdout << `x = ´ << x << `, y = ´ << y << "{n} } } @@ -219,17 +219,17 @@ /** To see the relevance of discussing here, note that we may define a Scheme-like ** function like this: **/ - apply: \ fun args → ( fun [] <>[unlist args] ) + apply: \ fun args → ( fun [] <>[Data..unlist args] ) - •stdout << `Using apply to compute the sum of two values: ´ << [apply (+) [list 4 5]] << "{n} + IO..•stdout << `Using apply to compute the sum of two values: ´ << [apply (+) [Data..list 4 5]] << "{n} /** Let us now verify that it is the inverse of in the following senses: **/ - lst: [list 1 2 3] - showList: \ lst → [lst.foldl \ p e → ( p + ( newString << `(´ << e << `)´ ) ) `´] - •stdout << [showList lst] << ` vs ´ << [showList ( list [] <>[unlist lst] )] << "{n} + lst: [Data..list 1 2 3] + showList: \ lst → [lst.foldl \ p e → ( p + ( String..newString << `(´ << e << `)´ ) ) `´] + IO..•stdout << [showList lst] << ` vs ´ << [showList ( list [] <>[Data..unlist lst] )] << "{n} struct: (> 'a 'b 'c <) - showStruct: \ struct → (( \ x y z → ( newString << `(´ << x << `)´ << `(´ << y << `)´ << `(´ << z << `)´ )) [] <>struct) - •stdout << [showStruct struct] << ` vs ´ << [showStruct [unlist ( list [] <>struct )]] << "{n} + showStruct: \ struct → (( \ x y z → ( String..newString << `(´ << x << `)´ << `(´ << y << `)´ << `(´ << z << `)´ )) [] <>struct) + IO..•stdout << [showStruct struct] << ` vs ´ << [showStruct [Data..unlist ( Data..list [] <>struct )]] << "{n} } diff --git a/examples/features/warm.blank b/examples/features/warm.blank index 2c61c615..6743db69 100644 --- a/examples/features/warm.blank +++ b/examples/features/warm.blank @@ -18,20 +18,20 @@ ##lookin ..Shapes -•str: newString -•msg: newString +•str: String..newString +•msg: String..newString •str << `Say´ << ` ´ •msg << `Say´ << ` ´ •str << `hello!´ •msg << `goodbye!´ str: •str; msg: •msg; -•stdout << str << "{n} << msg << "{n} +IO..•stdout << str << "{n} << msg << "{n} -•stdout << ( newString << `a ´ << `b´ << "{n} ) +IO..•stdout << ( String..newString << `a ´ << `b´ << "{n} ) -•dst1: newString -•dst2: newString +•dst1: String..newString +•dst2: String..newString •dst1 << `1:´ •dst2 << `2:´ @@ -40,7 +40,7 @@ say_y: \ •dstStr → { •dstStr << `y´ } /** Dynamic states is currently not a supported feature. **/ -|** dynamic @dfoo I •stdout +|** dynamic @dfoo I IO..•stdout |** foo: \ → { @dfoo << ` x ´ [say_y (@dfoo <<)] } @@ -58,4 +58,4 @@ endline: \ •os → { •os << `(endl)´ << "{n} } dst1: •dst1; dst2: •dst2; -•stdout << dst1 << dst2 +IO..•stdout << dst1 << dst2 diff --git a/examples/features/warm2D.shape b/examples/features/warm2D.shape index 11fc9fe0..7dfe51e4 100644 --- a/examples/features/warm2D.shape +++ b/examples/features/warm2D.shape @@ -23,19 +23,19 @@ pth: (~1cm,0cm)--(0cm,1cm)--(1cm,0cm)--(0cm,~1cm)--cycle -•layer1 << @stroking:RGB_RED | [stroke pth] -•layer2 << [TeX `$\mathrm{d}u \wedge \mathrm{d}v$´] -•layer1 << @stroking:RGB_RED | [[shift (0.3cm,0.5cm)] [stroke pth]] -•layer2 << [[shift (0.3cm,~0.5cm)] @nonstroking:RGB_BLUE | [TeX `$\mathrm{d}u \wedge \mathrm{d}v$´]] +•layer1 << @stroking:Traits..RGB..RED | [Graphics..stroke pth] +•layer2 << [Graphics..TeX `$\mathrm{d}u \wedge \mathrm{d}v$´] +•layer1 << @stroking:Traits..RGB..RED | [[shift (0.3cm,0.5cm)] [Graphics..stroke pth]] +•layer2 << [[shift (0.3cm,~0.5cm)] @nonstroking:Traits..RGB..BLUE | [Graphics..TeX `$\mathrm{d}u \wedge \mathrm{d}v$´]] layer1: •layer1; layer2: •layer2; -•page << layer1 << layer2 +IO..•page << layer1 << layer2 -•page << [stroke [Geometry..circle 8mm]] +IO..•page << [Graphics..stroke [Geometry..circle 8mm]] -ballHead: \ pth → (> picture:[[shift pth.begin.p] [stroke [Geometry..circle 2mm]]] cut:1mm <) -tHead: \ pth → { z: pth.begin.p (> picture:[stroke (z+(0,2mm))--(z-(0,2mm))] cut:0mm <)} +ballHead: \ pth → (> picture:[[shift pth.begin.p] [Graphics..stroke [Geometry..circle 2mm]]] cut:1mm <) +tHead: \ pth → { z: pth.begin.p (> picture:[Graphics..stroke (z+(0,2mm))--(z-(0,2mm))] cut:0mm <)} -•page << @defaultunit:1%c | [stroke (~1cm,~1cm)--(^)<(1cm,0.5cm)>(^10°)--(^190°)<(1.2cm,0.9cm) head:Graphics..ShapesArrow tail:ballHead] +IO..•page << Geometry..@defaultunit:1%c | [Graphics..stroke (~1cm,~1cm)--(^)<(1cm,0.5cm)>(^10°)--(^190°)<(1.2cm,0.9cm) head:Graphics..ShapesArrow tail:ballHead] diff --git a/examples/features/winding-numbers-color.shape b/examples/features/winding-numbers-color.shape index 242e369b..a9813203 100644 --- a/examples/features/winding-numbers-color.shape +++ b/examples/features/winding-numbers-color.shape @@ -21,14 +21,14 @@ ##lookin ..Shapes intColor: \ i → [if i = '0 - RGB_GREEN + Traits..RGB..GREEN [if i = '1 [gray 0] - [if i = '2 RGB_YELLOW [error [sprintf `Winding number out of range in color function: %d´ i]]]]] + [if i = '2 Traits..RGB..YELLOW [error [String..sprintf `Winding number out of range in color function: %d´ i]]]]] cmd: \ pth → { - bb: [bbox @width:4mm | [stroke pth]] + bb: [Layout..bbox @width:4mm | [Graphics..stroke pth]] step: 1mm x1: [Layout..xmin bb] x2: [Layout..xmax bb] @@ -36,9 +36,9 @@ cmd: \ pth → y2: [Layout..ymax bb] @width:0.5*step | - [[range x1 x2 step].foldl - \ p x → [[range y1 y2 step].foldl - \ p y → p & (@stroking:[intColor [winding pth (x,y)]] | [spot (x,y)]) + [[Data..range x1 x2 step].foldl + \ p x → [[Data..range y1 y2 step].foldl + \ p y → p & (@stroking:[intColor [Geometry..winding pth (x,y)]] | [spot (x,y)]) p] null] } @@ -47,7 +47,7 @@ cmd: \ pth → @nonstroking: [gray 0.4] | { - •page << ( [cmd starPath] & starPathStroke ) + IO..•page << ( [cmd starPath] & starPathStroke ) << ( [cmd sameCircle] & sameCircleStroke ) >> [shift (3cm,0cm)] << ( [cmd alternatingCircle] & alternatingCircleStroke ) >> [shift (6cm,0cm)] } diff --git a/examples/features/zbufdemo.shape b/examples/features/zbufdemo.shape index 135db047..73588a44 100644 --- a/examples/features/zbufdemo.shape +++ b/examples/features/zbufdemo.shape @@ -17,27 +17,28 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D leaf: \ a → ( @nonstroking:[gray a / 360°] | - [rotate3D angle:a dir:(0,0,1)] [] [fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] + [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics..fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] ) -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf •zbuf << -[[range 0° 359° 120°].foldl +[[Data..range 0° 359° 120°].foldl \ p e → (p & [leaf e]) - null3D] + Graphics3D..null] -•zbuf << @nonstroking:[gray 0.3] | [fill (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] - << @nonstroking:[gray 0.7] | [fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] +•zbuf << @nonstroking:[gray 0.3] | [Graphics..fill (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] + << @nonstroking:[gray 0.7] | [Graphics..fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] zbuf: •zbuf; -tf: [rotate3D (1,0,0) 60°] -|**tf: [affinetransform3D (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] +tf: [Geometry3D..rotate (1,0,0) 60°] +|**tf: [Geometry3D..affinetransform (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] [view tf [] zbuf] diff --git a/examples/features/zbuflightdemo.shape b/examples/features/zbuflightdemo.shape index ea36cc07..108a8b3b 100644 --- a/examples/features/zbuflightdemo.shape +++ b/examples/features/zbuflightdemo.shape @@ -17,6 +17,7 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D facetProperties: @nonstroking:[gray 0.8] @@ -29,12 +30,12 @@ leaf: \ a → ( facetProperties | - [rotate3D angle:a dir:(0,0,1)] [] [facet (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,1.5cm)--cycle] + [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics3D..facet (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,1.5cm)--cycle] ) -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf -[[range 0° 359° 120°].foldsl +[[Data..range 0° 359° 120°].foldsl \ p e •st → { •st << [leaf e] p } void •zbuf] @@ -42,17 +43,17 @@ leaf: \ a → facetProperties | { - •zbuf << @nonstroking:[gray 0.2] | [facet [rectangle (~6cm,~5cm) (9cm,5.4cm)] >> immerse >> [shift (0cm,0cm,~1cm)]] + •zbuf << @nonstroking:[gray 0.2] | [Graphics3D..facet [Geometry..rectangle (~6cm,~5cm) (9cm,5.4cm)] >> immerse >> [shift (0cm,0cm,~1cm)]] } -•zbuf << facetProperties | [facet (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] - << facetProperties | [facet (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] +•zbuf << facetProperties | [Graphics3D..facet (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] + << facetProperties | [Graphics3D..facet (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] •zbuf << [shift (5cm,1cm,10cm)] [] [specular_light [gray 0.9]] zbuf: •zbuf; -tf: [rotate3D (1,0,0) 60°] -|**tf: [affinetransform3D (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] -•page << [view zbuf] +tf: [Geometry3D..rotate (1,0,0) 60°] +|**tf: [Geometry3D..affinetransform (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] +IO..•page << [view zbuf] diff --git a/examples/features/zbuflines.shape b/examples/features/zbuflines.shape index 0e070637..cae49d89 100644 --- a/examples/features/zbuflines.shape +++ b/examples/features/zbuflines.shape @@ -17,22 +17,23 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D leaf: \ a → ( @nonstroking:[gray a / 360°] | - [rotate3D angle:a dir:(0,0,1)] [] [fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] + [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics..fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] ) stick: \ a → ( @stroking:[gray a / 360°] | - [rotate3D angle:a dir:(0,0,1)] [] [stroke (1.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)] + [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics..stroke (1.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)] ) -•zbuf: newZBuf +•zbuf: Graphics3D..newZBuf •zbuf << [leaf 0°] •zbuf << [stick 120°] @@ -40,14 +41,14 @@ stick: \ a → { p: (3cm,0cm,0cm)--(7cm,0cm,2cm) - •zbuf << @nonstroking:[gray 0.7] | [fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] - << @nonstroking:[gray 0.3] | [stroke p] - << @nonstroking:[gray 0.3] | [shift (0.3cm,0cm,0cm)] [] [stroke [p 2.5cm].p--p.end.p] - << @nonstroking:[gray 0.3] | [shift (0.6cm,0cm,0cm)] [] [stroke p.begin.p--(p.end-1.8cm).p] - << @nonstroking:[gray 0.3] | [shift (0.9cm,0cm,0cm)] [] [stroke [p 2.0cm].p--(p.end-1.8cm).p] + •zbuf << @nonstroking:[gray 0.7] | [Graphics..fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] + << @nonstroking:[gray 0.3] | [Graphics..stroke p] + << @nonstroking:[gray 0.3] | [shift (0.3cm,0cm,0cm)] [] [Graphics..stroke [p 2.5cm].p--p.end.p] + << @nonstroking:[gray 0.3] | [shift (0.6cm,0cm,0cm)] [] [Graphics..stroke p.begin.p--(p.end-1.8cm).p] + << @nonstroking:[gray 0.3] | [shift (0.9cm,0cm,0cm)] [] [Graphics..stroke [p 2.0cm].p--(p.end-1.8cm).p] } -tf: [rotate3D (1,0,0) 60°] -|**tf: [affinetransform3D (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] +tf: [Geometry3D..rotate (1,0,0) 60°] +|**tf: [Geometry3D..affinetransform (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] zbuf: •zbuf; [view tf [] zbuf] diff --git a/examples/features/zsorterdemo.shape b/examples/features/zsorterdemo.shape index 5b28ebdc..df8fac3e 100644 --- a/examples/features/zsorterdemo.shape +++ b/examples/features/zsorterdemo.shape @@ -19,27 +19,28 @@ ##echo This example illustrates that a z sorter does a bad job with cyclic overlaps. ##lookin ..Shapes +##lookin ..Shapes..Geometry3D leaf: \ a → ( @nonstroking:[gray a / 360°] | - [rotate3D angle:a dir:(0,0,1)] [] [fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] + [Geometry3D..rotate angle:a dir:(0,0,1)] [] [Graphics..fill (0.5cm,~4cm,0cm)--(2.5cm,~4cm,0cm)--(1.5cm,5cm,0.5cm)--cycle] ) -•zbuf: newZSorter +•zbuf: Graphics3D..newZSorter •zbuf << -[[range 0° 359° 120°].foldl +[[Data..range 0° 359° 120°].foldl \ p e → p & [leaf e] - null3D] + Graphics3D..null] -•zbuf << @nonstroking:[gray 0.3] | [fill (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] - << @nonstroking:[gray 0.7] | [fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] +•zbuf << @nonstroking:[gray 0.3] | [Graphics..fill (3cm,~2cm,0cm)--(3cm,2cm,0cm)--(7cm,0cm,2cm)--cycle] + << @nonstroking:[gray 0.7] | [Graphics..fill (8cm,~1cm,0cm)--(8cm,1cm,0cm)--(4cm,0cm,2cm)--cycle] zbuf: •zbuf; -tf: [rotate3D (1,0,0) 60°] -|**tf: [affinetransform3D (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] +tf: [Geometry3D..rotate (1,0,0) 60°] +|**tf: [Geometry3D..affinetransform (0,4,7) (2,5,8) (3,6,9) (0cm,0cm,0cm)] [view tf [] zbuf] diff --git a/examples/misc/crazy.shape b/examples/misc/crazy.shape index c49643f3..beca3b70 100644 --- a/examples/misc/crazy.shape +++ b/examples/misc/crazy.shape @@ -23,7 +23,7 @@ dynamic @c identity 1 fun: \ a b → a + b + @c -•stdout << ( ( \ x → @c:(x|2*@c) ) [] @c:4 ) | [fun 1 2] +IO..•stdout << ( ( \ x → @c:(x|2*@c) ) [] @c:4 ) | [fun 1 2] @spot diff --git a/examples/misc/gustafblend.shape b/examples/misc/gustafblend.shape index b7907e0a..843b8839 100644 --- a/examples/misc/gustafblend.shape +++ b/examples/misc/gustafblend.shape @@ -20,13 +20,13 @@ r: 1cm -•page<< [shift (1*4*r,0*4*r)] [] - ( @blend: BLEND_DIFFERENCE +IO..•page<< [shift (1*4*r,0*4*r)] [] + ( @blend: Traits..Blend..DIFFERENCE & - @blendspace: DEVICE_RGB + @blendspace: Traits..Device..RGB | - ( newGroup << @nonstroking:RGB_RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill - << @nonstroking:RGB_GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill - << @nonstroking:RGB_BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill + ( newGroup << @nonstroking:Traits..RGB..RED | [Geometry..circle 1.2*r] >> [shift r*[dir 0*120°]] >> fill + << @nonstroking:Traits..RGB..GREEN | [Geometry..circle 1.2*r] >> [shift r*[dir 1*120°]] >> fill + << @nonstroking:Traits..RGB..BLUE | [Geometry..circle 1.2*r] >> [shift r*[dir 2*120°]] >> fill ) ) diff --git a/examples/misc/sphere.shape b/examples/misc/sphere.shape index c38e358f..43e2d69d 100644 --- a/examples/misc/sphere.shape +++ b/examples/misc/sphere.shape @@ -17,6 +17,7 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D S1: [[shift (0cm,0cm,1mm)][immerse [Geometry..circle 5cm]]] & [[shift (0cm,0cm,~1mm)][immerse [Geometry..circle 5cm]]] @@ -25,5 +26,5 @@ mv: [shift (~2cm,~4cm,0cm)] @eyez: 20cm | { - •page << [stroke [view [mv S1]]] << [stroke [view [mv*[rotate3D (1,0,0) 90°] S1]]] << [stroke [view [mv*[rotate3D (0,1,0) 90°] S1]]] + IO..•page << [Graphics..stroke [view [mv S1]]] << [Graphics..stroke [view [mv*[Geometry3D..rotate (1,0,0) 90°] S1]]] << [Graphics..stroke [view [mv*[Geometry3D..rotate (0,1,0) 90°] S1]]] } diff --git a/examples/problems/choose.shape b/examples/problems/choose.shape index eca6a9f8..08ffe569 100644 --- a/examples/problems/choose.shape +++ b/examples/problems/choose.shape @@ -4,11 +4,11 @@ choose: \ <> cases → (escape_continuation leave - [cases.foldr \ p e → [if [typeof e]≠§Void + [cases.foldr \ p e → [if [typeof e]≠Data..Type..§Void (escape_continue leave e) p ] void] ) -•stdout << [choose [if 1=2 3] [if '1='1 4] [if '3='3 [debuglog_before `Fel!´ 5]]] << "{n} +IO..•stdout << [choose [if 1=2 3] [if '1='1 4] [if '3='3 [Debug..log_before `Fel!´ 5]]] << "{n} diff --git a/examples/showcase/blendarrows.shape b/examples/showcase/blendarrows.shape index 7a98d2a6..9ce79518 100644 --- a/examples/showcase/blendarrows.shape +++ b/examples/showcase/blendarrows.shape @@ -20,13 +20,13 @@ ##unit u = 1cm -@blend: BLEND_MULTIPLY +@blend: Traits..Blend..MULTIPLY & @stroking: [gray 0.7] & @width:0.2u & -@defaultunit: 1%C +Geometry..@defaultunit: 1%C | { - •page << [stroke (0u,0u)>(^)--(^)<(1u,1u)>(^)--(^)<(0u,2.2u) head:[Graphics..ShapesArrow width:3 ...]] - •page << [stroke (1u,0u)>(^)--(^)<(0u,1u)>(^)--(^)<(1u,2u) head:[Graphics..ShapesArrow width:4 ...]] + IO..•page << [Graphics..stroke (0u,0u)>(^)--(^)<(1u,1u)>(^)--(^)<(0u,2.2u) head:[Graphics..ShapesArrow width:3 ...]] + IO..•page << [Graphics..stroke (1u,0u)>(^)--(^)<(0u,1u)>(^)--(^)<(1u,2u) head:[Graphics..ShapesArrow width:4 ...]] } diff --git a/examples/showcase/blockdrawdemo.shape b/examples/showcase/blockdrawdemo.shape index ccce6b4e..22e92aa2 100644 --- a/examples/showcase/blockdrawdemo.shape +++ b/examples/showcase/blockdrawdemo.shape @@ -36,57 +36,57 @@ hboxmargin1: 2mm | { -G1 : [putblockOrigin •page [longblock [TeX `$G_{1}$´]]] -F1 : [putblockFarLeft •page [longblock [TeX `Reg.{} 1´]] G1] +G1 : [putblockOrigin IO..•page [longblock [Graphics..TeX `$G_{1}$´]]] +F1 : [putblockFarLeft IO..•page [longblock [Graphics..TeX `Reg.{} 1´]] G1] -sz : [putblockVeryNearRight •page [splitdot] G1] +sz : [putblockVeryNearRight IO..•page [splitdot] G1] -G2 : [putblockNearRight •page [longblock [TeX `$G_{2}$´]] sz] -F2 : [putblockVeryFarLeft •page [longblock [TeX `Reg.{} 2´]] F1] +G2 : [putblockNearRight IO..•page [longblock [Graphics..TeX `$G_{2}$´]] sz] +F2 : [putblockVeryFarLeft IO..•page [longblock [Graphics..TeX `Reg.{} 2´]] F1] -sy : [putblockVeryNearRight •page [splitdot] G2] +sy : [putblockVeryNearRight IO..•page [splitdot] G2] -ty : [putblockFarRight •page pointpicture G2] +ty : [putblockFarRight IO..•page pointpicture G2] {tmp: [leftpoint F2 2 2] - p: [hhconnect •page [shift (~@blockspacefar,0)][]tmp tmp 0.5 0cm] - •page << [putlabelAbove [TeX `$\refsub{y}$´] (p.end -2mm).p 1] + p: [hhconnect IO..•page [shift (~@blockspacefar,0)][]tmp tmp 0.5 0cm] + IO..•page << [putlabelAbove [Graphics..TeX `$\refsub{y}$´] (p.end -2mm).p 1] } -{p : [hhconnect •page [rightpoint F2 2 2] [leftpoint F1 2 2] 0.5 0cm] - •page << [putlabelAbove [TeX `$\refsub{z}$´] [Layout..mspoint p 0 2mm] ~1]} +{p : [hhconnect IO..•page [rightpoint F2 2 2] [leftpoint F1 2 2] 0.5 0cm] + IO..•page << [putlabelAbove [Graphics..TeX `$\refsub{z}$´] [Layout..mspoint p 0 2mm] ~1]} -{p : [connect •page F1 G1] - •page << [putlabelAbove [TeX `$u$´] [Layout..mspoint p 0.5] 0]} -{p : [connect •page G1 G2] - •page << [putlabelAbove [TeX `$z$´] [Layout..mspoint p 0.5] 0]} +{p : [connect IO..•page F1 G1] + IO..•page << [putlabelAbove [Graphics..TeX `$u$´] [Layout..mspoint p 0.5] 0]} +{p : [connect IO..•page G1 G2] + IO..•page << [putlabelAbove [Graphics..TeX `$z$´] [Layout..mspoint p 0.5] 0]} -•page << [putlabelAbove [TeX `$y$´] [toppoint ty ] 1] +IO..•page << [putlabelAbove [Graphics..TeX `$y$´] [toppoint ty ] 1] -Ftot: [rectangle ([leftpoint F2].x-hboxmargin-@blockspaceverynear-2mm,[bottompoint F2].y-12mm) +Ftot: [Geometry..rectangle ([leftpoint F2].x-hboxmargin-@blockspaceverynear-2mm,[bottompoint F2].y-12mm) ([rightpoint F1].x+hboxmargin,[toppoint G1].y+6mm)] -•page << hstyle | [stroke Ftot] +IO..•page << hstyle | [Graphics..stroke Ftot] -•page << hstyle1 | - [stroke [rectangle ([leftpoint F1].x-hboxmargin-@blockspaceverynear,[bottompoint F1].y-7mm) +IO..•page << hstyle1 | + [Graphics..stroke [Geometry..rectangle ([leftpoint F1].x-hboxmargin-@blockspaceverynear,[bottompoint F1].y-7mm) ([rightpoint sz].x+hboxmargin,[toppoint F1].y+hboxmargin)]] -ignore [] [connect •page G2 ty] +ignore [] [connect IO..•page G2 ty] { tmpPth: [bbconnect •ignore sz F1 5mm] - z: [intersection tmpPth Ftot].p - ignore [] [vhconnect •page tmpPth.begin.p z] - ignore [] [hhconnect •page z [leftpoint F1 2 1] 1 @blockspaceverynear] + z: [Geometry..intersection tmpPth Ftot].p + ignore [] [vhconnect IO..•page tmpPth.begin.p z] + ignore [] [hhconnect IO..•page z [leftpoint F1 2 1] 1 @blockspaceverynear] } { tmpPth: [bbconnect •ignore sy F2 10mm] - z: [intersection tmpPth Ftot].p - ignore [] [vhconnect •page tmpPth.begin.p z] - ignore [] [hhconnect •page z [leftpoint F2 2 1] 1 @blockspaceverynear] + z: [Geometry..intersection tmpPth Ftot].p + ignore [] [vhconnect IO..•page tmpPth.begin.p z] + ignore [] [hhconnect IO..•page z [leftpoint F2 2 1] 1 @blockspaceverynear] } } diff --git a/examples/showcase/bonddemo.shape b/examples/showcase/bonddemo.shape dissimilarity index 66% index 2480fb9e..9dcd5a85 100644 --- a/examples/showcase/bonddemo.shape +++ b/examples/showcase/bonddemo.shape @@ -1,60 +1,60 @@ -/** This file is part of Shapes. - ** - ** Shapes is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** any later version. - ** - ** Shapes is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Shapes. If not, see . - ** - ** Copyright 2008, 2010, 2014 Henrik Tidefelt - **/ - -##needs ..Applications..Blockdraw - -##lookin ..Shapes -##lookin ..Applications..Blockdraw - -##unit u = 2cm - -@connectionlw: 0.6bp -| -{ - j1: [putblockOrigin •page [shift (1u,1u)] [] sjunction] - j2: [putblockOrigin •page [shift (2u,1u)] [] [gyjunction Layout..to_rt [TeX `$\mu$´]]] - j3: [putblockOrigin •page [shift (3u,1u)] [] sjunction] - j4: [putblockOrigin •page [shift (4u,1u)] [] [tfjunction Layout..to_rt [TeX `$r$´]]] - j5: [putblockOrigin •page [shift (5u,1u)] [] pjunction] - j6: [putblockOrigin •page [shift (5u,~0.5u)][] sjunction] - j7: [putblockOrigin •page [shift (5u,2u)] [] sjunction] - - •page << tbond [] [bgconnect j1 j2] - •page << hbond [] [bgconnect j2 j3] - •page << tbond [] [bgconnect j3 j4] - •page << tbond [] [bgconnect j4 j5] - •page << hbond [] [bgconnect j5 j6] - •page << tbond [] [bgconnect j5 j7] - - •page << tbond [] [terminalfrom •page j1 (1u,0u) [TeX `R: $\phi_{1}(\bullet)$´]] - •page << hbond [] [terminalfrom •page j1 (1u,2u) [TeX `I: $m_{1}$´]] - •page << hbond [] [terminalfrom •page j3 (3u,2u) [TeX `I: $m_{2}$´]] - •page << tbond [] [terminalfrom •page j3 ( [Layout..centerof j3]+1u*[dir ~120°] ) [TeX `R: $R_{2}$´]] - •page << tbond [] [terminalfrom •page j3 ( [Layout..centerof j3]+1u*[dir ~60°] ) [TeX `R: $R_{3}$´]] - •page << hbond [] [terminalto •page j6 ( [Layout..centerof j6]+(~1u,0u) ) [TeX `$S_{\mathrm{e}}$´]] - •page << hbond [] [terminalfrom •page j6 ( [Layout..centerof j6]+(1u,0u) ) [TeX `I: $m_{3}$´]] - •page << tbond [] [terminalfrom •page j7 (4u,2u) [TeX `C: $C_{1}$´]] - •page << tbond [] [terminalfrom •page j7 (6u,2u) [TeX `R: $R_{1}$´]] - - { - con: [terminalto •page j1 (0u,1u) [TeX `$S_{\mathrm{e}}$´]] - •page << hbond [] con - •page << [flowlabel con [TeX `f´]] - •page << [effortlabel con [TeX `e´]] - } -} +/** This file is part of Shapes. + ** + ** Shapes is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** any later version. + ** + ** Shapes is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Shapes. If not, see . + ** + ** Copyright 2008, 2010, 2014 Henrik Tidefelt + **/ + +##needs ..Applications..Blockdraw + +##lookin ..Shapes +##lookin ..Applications..Blockdraw + +##unit u = 2cm + +@connectionlw: 0.6bp +| +{ + j1: [putblockOrigin IO..•page [shift (1u,1u)] [] sjunction] + j2: [putblockOrigin IO..•page [shift (2u,1u)] [] [gyjunction Layout..to_rt [Graphics..TeX `$\mu$´]]] + j3: [putblockOrigin IO..•page [shift (3u,1u)] [] sjunction] + j4: [putblockOrigin IO..•page [shift (4u,1u)] [] [tfjunction Layout..to_rt [Graphics..TeX `$r$´]]] + j5: [putblockOrigin IO..•page [shift (5u,1u)] [] pjunction] + j6: [putblockOrigin IO..•page [shift (5u,~0.5u)][] sjunction] + j7: [putblockOrigin IO..•page [shift (5u,2u)] [] sjunction] + + IO..•page << tbond [] [bgconnect j1 j2] + IO..•page << hbond [] [bgconnect j2 j3] + IO..•page << tbond [] [bgconnect j3 j4] + IO..•page << tbond [] [bgconnect j4 j5] + IO..•page << hbond [] [bgconnect j5 j6] + IO..•page << tbond [] [bgconnect j5 j7] + + IO..•page << tbond [] [terminalfrom IO..•page j1 (1u,0u) [Graphics..TeX `R: $\phi_{1}(\bullet)$´]] + IO..•page << hbond [] [terminalfrom IO..•page j1 (1u,2u) [Graphics..TeX `I: $m_{1}$´]] + IO..•page << hbond [] [terminalfrom IO..•page j3 (3u,2u) [Graphics..TeX `I: $m_{2}$´]] + IO..•page << tbond [] [terminalfrom IO..•page j3 ( [Layout..centerof j3]+1u*[dir ~120°] ) [Graphics..TeX `R: $R_{2}$´]] + IO..•page << tbond [] [terminalfrom IO..•page j3 ( [Layout..centerof j3]+1u*[dir ~60°] ) [Graphics..TeX `R: $R_{3}$´]] + IO..•page << hbond [] [terminalto IO..•page j6 ( [Layout..centerof j6]+(~1u,0u) ) [Graphics..TeX `$S_{\mathrm{e}}$´]] + IO..•page << hbond [] [terminalfrom IO..•page j6 ( [Layout..centerof j6]+(1u,0u) ) [Graphics..TeX `I: $m_{3}$´]] + IO..•page << tbond [] [terminalfrom IO..•page j7 (4u,2u) [Graphics..TeX `C: $C_{1}$´]] + IO..•page << tbond [] [terminalfrom IO..•page j7 (6u,2u) [Graphics..TeX `R: $R_{1}$´]] + + { + con: [terminalto IO..•page j1 (0u,1u) [Graphics..TeX `$S_{\mathrm{e}}$´]] + IO..•page << hbond [] con + IO..•page << [flowlabel con [Graphics..TeX `f´]] + IO..•page << [effortlabel con [Graphics..TeX `e´]] + } +} diff --git a/examples/showcase/bracedemo.shape b/examples/showcase/bracedemo.shape index b93ae894..b23ee852 100644 --- a/examples/showcase/bracedemo.shape +++ b/examples/showcase/bracedemo.shape @@ -25,17 +25,17 @@ lMin: 1.5cm lMax: 10cm lSteps: '20 -•page << - [[range '0 lSteps].foldl +IO..•page << + [[Data..range '0 lSteps].foldl \ p e → { l: lMin+e*(lMax-lMin)/(lSteps-'1) br: [Graphics..someBrace (e*xStep,0cm) (e*xStep,l)] p & - [stroke br] + [Graphics..stroke br] |** & -|** ( @stroking:RGB_RED & @width:0.5bp | [stroke [controlling br]] ) +|** ( @stroking:Traits..RGB..RED & @width:0.5bp | [Graphics..stroke [Geometry..controlling br]] ) & ( fill [] (@width:1bp|[Graphics..someClosedBrace (e*xStep,lMax+lMin) (e*xStep,l)]) ) } diff --git a/examples/showcase/circuitdemo.shape b/examples/showcase/circuitdemo.shape index 6d587f6a..74568afd 100644 --- a/examples/showcase/circuitdemo.shape +++ b/examples/showcase/circuitdemo.shape @@ -25,31 +25,31 @@ ##lookin ..Applications..Blockdraw ##lookin ..Applications..Circuit -demoprefs & @defaultunit:1%c +demoprefs & Geometry..@defaultunit:1%c | { |** book preferences active -t1: [putblockOrigin •page [termcircle]] +t1: [putblockOrigin IO..•page [termcircle]] -r: [putblockNearRight •page [resistance] t1] -l: [putblockNearRight •page [inductance] r] -h: [putblockNearRight •page pointpicture l] -c: [putblockNearBelow •page [[rotate 90°] [capacitance]] h] +r: [putblockNearRight IO..•page [resistance] t1] +l: [putblockNearRight IO..•page [inductance] r] +h: [putblockNearRight IO..•page pointpicture l] +c: [putblockNearBelow IO..•page [[rotate 90°] [capacitance]] h] -t2: [putblockNearBelow •page [termcircle] c] +t2: [putblockNearBelow IO..•page [termcircle] c] -•page << [putlabelAbove [TeX `$R$´] [toppoint r] 0] -•page << [putlabelAbove [TeX `$L$´] [toppoint l] 0] -•page << [putlabelLeft [TeX `$C$´] [leftpoint c] 0] +IO..•page << [putlabelAbove [Graphics..TeX `$R$´] [toppoint r] 0] +IO..•page << [putlabelAbove [Graphics..TeX `$L$´] [toppoint l] 0] +IO..•page << [putlabelLeft [Graphics..TeX `$C$´] [leftpoint c] 0] @width:@connectionlw | { |** We don't wan't the usual arrowheads on the connections, so the implicitly drawn connection must be ignored. - •page << [stroke [connect •ignore t1 r]] - •page << [stroke [connect •ignore r l]] - •page << [stroke [connect •ignore l c]] - •page << [stroke [connect •ignore c t2]] + IO..•page << [Graphics..stroke [connect •ignore t1 r]] + IO..•page << [Graphics..stroke [connect •ignore r l]] + IO..•page << [Graphics..stroke [connect •ignore l c]] + IO..•page << [Graphics..stroke [connect •ignore c t2]] } } |** end of book preferences diff --git a/examples/showcase/fig2_11.shape b/examples/showcase/fig2_11.shape index 3c5aac27..1d6dce87 100644 --- a/examples/showcase/fig2_11.shape +++ b/examples/showcase/fig2_11.shape @@ -25,7 +25,7 @@ ##lookin ..Shapes ##lookin ..Applications..Blockdraw -demoprefs & @defaultunit:1%c +demoprefs & Geometry..@defaultunit:1%c | { @@ -43,25 +43,25 @@ r: 5mm inflow: \ •dst x1 x2 txt doValve → { d: [normalized x2 - x1] - •dst << [stroke (x1,y1+@pipe_width/2)--(x2-d*(r+@pipe_width/2),y1+@pipe_width/2)>(^[angle (d,0)])--(^90°)<(x2+d*@pipe_width/2,y1-@pipe_width/2-r)--(x2+d*@pipe_width/2,y2)] - •dst << [stroke (x1,y1-@pipe_width/2)--(x2-d*(r+@pipe_width/2),y1-@pipe_width/2)>(^[angle (d,0)])--(^90°)<(x2-d*@pipe_width/2,y1-@pipe_width/2-r)--(x2-d*@pipe_width/2,y2)] + •dst << [Graphics..stroke (x1,y1+@pipe_width/2)--(x2-d*(r+@pipe_width/2),y1+@pipe_width/2)>(^[angle (d,0)])--(^90°)<(x2+d*@pipe_width/2,y1-@pipe_width/2-r)--(x2+d*@pipe_width/2,y2)] + •dst << [Graphics..stroke (x1,y1-@pipe_width/2)--(x2-d*(r+@pipe_width/2),y1-@pipe_width/2)>(^[angle (d,0)])--(^90°)<(x2-d*@pipe_width/2,y1-@pipe_width/2-r)--(x2-d*@pipe_width/2,y2)] p: (x2-d*(r+7mm),y1)--(x2-d*(r+2mm),y1) - •dst <<[stroke p head:Graphics..ShapesArrow] - •dst << [[shift (x1+d*3mm,y1-@pipe_width/2-3mm)] [Layout..center [TeX txt] (0,1)]] + •dst <<[Graphics..stroke p head:Graphics..ShapesArrow] + •dst << [[shift (x1+d*3mm,y1-@pipe_width/2-3mm)] [Layout..center [Graphics..TeX txt] (0,1)]] •dst << [if doValve [[shift ([Layout..mediate 0.4 x1 x2],y1)]*[rotate 90°] [valve]] null] } -[inflow •page ~2.5cm tank_W/3 `Acid process flow´ false] -[inflow •page tank_W+2.5cm tank_W*2/3 `NaOH solution´ true] +[inflow IO..•page ~2.5cm tank_W/3 `Acid process flow´ false] +[inflow IO..•page tank_W+2.5cm tank_W*2/3 `NaOH solution´ true] -•page << @nonstroking: [gray 0.8] | - [fill (0cm,0cm)--(tank_W,0cm)--(tank_W,tank_L)--(0cm,tank_L)--cycle] +IO..•page << @nonstroking: [gray 0.8] | + [Graphics..fill (0cm,0cm)--(tank_W,0cm)--(tank_W,tank_L)--(0cm,tank_L)--cycle] { hdl: (3mm^45°) lambda: (tank_W) / 4 - •page << @width: 0.5bp & @dash: [dashpattern 3mm 1mm] | [stroke (0,tank_L)>hdl--(^)<(lambda,tank_L)>hdl--(^)<(2*lambda,tank_L)>hdl--(^)<(3*lambda,tank_L)>hdl--(^)<(4*lambda,tank_L)>hdl] + IO..•page << @width: 0.5bp & @dash: [dashpattern 3mm 1mm] | [Graphics..stroke (0,tank_L)>hdl--(^)<(lambda,tank_L)>hdl--(^)<(2*lambda,tank_L)>hdl--(^)<(3*lambda,tank_L)>hdl--(^)<(4*lambda,tank_L)>hdl] } { @@ -69,16 +69,16 @@ inflow: \ •dst x1 x2 txt doValve → xc: tank_W*0.5 yc: 5mm a: 60° - •page << [stroke (xc,y1+5mm)--(xc,yc)>(^a)--(^180°-a)<(xc+r,yc)>(^180°+a)--(^~a)<(xc,yc)>(^180°-a)--(^a)<(xc-r,yc)>(^~a)--(^180°+a)<(xc,yc)] + IO..•page << [Graphics..stroke (xc,y1+5mm)--(xc,yc)>(^a)--(^180°-a)<(xc+r,yc)>(^180°+a)--(^~a)<(xc,yc)>(^180°-a)--(^a)<(xc-r,yc)>(^~a)--(^180°+a)<(xc,yc)] } -•page << [stroke (0cm,tank_H)--(0cm,0cm)--(tank_W,0cm)--(tank_W,tank_H)] -•page << [stroke (tank_W/2,0cm)--(tank_W/2,~1.5cm)] -•page << [stroke (tank_W/2+@pipe_width,0cm)--(tank_W/2+@pipe_width,~1.5cm)] +IO..•page << [Graphics..stroke (0cm,tank_H)--(0cm,0cm)--(tank_W,0cm)--(tank_W,tank_H)] +IO..•page << [Graphics..stroke (tank_W/2,0cm)--(tank_W/2,~1.5cm)] +IO..•page << [Graphics..stroke (tank_W/2+@pipe_width,0cm)--(tank_W/2+@pipe_width,~1.5cm)] { p: (tank_W/2+@pipe_width/2,~5mm)--(tank_W/2+@pipe_width/2,~10mm) - •page << [stroke p head:Graphics..ShapesArrow] - •page << [putlabelRight [TeX `Flow with desired pH´] [p 0.5].p+(@pipe_width/2,0) 0] + IO..•page << [Graphics..stroke p head:Graphics..ShapesArrow] + IO..•page << [putlabelRight [Graphics..TeX `Flow with desired pH´] [p 0.5].p+(@pipe_width/2,0) 0] } } diff --git a/examples/showcase/fig2_2a.shape b/examples/showcase/fig2_2a.shape index 5d761471..794d95f7 100644 --- a/examples/showcase/fig2_2a.shape +++ b/examples/showcase/fig2_2a.shape @@ -21,26 +21,26 @@ ##lookin ..Shapes ##lookin ..Applications..Blockdraw -g1: [putblockOrigin •page [longblock [TeX `Amp´]]] -g2: [putblockNearRight •page [longblock [TeX `Motor´]] g1] -f: [putblockNearLeft •page [longblock [TeX `$K$´]] g1] -s: [putblockNearLeft •page [sumpicture] f] +g1: [putblockOrigin IO..•page [longblock [Graphics..TeX `Amp´]]] +g2: [putblockNearRight IO..•page [longblock [Graphics..TeX `Motor´]] g1] +f: [putblockNearLeft IO..•page [longblock [Graphics..TeX `$K$´]] g1] +s: [putblockNearLeft IO..•page [sumpicture] f] -sy: [putblockVeryNearRight •page [splitdot] g2] +sy: [putblockVeryNearRight IO..•page [splitdot] g2] -ty: [putblockFarRight •page pointpicture g2] -tr: [putblockFarLeft •page pointpicture s] +ty: [putblockFarRight IO..•page pointpicture g2] +tr: [putblockFarLeft IO..•page pointpicture s] -[ignore [connect •page tr s]] -•page << [leftpointsign s `+´] -{ p: [connect •page s f] - •page << [putlabelAbove [TeX `$e$´] [Layout..mspoint p 0.5] 0] } -{p: [connect •page f g1] - •page << [putlabelAbove [TeX `$u$´] [Layout..mspoint p 0.5] 0] } -[ignore [connect •page g1 g2]] -[ignore [connect •page g2 ty]] -[ignore [bbconnect •page sy s 0.5cm]] -•page << [bottompointsign s `-´] +[ignore [connect IO..•page tr s]] +IO..•page << [leftpointsign s `+´] +{ p: [connect IO..•page s f] + IO..•page << [putlabelAbove [Graphics..TeX `$e$´] [Layout..mspoint p 0.5] 0] } +{p: [connect IO..•page f g1] + IO..•page << [putlabelAbove [Graphics..TeX `$u$´] [Layout..mspoint p 0.5] 0] } +[ignore [connect IO..•page g1 g2]] +[ignore [connect IO..•page g2 ty]] +[ignore [bbconnect IO..•page sy s 0.5cm]] +IO..•page << [bottompointsign s `-´] -•page << [putlabelAbove [TeX `$r$´] [toppoint tr 1 1] ~1] -•page << [putlabelAbove [TeX `$y$´] [toppoint ty 1 1] 1] +IO..•page << [putlabelAbove [Graphics..TeX `$r$´] [toppoint tr 1 1] ~1] +IO..•page << [putlabelAbove [Graphics..TeX `$y$´] [toppoint ty 1 1] 1] diff --git a/examples/showcase/fourcolordie.shape b/examples/showcase/fourcolordie.shape index 8892d489..c4918920 100644 --- a/examples/showcase/fourcolordie.shape +++ b/examples/showcase/fourcolordie.shape @@ -17,6 +17,7 @@ **/ ##lookin ..Shapes +##lookin ..Shapes..Geometry3D r: 1cm z1: [immerse r*[dir 0°]] @@ -24,20 +25,20 @@ z2: [immerse r*[dir 120°]] z3: [immerse r*[dir ~120°]] z4: (0cm,0cm,(1.5++0.5)*r) -die: ( newGroup3D - << @nonstroking:RGB_RED | [fill z1--z2--z3--cycle] - << @nonstroking:RGB_GREEN | [fill z1--z2--z4--cycle] - << @nonstroking:RGB_BLUE | [fill z1--z3--z4--cycle] - << @nonstroking:RGB_YELLOW | [fill z2--z3--z4--cycle] ) +die: ( Graphics3D..newGroup + << @nonstroking:Traits..RGB..RED | [Graphics..fill z1--z2--z3--cycle] + << @nonstroking:Traits..RGB..GREEN | [Graphics..fill z1--z2--z4--cycle] + << @nonstroking:Traits..RGB..BLUE | [Graphics..fill z1--z3--z4--cycle] + << @nonstroking:Traits..RGB..YELLOW | [Graphics..fill z2--z3--z4--cycle] ) -•rand: [newRandom (•time)] +•rand: [Random..newRandom (•time)] world: - [[range '1 '5].foldsl + [[Data..range '1 '5].foldsl \ pile e •st → pile & - ( [shift 5*r*[random3D •st]]*[rotate3D dir:[random3D •st] angle:180°*[random1D •st]] [] die ) - null3D + ( [shift 5*r*[Random..ball3D •st]]*[Geometry3D..rotate dir:[Random..ball3D •st] angle:180°*[Random..ball1D •st]] [] die ) + Graphics3D..null •rand] -view [] ( newZBuf << world ) +view [] ( Graphics3D..newZBuf << world ) diff --git a/examples/showcase/kjmrobot.shape b/examples/showcase/kjmrobot.shape index f5e1debf..e6fe04ac 100644 --- a/examples/showcase/kjmrobot.shape +++ b/examples/showcase/kjmrobot.shape @@ -31,14 +31,15 @@ ##needs ..Shapes..Graphics3D / metapostarrow ##lookin ..Shapes +##lookin ..Shapes..Geometry3D ##unit u = 1cm cylinderLid: \ radius height sides smallRadius → - [shift (0cm,0cm,height)] [] ( newGroup3D << [facet [immerse [Graphics..polyDisc radius sides]]] - << [stroke [immerse [Graphics..polyDisc radius sides]]] - << @nonstroking:[gray 0.3] | [facet [immerse [Graphics..polyDisc smallRadius sides]] tiebreaker:1bp] + [shift (0cm,0cm,height)] [] ( Graphics3D..newGroup << [Graphics3D..facet [immerse [Graphics..polyDisc radius sides]]] + << [Graphics..stroke [immerse [Graphics..polyDisc radius sides]]] + << @nonstroking:[gray 0.3] | [Graphics3D..facet [immerse [Graphics..polyDisc smallRadius sides]] tiebreaker:1bp] ) |** First object to be defined is a joint. @@ -56,7 +57,7 @@ jointSurface: jointSides: '30 -joint: jointSurface | ( newGroup3D << [shift (0m,0m,~jointThickness)] [] [Graphics3D..cylinderWall jointRadius 2*jointThickness jointSides] +joint: jointSurface | ( Graphics3D..newGroup << [shift (0m,0m,~jointThickness)] [] [Graphics3D..cylinderWall jointRadius 2*jointThickness jointSides] << [cylinderLid jointRadius ~jointThickness jointSides 0.3*jointRadius] << [cylinderLid jointRadius jointThickness jointSides 0.3*jointRadius] ) @@ -68,43 +69,43 @@ armPath: \ tfStart tfEnd → { pStart: tfStart [] (0u,0u,0u) pEnd: tfEnd [] (0u,0u,0u) - hr: 0.4 * [abs pEnd - pStart] + hr: 0.4 * [Numeric..Math..abs pEnd - pStart] - pStart > [tfStart [rotate3D (0,0,1) ~armTwist] [] (hr,0u,0u)] + pStart > [tfStart [Geometry3D..rotate (0,0,1) ~armTwist] [] (hr,0u,0u)] -- - [tfEnd [rotate3D (0,0,1) armTwist] [] (~hr,0u,0u)] < pEnd + [tfEnd [Geometry3D..rotate (0,0,1) armTwist] [] (~hr,0u,0u)] < pEnd } edgyCylinder: \ pth0 pth1 → -[if [duration pth0] ≠ [duration pth1] +[if [Geometry..duration pth0] ≠ [Geometry..duration pth1] [error `edgyCylinder: Paths don't have the same duration.´] { - •res: newGroup3D + •res: Graphics3D..newGroup •res << - [[range '0 [duration pth0]-'1].foldl + [[Data..range '0 [Geometry..duration pth0]-'1].foldl \ p e → p & - ( [facet [pth0 e*1].p--[pth0 (e+'1)*1].p--[pth1 (e+'1)*1].p--cycle] ) + ( [Graphics3D..facet [pth0 e*1].p--[pth0 (e+'1)*1].p--[pth1 (e+'1)*1].p--cycle] ) & - ( [facet [pth0 e*1].p--[pth1 (e+'1)*1].p--[pth1 e*1].p--cycle] ) - null3D] + ( [Graphics3D..facet [pth0 e*1].p--[pth1 (e+'1)*1].p--[pth1 e*1].p--cycle] ) + Graphics3D..null] •res << - [[range '0 [duration pth0]].foldl + [[Data..range '0 [Geometry..duration pth0]].foldl \ p e → - p & [stroke [pth0 e*1].p--[pth1 e*1].p] - null3D] + p & [Graphics..stroke [pth0 e*1].p--[pth1 e*1].p] + Graphics3D..null] •res; }] paintArm: \ pth width height steps → { - lStep: [abs pth] / steps + lStep: [Numeric..Math..abs pth] / steps - [[range '0 steps-'1].foldl + [[Data..range '0 steps-'1].foldl \ p e → p & @@ -127,14 +128,14 @@ paintArm: \ pth width height steps → [edgyCylinder pth0 pth1] } - null3D] + Graphics3D..null] } myArrowHead: [Graphics3D..MetaPostArrow ahLength:8bp ...] frameArrows: { - •res: newGroup3D + •res: Graphics3D..newGroup l: 2u @@ -142,17 +143,17 @@ frameArrows: y: (0m,l,0m) z: (0m,0m,l) - •res << [tag 'x x] - << [tag 'y y] - << [tag 'z z] + •res << [Graphics..Tag..tag 'x x] + << [Graphics..Tag..tag 'y y] + << [Graphics..Tag..tag 'z z] - @stroking:RGB_BLUE - & @nonstroking:RGB_BLUE + @stroking:Traits..RGB..BLUE + & @nonstroking:Traits..RGB..BLUE | { - •res << [stroke (0m,0m,0m)--x head:[myArrowHead (0,~1,0) ...]] - •res << [stroke (0m,0m,0m)--y head:[myArrowHead (0,0,1) ...]] - •res << [stroke (0m,0m,0m)--z head:[myArrowHead (0,~1,0) ...]] + •res << [Graphics..stroke (0m,0m,0m)--x head:[myArrowHead (0,~1,0) ...]] + •res << [Graphics..stroke (0m,0m,0m)--y head:[myArrowHead (0,0,1) ...]] + •res << [Graphics..stroke (0m,0m,0m)--z head:[myArrowHead (0,~1,0) ...]] } •res; @@ -192,32 +193,32 @@ theta2: 0° |** Never actually seen. ** needed to draw the machinery (besides being used to define the downstream frames). ** The difference between adjacent tf_u and tf_d is thus only a shift in the z-direction. **/ -tf0d: [rotate3D (1,0,0) ~75°] * [rotate3D (0,0,1) ~20°] -tf1u: tf0d * [shift (a0,0u,0u)] * [rotate3D (1,0,0) alpha0] * [shift (0u,0u,d1-jointYSeparation)] -tf1d: tf1u * [shift (0u,0u,jointYSeparation)] * [rotate3D (0,0,1) theta1] -tf2u: tf1d * [shift (a1,0u,0u)] * [rotate3D (1,0,0) alpha1] * [shift (0u,0u,d2-jointYSeparation)] -tf2d: tf2u * [shift (0u,0u,jointYSeparation)] * [rotate3D (0,0,1) theta2] +tf0d: [Geometry3D..rotate (1,0,0) ~75°] * [Geometry3D..rotate (0,0,1) ~20°] +tf1u: tf0d * [shift (a0,0u,0u)] * [Geometry3D..rotate (1,0,0) alpha0] * [shift (0u,0u,d1-jointYSeparation)] +tf1d: tf1u * [shift (0u,0u,jointYSeparation)] * [Geometry3D..rotate (0,0,1) theta1] +tf2u: tf1d * [shift (a1,0u,0u)] * [Geometry3D..rotate (1,0,0) alpha1] * [shift (0u,0u,d2-jointYSeparation)] +tf2d: tf2u * [shift (0u,0u,jointYSeparation)] * [Geometry3D..rotate (0,0,1) theta2] frame0: tf0d [] frameArrows frame1: tf1d [] frameArrows |** This is the part of the picture where the machinery is drawn. -•zbuf: newZSorter +•zbuf: Graphics3D..newZSorter •zbuf << [shift (0cm,0cm,10cm)] [] [specular_light [gray 0.9]] •zbuf << [ambient_light [gray 0.3]] |** Annotations to be placed on top of the z-buffer goes here. -•zbufAnnot: newGroup3D +•zbufAnnot: Graphics3D..newGroup |** This is the part of the picture where parameters are shown. -•pbuf: newGroup3D +•pbuf: Graphics3D..newGroup •zbuf << tf0d [] joint •zbuf << tf1u [] joint -•zbufAnnot << @nonstroking:GRAY_WHITE | tf1u [] [facing [Layout..center [TeX `\small Link $i$´] (0,2)]] +•zbufAnnot << @nonstroking:Traits..BW..WHITE | tf1u [] [facing [Layout..center [Graphics..TeX `\small Link $i$´] (0,2)]] •zbuf << tf1d [] joint •zbuf << tf2u [] joint -•zbufAnnot << @nonstroking:GRAY_WHITE | tf2u [] [facing [Layout..center [TeX `\small Link $i+1$´] (0,1.2)]] +•zbufAnnot << @nonstroking:Traits..BW..WHITE | tf2u [] [facing [Layout..center [Graphics..TeX `\small Link $i+1$´] (0,1.2)]] •zbuf << jointSurface | [paintArm [armPath tf0d tf1u] 0.5*jointRadius 0.2*jointRadius '10] •zbuf << jointSurface | [paintArm [armPath tf1d tf2u] 0.5*jointRadius 0.2*jointRadius '10] @@ -230,23 +231,23 @@ axis1: tf1d [] (0u,0u,0u)--(0u,0u,~5*jointThickness) axis2: tf2d [] (0u,0u,0u)--(0u,0u,~5*jointThickness) -•zbuf << @stroking:RGB_RED | [stroke axis0] +•zbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis0] •zbuf << frame0 -•zbuf << @stroking:RGB_RED | [stroke axis1] +•zbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis1] •zbuf << frame1 -•zbuf << @stroking:RGB_RED | [stroke axis2] +•zbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis2] -•pbuf << @stroking:RGB_RED | [stroke axis0] +•pbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis0] •pbuf << frame0 -•pbuf << [shift [find frame0 'x]] [] [facing [Layout..center_wlm [TeX `$x_{i-1}$´] (0,~1)]] -•pbuf << [shift [find frame0 'y]] [] [facing [Layout..center_wlm [TeX `$y_{i-1}$´] (0,~1)]] -•pbuf << [shift [find frame0 'z]] [] [facing [Layout..center_wlm [TeX `$z_{i-1}$´] (1,0)]] -•pbuf << @stroking:RGB_RED | [stroke axis1] +•pbuf << [shift [Graphics..Tag..find frame0 'x]] [] [facing [Layout..center_wlm [Graphics..TeX `$x_{i-1}$´] (0,~1)]] +•pbuf << [shift [Graphics..Tag..find frame0 'y]] [] [facing [Layout..center_wlm [Graphics..TeX `$y_{i-1}$´] (0,~1)]] +•pbuf << [shift [Graphics..Tag..find frame0 'z]] [] [facing [Layout..center_wlm [Graphics..TeX `$z_{i-1}$´] (1,0)]] +•pbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis1] •pbuf << frame1 -•pbuf << [shift [find frame1 'x]] [] [facing [Layout..center_wlm [TeX `$x_{i}$´] (0,~1)]] -•pbuf << [shift [find frame1 'y]] [] [facing [Layout..center_wlm [TeX `$y_{i}$´] (1,0)]] -•pbuf << [shift [find frame1 'z]] [] [facing [Layout..center_wlm [TeX `$z_{i}$´] (1,0)]] -•pbuf << @stroking:RGB_RED | [stroke axis2] +•pbuf << [shift [Graphics..Tag..find frame1 'x]] [] [facing [Layout..center_wlm [Graphics..TeX `$x_{i}$´] (0,~1)]] +•pbuf << [shift [Graphics..Tag..find frame1 'y]] [] [facing [Layout..center_wlm [Graphics..TeX `$y_{i}$´] (1,0)]] +•pbuf << [shift [Graphics..Tag..find frame1 'z]] [] [facing [Layout..center_wlm [Graphics..TeX `$z_{i}$´] (1,0)]] +•pbuf << @stroking:Traits..RGB..RED | [Graphics..stroke axis2] @width: 0.5bp | { @@ -256,7 +257,7 @@ axis2: tf2d [] (0u,0u,0u)--(0u,0u,~5*jointThickness) |** This is the distance $a_{i-1}$ along with angle marks. pth: tf0d [] ( (0u,0u,0u)--(a0,0u,0u) ) •pbuf << stroke [] pth - •pbuf << [shift [pth 0.5*[abs pth]].p] [] [facing [Layout..center_wlm [TeX `$a_{i-1}$´] (0,1)]] + •pbuf << [shift [pth 0.5*[Numeric..Math..abs pth]].p] [] [facing [Layout..center_wlm [Graphics..TeX `$a_{i-1}$´] (0,1)]] •pbuf << stroke [] [myRightAnglePath [tf0d (0u,0u,0u)] [axis0 0].T [pth 0].T] •pbuf << stroke [] [myRightAnglePath [tf0d (a0,0u,0u)] [axis1 0].T [pth 1].rT] } @@ -264,7 +265,7 @@ axis2: tf2d [] (0u,0u,0u)--(0u,0u,~5*jointThickness) |** This is the distance $a_{i}$ along with angle marks. pth: tf1d [] ( (0u,0u,0u)--(a1,0u,0u) ) •pbuf << stroke [] pth - •pbuf << [shift [pth 0.5*[abs pth]].p] [] [facing [Layout..center_wlm [TeX `$a_{i}$´] (0,1)]] + •pbuf << [shift [pth 0.5*[Numeric..Math..abs pth]].p] [] [facing [Layout..center_wlm [Graphics..TeX `$a_{i}$´] (0,1)]] •pbuf << stroke [] [myRightAnglePath [tf1d (0u,0u,0u)] [axis1 0].T [pth 0].T] •pbuf << stroke [] [myRightAnglePath [tf1d (a1,0u,0u)] [axis2 0].T [pth 1].rT] @@ -278,20 +279,20 @@ axis2: tf2d [] (0u,0u,0u)--(0u,0u,~5*jointThickness) arc: tf1d*[shift (0u,0u,~d1)] [] [immerse (angleR*[dir ~theta1])>(1%c^90°-theta1)--(1%c^~90°)<(angleR,0)] •pbuf << myDash | stroke [] helper1 •pbuf << myDash | stroke [] helper2 - •pbuf << [stroke arc head:[Graphics3D..MetaPostArrow (0,0,1) ahLength:5bp ...]] - •pbuf << [shift [arc 0.5*[abs arc]].p] [] [facing [Layout..center_wlm [TeX `$\theta_{i}$´] (~1,0)]] + •pbuf << [Graphics..stroke arc head:[Graphics3D..MetaPostArrow (0,0,1) ahLength:5bp ...]] + •pbuf << [shift [arc 0.5*[Numeric..Math..abs arc]].p] [] [facing [Layout..center_wlm [Graphics..TeX `$\theta_{i}$´] (~1,0)]] } { |** This is the angle $\alpha_{i-1}$ along helpers and angle marks. helper: [shift [tf0d (0u,0u,0u)]] [] ( (0u,0u,0u)--((angleR+angleExtra)*[axis1 0].T) ) |** At the moment, the easy way to define circular arcs in 3D is to immerse a 2D arc. - arc: tf0d*[rotate3D (0,0,1) 90°]*[rotate3D (1,0,0) 90°] [] [immerse (0,~angleR)>(1%c^0°)--(1%c^180°+alpha0)<(angleR*[dir ~90°+alpha0])] + arc: tf0d*[Geometry3D..rotate (0,0,1) 90°]*[Geometry3D..rotate (1,0,0) 90°] [] [immerse (0,~angleR)>(1%c^0°)--(1%c^180°+alpha0)<(angleR*[dir ~90°+alpha0])] •pbuf << myDash | stroke [] helper - •pbuf << [stroke arc head:[Graphics3D..MetaPostArrow [axis1 0].T ahLength:5bp ...]] - •pbuf << [shift [arc 0.5*[abs arc]].p] [] [facing [Layout..center_wlm [TeX `$\alpha_{i-1}$´] (~1,1)]] + •pbuf << [Graphics..stroke arc head:[Graphics3D..MetaPostArrow [axis1 0].T ahLength:5bp ...]] + •pbuf << [shift [arc 0.5*[Numeric..Math..abs arc]].p] [] [facing [Layout..center_wlm [Graphics..TeX `$\alpha_{i-1}$´] (~1,1)]] } } -•pbuf << [shift 0.5 * ([tf0d (a0,0u,0u)] + [tf1d (0u,0u,0u)])] [] [facing [Layout..center_wlm [TeX `$d_{i}$´] (~1,0)]] +•pbuf << [shift 0.5 * ([tf0d (a0,0u,0u)] + [tf1d (0u,0u,0u)])] [] [facing [Layout..center_wlm [Graphics..TeX `$d_{i}$´] (~1,0)]] zbuf: •zbuf; zbufAnnot: •zbufAnnot; @@ -301,7 +302,7 @@ pbuf: •pbuf; @eyez:40u | { - •page << [view zbuf] + IO..•page << [view zbuf] << [view zbufAnnot] - •page << [shift (0,~5u)] [] [view pbuf] + IO..•page << [shift (0,~5u)] [] [view pbuf] } diff --git a/examples/showcase/koch.shape b/examples/showcase/koch.shape index 25650b95..a45f575f 100644 --- a/examples/showcase/koch.shape +++ b/examples/showcase/koch.shape @@ -32,7 +32,7 @@ koch: \ pth depth → [if depth = '0 pth { - len: [abs pth] + len: [Numeric..Math..abs pth] sl1: [pth len / 3] sl2: [pth 2 * len / 3] seg1: pth.begin--sl1 @@ -48,17 +48,17 @@ koch: \ pth depth → |** Here's our first simple application to a straight line: -•page << @width:0.3bp | [stroke [koch (0cm,0cm)--(15cm,10cm) '6]] +IO..•page << @width:0.3bp | [Graphics..stroke [koch (0cm,0cm)--(15cm,10cm) '6]] |** As a more advanced application, we start from a circle, and draw also the curves at intermediate depths, in successively darker shades of gray: -•page << { +IO..•page << { c: [shift (5cm,~10cm)][][Geometry..circle 5cm] end: '5 [accumulateGraphics2D - [range '0 end] - \ i → ( @stroking:[Layout..mediate i*(1/end) 0.9*GRAY_WHITE GRAY_BLACK] + [Data..range '0 end] + \ i → ( @stroking:[Layout..mediate i*(1/end) 0.9*Traits..BW..WHITE Traits..BW..BLACK] | - [stroke [koch c i]] ) ] + [Graphics..stroke [koch c i]] ) ] } diff --git a/examples/showcase/mergepaths.shape b/examples/showcase/mergepaths.shape index a5497d1e..06c5c0f7 100644 --- a/examples/showcase/mergepaths.shape +++ b/examples/showcase/mergepaths.shape @@ -31,20 +31,20 @@ pathpoint: \ p t → >(+[speed p t]*[direction p t]) mergepaths: \ p1 p2 → - [if [duration p1]>1 - { t:([duration p1]-1) [subpath p1 0 t]>(+[speed p1 t]*[direction p1 t]) } + [if [Geometry..duration p1]>1 + { t:([Geometry..duration p1]-1) [subpath p1 0 t]>(+[speed p1 t]*[direction p1 t]) } [pathpoint p1 0]] -- (+[reversespeed p1 ∞]*[reversedirection p1 ∞])< ( 0.5 * ( [point p1 ∞] + [point p2 0] ) ) >(+[speed p2 0]*[direction p2 0]) -- - [if [duration p2]>1 + [if [Geometry..duration p2]>1 (+[reversespeed p 1]*[reversedirection p 1])<[subpath p2 1 ∞] [pathpoint p2 ∞]] **/ -@defaultunit: 1%c +Geometry..@defaultunit: 1%c | { pth1: (~1cm,0cm)--(^)<(0cm,0cm)>(1cm,1cm)--(2cm,3cm)<(4cm,4cm)>(^) @@ -53,14 +53,14 @@ mergepaths: \ p1 p2 → @stroking:[gray 0.7] | { - •page << [stroke pth1] - •page << [stroke pth2] + IO..•page << [Graphics..stroke pth1] + IO..•page << [Graphics..stroke pth2] } - •page << [stroke [meetpaths pth1 pth2]] + IO..•page << [Graphics..stroke [Geometry..meetpaths pth1 pth2]] } -@defaultunit: 1%c +Geometry..@defaultunit: 1%c | { pth1: (0cm,~3cm)>(2cm^70°)--(5cm,5cm) @@ -69,26 +69,26 @@ mergepaths: \ p1 p2 → @stroking:[gray 0.7] | { - •page << [stroke pth1] << [stroke pth2] + IO..•page << [Graphics..stroke pth1] << [Graphics..stroke pth2] } - •page << [stroke [Geometry..linkpaths pth1 pth2]] + IO..•page << [Graphics..stroke [Geometry..linkpaths pth1 pth2]] } { subpath: \ pth t1 t2 → [pth t1]--[pth t2] - seg: \ a → [shift (5cm,0)]*[rotate a]*[shift (0,~1.2cm)] [] [reverse [subpath [Geometry..circle 1cm] 0 1.5]] + seg: \ a → [shift (5cm,0)]*[rotate a]*[shift (0,~1.2cm)] [] [Geometry..reverse [subpath [Geometry..circle 1cm] 0 1.5]] c1: [seg 0°] c2: [seg 90°] c3: [seg 180°] c4: [seg 270°] - •page << [stroke c1] - pths: Data..consify [] [list c1 c2 c3 c4] + IO..•page << [Graphics..stroke c1] + pths: Data..consify [] [Data..list c1 c2 c3 c4] - •page << [pths.foldl - \ p e → p & [stroke e] + IO..•page << [pths.foldl + \ p e → p & [Graphics..stroke e] null] - scaleAroundCenter: \ factor pth → { c: [mean pth] [shift c]*[scale factor]*[shift ~c] [] pth } - •page << @stroking: RGB_RED | [stroke [scaleAroundCenter 1.3 ...][] [Geometry..buildchain pths]--cycle] + scaleAroundCenter: \ factor pth → { c: [Geometry..mean pth] [shift c]*[scale factor]*[shift ~c] [] pth } + IO..•page << @stroking: Traits..RGB..RED | [Graphics..stroke [scaleAroundCenter 1.3 ...][] [Geometry..buildchain pths]--cycle] } diff --git a/examples/showcase/stereo.shape b/examples/showcase/stereo.shape index eee153be..f5c5921c 100644 --- a/examples/showcase/stereo.shape +++ b/examples/showcase/stereo.shape @@ -20,14 +20,16 @@ ##preamble \usepackage{SIunits} ##lookin ..Shapes +##lookin ..Shapes..Geometry3D -pth: [[scale3D 2] (0cm,0cm,0cm)>(+3cm*(1,1,0))--(+3cm*(~1,1,0))<(1cm,0cm,1cm)] +pth: [[Geometry3D..scale 2] (0cm,0cm,0cm)>(+3cm*(1,1,0))--(+3cm*(~1,1,0))<(1cm,0cm,1cm)] eyew: 5cm @eyez:25cm | { - •page << [stroke [view pth]] << [stroke [[shift (2*eyew,0cm)] [view [[shift (~eyew,0cm,0cm)] pth]]]] - •page << [[shift (5cm,9cm)] [TeX `\begin{minipage}{4cm}\begin{align*}´ + [sprintf `w_{\mathrm{eye}} &= \unit{%g}{\centi\meter}\\´ eyew/1cm] + [sprintf `z_{\mathrm{eye}} &= \unit{%g}{\centi\meter}´ @eyez/1cm] + `\end{align*}\end{minipage}´]] + + IO..•page << [Graphics..stroke [view pth]] << [Graphics..stroke [[shift (2*eyew,0cm)] [view [[shift (~eyew,0cm,0cm)] pth]]]] + IO..•page << [[shift (5cm,9cm)] [Graphics..TeX `\begin{minipage}{4cm}\begin{align*}´ + [String..sprintf `w_{\mathrm{eye}} &= \unit{%g}{\centi\meter}\\´ eyew/1cm] + [String..sprintf `z_{\mathrm{eye}} &= \unit{%g}{\centi\meter}´ @eyez/1cm] + `\end{align*}\end{minipage}´]] } diff --git a/examples/showcase/valve.shext b/examples/showcase/valve.shext index eb0d1026..ba187df9 100644 --- a/examples/showcase/valve.shext +++ b/examples/showcase/valve.shext @@ -29,15 +29,15 @@ valve: \ → z22: (u,u) c: 0.5*(z11+z22) v: c+(4*u,0cm) - @defaultunit:1%c + Geometry..@defaultunit:1%c | ( - ( @nonstroking:GRAY_WHITE | [fill z11--z12--z22--z21--cycle] ) + ( @nonstroking:Traits..BW..WHITE | [Graphics..fill z11--z12--z22--z21--cycle] ) & - [stroke z11--z22--z12--z21--cycle] + [Graphics..stroke z11--z22--z12--z21--cycle] & - [stroke c--v] + [Graphics..stroke c--v] & - [stroke (v+(0cm,u))>(^~20°)--(^20°)<(v-(0cm,u))--cycle] + [Graphics..stroke (v+(0cm,u))>(^~20°)--(^20°)<(v-(0cm,u))--cycle] ) } diff --git a/resources/extensions/Applications/Blockdraw/blockdraw.shext b/resources/extensions/Applications/Blockdraw/blockdraw.shext index 4fbcd893..9a0b325e 100644 --- a/resources/extensions/Applications/Blockdraw/blockdraw.shext +++ b/resources/extensions/Applications/Blockdraw/blockdraw.shext @@ -45,7 +45,7 @@ dynamic @blockspaceveryfar identity 15mm dynamic @textscaling identity [scale 1] -dynamic @connectpainter identity [stroke head:Graphics..ShapesArrow ...] +dynamic @connectpainter identity [Graphics..stroke head:Graphics..ShapesArrow ...] dynamic @blockpainter identity stroke centerlabel: \ obj → [Layout..center_x [Xcenter_y obj]] @@ -54,10 +54,10 @@ putlabelAbove: \ lbl z x → [[shift z + (0cm,@abovelabelmargin)] [Layout..cente putlabelBelow: \ lbl z x → [[shift z + (0cm,~@belowlabelmargin)] [Xcenter_y [Layout..center_x lbl x] 1]] putlabelLeft: \ lbl z y → [[shift z + (~@leftrightlabelmargin,0cm)] [Xcenter_y [Layout..center_x lbl 1] y]] putlabelRight: \ lbl z y → [[shift z + (@leftrightlabelmargin,0cm)] [Xcenter_y lbl y]] -leftpointsign: \ obj str n:1 i:1 → [[shift [leftpoint obj n i] + (~@signmarginslide,~@signmarginoffset)] [center [TeX [sprintf `$\scriptsize %s$´ str]] (0,0)]] -rightpointsign: \ obj str n:1 i:1 → [[shift [rightpoint obj n i] + (@signmarginslide,@signmarginoffset)] [center [TeX [sprintf `$\scriptsize %s$´ str]] (0,0)]] -bottompointsign: \ obj str n:1 i:1 → [[shift [bottompoint obj n i] + (@signmarginoffset,~@signmarginslide)] [center [TeX [sprintf `$\scriptsize %s$´ str]] (0,0)]] -toppointsign: \ obj str n:1 i:1 → [[shift [toppoint obj n i] + (~@signmarginoffset,@signmarginslide)] [center [TeX [sprintf `$\scriptsize %s$´ str]] (0,0)]] +leftpointsign: \ obj str n:1 i:1 → [[shift [leftpoint obj n i] + (~@signmarginslide,~@signmarginoffset)] [center [Graphics..TeX [String..sprintf `$\scriptsize %s$´ str]] (0,0)]] +rightpointsign: \ obj str n:1 i:1 → [[shift [rightpoint obj n i] + (@signmarginslide,@signmarginoffset)] [center [Graphics..TeX [String..sprintf `$\scriptsize %s$´ str]] (0,0)]] +bottompointsign: \ obj str n:1 i:1 → [[shift [bottompoint obj n i] + (@signmarginoffset,~@signmarginslide)] [center [Graphics..TeX [String..sprintf `$\scriptsize %s$´ str]] (0,0)]] +toppointsign: \ obj str n:1 i:1 → [[shift [toppoint obj n i] + (~@signmarginoffset,@signmarginslide)] [center [Graphics..TeX [String..sprintf `$\scriptsize %s$´ str]] (0,0)]] putblockOrigin: \ •dst newBlock → { •dst << newBlock @@ -123,8 +123,8 @@ longblock: \ lbl → [sizedblock lbl @longblockrx @longblockry] squareblock: \ lbl → [sizedblock lbl @smallblockr @smallblockr] fracblock: \ lbl → [sizedblock lbl @longblockrx @fracblockry] -longenoughblock: \ lbl → [sizedblock lbl [max @longblockrx 1mm+0.5*([xmax [bbox lbl]]-[xmin [bbox lbl]])] @longblockry] -longenoughfracblock: \ lbl → [sizedblock lbl [max @longblockrx 1mm+0.5*([xmax [bbox lbl]]-[xmin [bbox lbl]])] @fracblockry] +longenoughblock: \ lbl → [sizedblock lbl [Numeric..Math..max @longblockrx 1mm+0.5*([xmax [Layout..bbox lbl]]-[xmin [Layout..bbox lbl]])] @longblockry] +longenoughfracblock: \ lbl → [sizedblock lbl [Numeric..Math..max @longblockrx 1mm+0.5*([xmax [Layout..bbox lbl]]-[xmin [Layout..bbox lbl]])] @fracblockry] roundblock: \ lbl → ( @@ -133,11 +133,11 @@ roundblock: \ lbl → [center [@textscaling lbl] (0,0)] ) -sumpicture: \ → [roundblock [TeX `$\Sigma$´]] +sumpicture: \ → [roundblock [Graphics..TeX `$\Sigma$´]] -splitdot: \ → ( @nonstroking:@stroking | [fill [Geometry..circle 2.5 * @connectionlw]] ) +splitdot: \ → ( @nonstroking:@stroking | [Graphics..fill [Geometry..circle 2.5 * @connectionlw]] ) -termcircle: \ → ( @width:@connectionlw | [stroke [Geometry..circle 3 * @connectionlw]] ) +termcircle: \ → ( @width:@connectionlw | [Graphics..stroke [Geometry..circle 3 * @connectionlw]] ) hhconnect: \ •dst pa pb mediation slide → { @@ -168,10 +168,10 @@ vhconnect: \ •dst pa pb → conlabel: \ shiftdir lbl z → [[shift z] [shiftoff_wlm lbl shiftdir]] -leftpoint: \ pic n:1 i:1 → { bb: [bbox pic] ([xmin bb], [mediate i/(n+1) [ymin bb] [ymax bb]])} -rightpoint: \ pic n:1 i:1 → { bb: [bbox pic] ([xmax bb], [mediate i/(n+1) [ymin bb] [ymax bb]])} -bottompoint: \ pic n:1 i:1 → { bb: [bbox pic] ([mediate i/(n+1) [xmin bb] [xmax bb]], [ymin bb])} -toppoint: \ pic n:1 i:1 → { bb: [bbox pic] ([mediate i/(n+1) [xmin bb] [xmax bb]], [ymax bb])} +leftpoint: \ pic n:1 i:1 → { bb: [Layout..bbox pic] ([xmin bb], [mediate i/(n+1) [ymin bb] [ymax bb]])} +rightpoint: \ pic n:1 i:1 → { bb: [Layout..bbox pic] ([xmax bb], [mediate i/(n+1) [ymin bb] [ymax bb]])} +bottompoint: \ pic n:1 i:1 → { bb: [Layout..bbox pic] ([mediate i/(n+1) [xmin bb] [xmax bb]], [ymin bb])} +toppoint: \ pic n:1 i:1 → { bb: [Layout..bbox pic] ([mediate i/(n+1) [xmin bb] [xmax bb]], [ymax bb])} llconnect: \ •dst pica picb slide → { z1:[leftpoint pica 1 1] z2:[leftpoint picb 1 1] [hhconnect •dst z1 z2 [if z1.xz2.x 0 1] slide] } @@ -194,14 +194,14 @@ brconnect: \ •dst pica picb → [vhconnect •dst [bottompoint pica 1 1] [righ connect: \ •dst pica picb → { - bba: [bbox pica] - bbb: [bbox picb] + bba: [Layout..bbox pica] + bbb: [Layout..bbox picb] rxa: 0.5 * ( [xmax bba] - [xmin bba] ) rxb: 0.5 * ( [xmax bbb] - [xmin bbb] ) rya: 0.5 * ( [ymax bba] - [ymin bba] ) ryb: 0.5 * ( [ymax bbb] - [ymin bbb] ) - ca: [pathpoint_mean bba] - cb: [pathpoint_mean bbb] + ca: [Geometry..pathpoint_mean bba] + cb: [Geometry..pathpoint_mean bbb] [if ca.x < cb.x - ( rxa + rxb ) [if ca.y < cb.y - ( rya + ryb ) [rbconnect •dst pica picb] diff --git a/resources/extensions/Applications/Blockdraw/bondgraph.shext b/resources/extensions/Applications/Blockdraw/bondgraph.shext index c27c9914..16964238 100644 --- a/resources/extensions/Applications/Blockdraw/bondgraph.shext +++ b/resources/extensions/Applications/Blockdraw/bondgraph.shext @@ -24,40 +24,40 @@ ##lookin ..Shapes ##lookin ..Shapes..Layout -junction: \ txt → [bboxed [center txt (0,0)] [rectangle (~@smallblockr,~@smallblockr) (@smallblockr,@smallblockr)]] +junction: \ txt → [Layout..bboxed [center txt (0,0)] [Geometry..rectangle (~@smallblockr,~@smallblockr) (@smallblockr,@smallblockr)]] -pjunction: [junction [TeX `p´]] -sjunction: [junction [TeX `s´]] +pjunction: [junction [Graphics..TeX `p´]] +sjunction: [junction [Graphics..TeX `s´]] junctionlbl: \ txt arrowdir lbl doArrow → { ahLength: 1.5mm ahAngle: 30° tmppic: [junction txt] - thebb: [bbox tmppic] - pOffset: 0bp |** @connectionlw + ahLength*[sin 0.5*ahAngle] + thebb: [Layout..bbox tmppic] + pOffset: 0bp |** @connectionlw + ahLength*[Numeric..Math..sin 0.5*ahAngle] p: [if arrowdir = to_lft [[shift (0,pOffset)] ([xmax thebb],[ymax thebb])--([xmin thebb],[ymax thebb])] [if arrowdir = to_rt [[shift (0,pOffset)] ([xmin thebb],[ymax thebb])--([xmax thebb],[ymax thebb])] [if arrowdir = to_bot [[shift (pOffset,0)] ([xmax thebb],[ymax thebb])--([xmax thebb],[ymin thebb])] [if arrowdir = to_top [[shift (pOffset,0)] ([xmax thebb],[ymin thebb])--([xmax thebb],[ymax thebb])] - [error [sprintf `Bad arrowdir constant: %g´ arrowdir]]]]]] + [error [String..sprintf `Bad arrowdir constant: %g´ arrowdir]]]]]] d: [if arrowdir = to_lft to_top [if arrowdir = to_rt to_top [if arrowdir = to_bot to_rt [if arrowdir = to_top to_rt - [error [sprintf `Bad arrowdir constant: %g´ arrowdir]]]]]] + [error [String..sprintf `Bad arrowdir constant: %g´ arrowdir]]]]]] [bboxed_sym (newGroup << [if doArrow - [stroke p head: [Graphics..triangleArrow ahLength:ahLength ahAngle:ahAngle ...]] + [Graphics..stroke p head: [Graphics..triangleArrow ahLength:ahLength ahAngle:ahAngle ...]] null] << [conlabel d lbl [mspoint p 0.5]] << tmppic )] } -tfjunction: \ arrowdir lbl → [junctionlbl [TeX `TF´] arrowdir lbl true] -gyjunction: \ arrowdir lbl → [junctionlbl [TeX `GY´] arrowdir lbl false] +tfjunction: \ arrowdir lbl → [junctionlbl [Graphics..TeX `TF´] arrowdir lbl true] +gyjunction: \ arrowdir lbl → [junctionlbl [Graphics..TeX `GY´] arrowdir lbl false] @@ -72,7 +72,7 @@ bgconnect: \ pica picb → { ca: [centerof pica] cb: [centerof picb] - d: [if [abs ca - cb] = 0bp + d: [if [Numeric..Math..abs ca - cb] = 0bp (1,0) [normalized cb - ca]] (ca + d * @smallblockr)--(cb - d * @smallblockr) @@ -81,25 +81,25 @@ bgconnect: \ pica picb → dynamic @bgArrowWidth identity 4bp bondgraphArrow: \ p doHook:false doCausal:false ahAngle:20° fillAsStroking:true → - (@blend:BLEND_NORMAL + (@blend:Traits..Blend..NORMAL | - { theLength: @bgArrowWidth / [sin ahAngle] + { theLength: @bgArrowWidth / [Numeric..Math..sin ahAngle] hook: { sl: [p theLength] - z: sl.p - sl.N * theLength * [sin ahAngle] + z: sl.p - sl.N * theLength * [Numeric..Math..sin ahAngle] @nonstroking:[if fillAsStroking @stroking @nonstroking] | - [fill [[shift sl.N * 0.5 * @width] [p 0]--sl]--z--cycle] + [Graphics..fill [[shift sl.N * 0.5 * @width] [p 0]--sl]--z--cycle] } causal: { sl: [p 0] z: sl.p + sl.rT * @width - r: sl.N * theLength * [sin ahAngle] + r: sl.N * theLength * [Numeric..Math..sin ahAngle] @width: 1.5*@width | - [stroke (z-r)--(z+r)] + [Graphics..stroke (z-r)--(z+r)] } (> picture: @@ -118,9 +118,9 @@ bondgraphArrow: \ p doHook:false doCausal:false ahAngle:20° fillAsStroking:true } ) -ubond: \ p → ( @width:@connectionlw | [stroke p head:[bondgraphArrow doHook:true ...]] ) -hbond: \ p → ( @width:@connectionlw | [stroke p head:[bondgraphArrow doHook:true doCausal:true ...]] ) -tbond: \ p → ( @width:@connectionlw | [stroke p head:[bondgraphArrow doHook:true ...] tail:[bondgraphArrow doCausal:true ...]] ) +ubond: \ p → ( @width:@connectionlw | [Graphics..stroke p head:[bondgraphArrow doHook:true ...]] ) +hbond: \ p → ( @width:@connectionlw | [Graphics..stroke p head:[bondgraphArrow doHook:true doCausal:true ...]] ) +tbond: \ p → ( @width:@connectionlw | [Graphics..stroke p head:[bondgraphArrow doHook:true ...] tail:[bondgraphArrow doCausal:true ...]] ) |** the midpoint has typically singular direction, so we can't do the obvious: |** draw( conlabel( to_dir( dir( angle( direction (0.5*length(p)) of p ) - 90 ) ), txt, mspoint( p, 0.5, 0 ) ) ) diff --git a/resources/extensions/Applications/Circuit/parts.shext b/resources/extensions/Applications/Circuit/parts.shext index 99e1297f..d0a2ea99 100644 --- a/resources/extensions/Applications/Circuit/parts.shext +++ b/resources/extensions/Applications/Circuit/parts.shext @@ -20,31 +20,31 @@ ##lookin ..Applications..Blockdraw resistance: \ → -@width:@connectionlw & @cap:CAP_SQUARE +@width:@connectionlw & @cap:Traits..Cap..SQUARE | { lambda: @longblockrx / 3 r: 0.75 * lambda - [stroke (~2.5*lambda-@width,0)--(~2.5*lambda,0)--(~2*lambda,r)--(~1.5*lambda,~r)--(~1*lambda,r)--(~0.5*lambda,~r)--(0*lambda,r)-- + [Graphics..stroke (~2.5*lambda-@width,0)--(~2.5*lambda,0)--(~2*lambda,r)--(~1.5*lambda,~r)--(~1*lambda,r)--(~0.5*lambda,~r)--(0*lambda,r)-- (0.5*lambda,~r)--(1*lambda,r)--(1.5*lambda,~r)--(2*lambda,r)--(2.5*lambda,0)--(2.5*lambda+@width,0)] } inductance: \ → -@width:@connectionlw & @cap:CAP_SQUARE & @defaultunit:1%c +@width:@connectionlw & @cap:Traits..Cap..SQUARE & Geometry..@defaultunit:1%c | { lambda: @longblockrx / 3 r: 0.75 * lambda - [stroke (~2.5*lambda-@width,0)--(~2.5*lambda,0)>(^80°)--(lambda/3^)<(~2*lambda,r)>(r^0°) + [Graphics..stroke (~2.5*lambda-@width,0)--(~2.5*lambda,0)>(^80°)--(lambda/3^)<(~2*lambda,r)>(r^0°) --(^)<(~1.5*lambda,~r)>(r^180°)--(^)<(~1*lambda,r)>(r^0°)--(^)<(~0.5*lambda,~r)>(r^180°)--(^)<(0*lambda,r)>(r^0°)-- (^)<(0.5*lambda,~r)>(r^180°)--(^)<(1*lambda,r)>(r^0°)--(^)<(1.5*lambda,~r)>(r^180°)--(r^)<(2*lambda,r)>(lambda/3^0°)--(^100°)<(2.5*lambda,0)--(2.5*lambda,0)--(2.5*lambda+@width,0)] } capacitance: \ → -@width:@connectionlw & @cap:CAP_SQUARE & @defaultunit:1%c +@width:@connectionlw & @cap:Traits..Cap..SQUARE & Geometry..@defaultunit:1%c | { rh: @longblockry rw: @longblockrx / 8 - [stroke (~rw,~rh)--(~rw,rh) & (rw,~rh)--(rw,rh)] + [Graphics..stroke (~rw,~rh)--(~rw,rh) & (rw,~rh)--(rw,rh)] } diff --git a/resources/extensions/Shapes/Control/cond.shext b/resources/extensions/Shapes/Control/cond.shext index af0318e4..aa3f1e06 100644 --- a/resources/extensions/Shapes/Control/cond.shext +++ b/resources/extensions/Shapes/Control/cond.shext @@ -16,6 +16,8 @@ ** Copyright 2009, 2014, 2015 Henrik Tidefelt **/ +##lookin ..Shapes + /** A Scheme-like function. ** ** The function expects any number of ConsPair arguments, which are put @@ -26,7 +28,7 @@ cond: \ <>cases → (escape_continuation return { - ![(list []<>cases).foldr + ![(Data..list []<>cases).foldr \ p e → [if e.car (escape_continue return e.cdr) p] void] ![error 'misc VARNAME `No matching cond clause.´] diff --git a/resources/extensions/Shapes/Geometry/circle.shext b/resources/extensions/Shapes/Geometry/circle.shext index 3ca3c307..dcbaec5c 100644 --- a/resources/extensions/Shapes/Geometry/circle.shext +++ b/resources/extensions/Shapes/Geometry/circle.shext @@ -18,7 +18,7 @@ circle: { - p1cm: @defaultunit:1%c + p1cm: Geometry..@defaultunit:1%c | (^)<(1cm,0cm)>(^)--(^)<(0cm,1cm)>(^)--(^)<(~1cm,0cm)>(^)--(^)<(0cm,~1cm)>(^)--cycle \ r → [[scale r / 1cm] p1cm] } @@ -30,7 +30,7 @@ ccw_arc: \ z0 zStart zEnd r → aStart: [angle dStart] aEnd: { tmp: [angle dEnd] [if tmp ≥ aStart tmp tmp+360°] } - @defaultunit:1%C | [shift z0] [] ( dStart>(^aStart+90°)--(^)<(r*[dir aStart+0.25*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.5*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.75*(aEnd-aStart)])>(^)--(^aEnd-90°)(^aStart+90°)--(^)<(r*[dir aStart+0.25*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.5*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.75*(aEnd-aStart)])>(^)--(^aEnd-90°)(^aStart-90°)--(^)<(r*[dir aStart+0.25*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.5*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.75*(aEnd-aStart)])>(^)--(^aEnd+90°)(^aStart-90°)--(^)<(r*[dir aStart+0.25*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.5*(aEnd-aStart)])>(^)--(^)<(r*[dir aStart+0.75*(aEnd-aStart)])>(^)--(^aEnd+90°)> [debuglog_before p1 ...] >> [debuglog_before "{n} ...] + [if p1.null? >> [Debug..log_before p1 ...] >> [Debug..log_before "{n} ...] p2 (escape_continuation cont @handler_NoIntersection: (\ pth1 pth2 → (escape_continue cont (pth1.begin--pth1.end>(1%C^[angle (-pth1.end.rT)]))--((1%C^[angle (-pth2.begin.T)])> [debuglog_before `search...´ ...] >> [debuglog_after `found´ ...] + t: [intersection p1 p2] >> [Debug..log_before `search...´ ...] >> [Debug..log_after `found´ ...] [meetpaths [p1 0]--t [approximator p2 t.p]--[p2 ∞]] } ) @@ -39,7 +39,7 @@ pathmap: \ pth f → { - tmp: [helper f [pth 0] [pth 1] emptypath] + tmp: [helper f [pth 0] [pth 1] Geometry..emptypath] [if pth.closed? tmp--cycle tmp] @@ -48,7 +48,7 @@ pathmap: sidepath: \ pth dst → - @defaultunit:1%C + Geometry..@defaultunit:1%C | [pathmap pth \ sl1 sl2 → diff --git a/resources/extensions/Shapes/Geometry3D/circle.shext b/resources/extensions/Shapes/Geometry3D/circle.shext index 59694aff..537ed474 100644 --- a/resources/extensions/Shapes/Geometry3D/circle.shext +++ b/resources/extensions/Shapes/Geometry3D/circle.shext @@ -17,14 +17,14 @@ **/ ##needs ..Shapes..Geometry / circle - +##lookin ..Shapes..Geometry3D generic_arc3D: \ arc2D z0 zStart zEnd r → { dStart: [normalized zStart - z0] dEnd: [normalized zEnd - z0] n: [normalized [cross dStart dEnd]] - tf: [affinetransform3D dStart [cross n dStart] n z0] + tf: [Geometry3D..affinetransform dStart [cross n dStart] n z0] itf: [inverse tf] [arc2D [view [itf z0]] [view [itf zStart]] [view [itf zEnd]] r] >> immerse >> tf } diff --git a/resources/extensions/Shapes/Graphics/arrowheads.shext b/resources/extensions/Shapes/Graphics/arrowheads.shext index 08c45451..86090452 100644 --- a/resources/extensions/Shapes/Graphics/arrowheads.shext +++ b/resources/extensions/Shapes/Graphics/arrowheads.shext @@ -17,16 +17,16 @@ **/ triangleArrow: \ p ahLength:void ahAngle:30° fillAsStroking:true → - (@blend:BLEND_NORMAL + (@blend:Traits..Blend..NORMAL | { sl: [p 0] z: sl.p d: [angle sl.T] - theLength: [if [typeof ahLength]=§Void @width*6 ahLength] + theLength: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] (> picture: @nonstroking:[if fillAsStroking @stroking @nonstroking] | - [fill (z+[dir d - ahAngle/2]*theLength)--z--(z+[dir d + ahAngle/2]*theLength)--cycle] + [Graphics..fill (z+[dir d - ahAngle/2]*theLength)--z--(z+[dir d + ahAngle/2]*theLength)--cycle] cut: 2*@width <) } diff --git a/resources/extensions/Shapes/Graphics/braces.shext b/resources/extensions/Shapes/Graphics/braces.shext index 22b58a5b..71422728 100644 --- a/resources/extensions/Shapes/Graphics/braces.shext +++ b/resources/extensions/Shapes/Graphics/braces.shext @@ -24,15 +24,15 @@ genericBrace: \ p0 p1 height aEnd rEndFactor aMid rMidFactor extendLimitFactor r: p1 - p0 a0: [angle r] n: [[rotate ~90°] height * [normalized r]] - [if [abs r] < extendLimit + [if [Numeric..Math..abs r] < extendLimit p0>(rEnd^a0-aEnd)--(rMid^180°+a0-aMid)<(p0+0.5*r+n)>(rMid^a0+aMid)--(rEnd^180°+a0+aEnd)(rEnd^a0-aEnd)--(rMid^180°+a0-aMid)<(p0+0.5*r+n)>(rMid^a0+aMid)--(rEnd^180°+a0+aEnd)<(p0+r) tmp1: tmp.begin--[tmp 1] - slmid: [tmp1 0.5*[abs tmp1]] - l1: [maximizer tmp1.begin--slmid [normalized n]].length - l2: slmid.length + [maximizer slmid--tmp1.end ~[normalized n]].length + slmid: [tmp1 0.5*[Numeric..Math..abs tmp1]] + l1: [Geometry..maximizer tmp1.begin--slmid [normalized n]].length + l2: slmid.length + [Geometry..maximizer slmid--tmp1.end ~[normalized n]].length sl1: tmp.begin + l1 sl2: tmp.begin + l2 sl3: tmp.end - l2 @@ -49,9 +49,9 @@ someBrace: [heightBrace height:4mm ...] closedBrace: \ p0 p1 height width:void → { - lowHeight: height - [if [typeof width]=§Void @width width] - lowBrace: [reverse [genericBrace p0 p1 aEnd:70° rEndFactor:1.3 aMid:55° rMidFactor:1.6 extendLimitFactor:11 height:lowHeight]] - highBrace: [genericBrace p0 p1 aEnd:80° rEndFactor:1.3 aMid:50° rMidFactor:1.6 extendLimitFactor:11 height:height] + lowHeight: height - [if [typeof width]=Data..Type..§Void @width width] + lowBrace: [Geometry..reverse [genericBrace p0 p1 aEnd:70° rEndFactor:1.3 aMid:55° rMidFactor:1.6 extendLimitFactor:11 height:lowHeight]] + highBrace: [genericBrace p0 p1 aEnd:80° rEndFactor:1.3 aMid:50° rMidFactor:1.6 extendLimitFactor:11 height:height] lowBrace--highBrace--cycle } diff --git a/resources/extensions/Shapes/Graphics/elementary.shext b/resources/extensions/Shapes/Graphics/elementary.shext index e583ac71..1d30b95a 100644 --- a/resources/extensions/Shapes/Graphics/elementary.shext +++ b/resources/extensions/Shapes/Graphics/elementary.shext @@ -19,8 +19,8 @@ polyDisc: \ radius sides → { deltaAngle: 360° / sides - r: radius * ( 2 / ( 1 + [cos deltaAngle / 2] ) ) - [[range '0 sides-'1].foldl + r: radius * ( 2 / ( 1 + [Numeric..Math..cos deltaAngle / 2] ) ) + [[Data..range '0 sides-'1].foldl \ pile e → pile--( r * [dir deltaAngle * e] ) - emptypath]--cycle + Geometry..emptypath]--cycle } diff --git a/resources/extensions/Shapes/Graphics/metapostarrow.shext b/resources/extensions/Shapes/Graphics/metapostarrow.shext index 277cf562..57c2b313 100644 --- a/resources/extensions/Shapes/Graphics/metapostarrow.shext +++ b/resources/extensions/Shapes/Graphics/metapostarrow.shext @@ -16,17 +16,21 @@ ** Copyright 2008, 2014, 2015 Henrik Tidefelt **/ +##lookin ..Shapes +##lookin ..Shapes..Traits +##lookin ..Shapes..Geometry + MetaPostArrow: \ p ahLength:void ahAngle:30° fillAsStroking:true → - (@blend:BLEND_NORMAL + (@blend:Blend..NORMAL | { z: [p 0].p - theLength: [if [typeof ahLength]=§Void @width*6 ahLength] - l: [min theLength 0.9*[abs p]] + theLength: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] + l: [Numeric..Math..min theLength 0.9*[Numeric..Math..abs p]] e: [p 0]--[p l] (> picture: @nonstroking:[if fillAsStroking @stroking @nonstroking] | - [fill [[shift z]*[rotate ahAngle*0.5]*[shift ~z] e]--[reverse [[shift z]*[rotate ~ahAngle*0.5]*[shift ~z] e]]--cycle] + [Graphics..fill [[shift z]*[rotate ahAngle*0.5]*[shift ~z] e]--[Geometry..reverse [[shift z]*[rotate ~ahAngle*0.5]*[shift ~z] e]]--cycle] cut: 2*@width <) } diff --git a/resources/extensions/Shapes/Graphics/shapesarrow.shext b/resources/extensions/Shapes/Graphics/shapesarrow.shext index 7e9a09b1..6716af1e 100644 --- a/resources/extensions/Shapes/Graphics/shapesarrow.shext +++ b/resources/extensions/Shapes/Graphics/shapesarrow.shext @@ -16,33 +16,37 @@ ** Copyright 2009, 2014, 2015 Henrik Tidefelt **/ +##lookin ..Shapes +##lookin ..Shapes..Traits +##lookin ..Shapes..Geometry + ShapesArrow: \ p width:3 frontAngle:40° rearAngle:150° fillAsStroking:true → - (@blend:BLEND_NORMAL + (@blend:Blend..NORMAL | { z: p.begin.p - lMax: 0.99*[abs p] - w: 0.5*[if [typeof width]=§Float [max 3bp @width*width] width] - el: [min w/[sin 0.5*frontAngle] lMax] - l: [min w * ( [cot 0.5*frontAngle] - [cot 0.5*rearAngle] ) lMax] + lMax: 0.99*[Numeric..Math..abs p] + w: 0.5*[if [typeof width]=Data..Type..§Float [Numeric..Math..max 3bp @width*width] width] + el: [Numeric..Math..min w/[Numeric..Math..sin 0.5*frontAngle] lMax] + l: [Numeric..Math..min w * ( [Numeric..Math..cot 0.5*frontAngle] - [Numeric..Math..cot 0.5*rearAngle] ) lMax] e: [p 0]--[p el] >> [shift ~z] sl: [p l] pr: sl.p dr: e.end.p dra: [angle dr] drl: (|dr|) - r: w / [sin 0.5*rearAngle] + r: w / [Numeric..Math..sin 0.5*rearAngle] d1: sl.p + [[rotate 0.5*rearAngle] (r*sl.T)] - z d2: sl.p + [[rotate ~0.5*rearAngle] (r*sl.T)] - z (> picture: @nonstroking:[if fillAsStroking @stroking @nonstroking] | - [fill [[shift z]*[rotate [angle d1]-dra]*[scale (|d1|)/drl] e]-- + [Graphics..fill [[shift z]*[rotate [angle d1]-dra]*[scale (|d1|)/drl] e]-- pr-- - [reverse [[shift z]*[rotate [angle d2]-dra]*[scale (|d2|)/drl] e]]-- + [Geometry..reverse [[shift z]*[rotate [angle d2]-dra]*[scale (|d2|)/drl] e]]-- cycle] /** Cut away the average between the length computed at the point and the rear of the head. **/ - cut: 0.5 * ( ( l + 0.5*@width * [max 0 [cot 0.5 * rearAngle]] ) + 0.5*@width*[cot 0.5*frontAngle] ) + cut: 0.5 * ( ( l + 0.5*@width * [Numeric..Math..max 0 [Numeric..Math..cot 0.5 * rearAngle]] ) + 0.5*@width*[Numeric..Math..cot 0.5*frontAngle] ) <) } ) diff --git a/resources/extensions/Shapes/Graphics3D/arrowheads.shext b/resources/extensions/Shapes/Graphics3D/arrowheads.shext index a43ff795..4375bf78 100644 --- a/resources/extensions/Shapes/Graphics3D/arrowheads.shext +++ b/resources/extensions/Shapes/Graphics3D/arrowheads.shext @@ -21,20 +21,20 @@ twoCirclesArrow: ztf: \ z0 → { z: [normalized z0] - x: [orthogonal z] - y: [cross z x] - [affinetransform3D x y z (0cm,0cm,0cm)] + x: [Geometry..orthogonal z] + y: [Geometry3D..cross z x] + [Geometry3D..affinetransform x y z (0cm,0cm,0cm)] } \ p ahLength:void ahAngle:30° → { z: [p 0] - theLength: [if [typeof ahLength]=§Void @width*6 ahLength] - l: [min theLength*[cos ahAngle] 0.9*[abs p]] + theLength: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] + l: [Numeric..Math..min theLength*[Numeric..Math..cos ahAngle] 0.9*[Numeric..Math..abs p]] e: [p 0]--[p l] (> - picture: [stroke [[shift [p 0.5*theLength*[cos ahAngle]].p]*[ztf [p 0.5*theLength*[cos ahAngle]].T] [immerse [..Shapes..Geometry..circle 0.5*theLength*[sin ahAngle]]]]] + picture: [Graphics..stroke [[shift [p 0.5*theLength*[Numeric..Math..cos ahAngle]].p]*[ztf [p 0.5*theLength*[Numeric..Math..cos ahAngle]].T] [immerse [..Shapes..Geometry..circle 0.5*theLength*[Numeric..Math..sin ahAngle]]]]] & - [stroke [[shift [p theLength*[cos ahAngle]].p]*[ztf [p theLength*[cos ahAngle]].T] [immerse [..Shapes..Geometry..circle theLength*[sin ahAngle]]]]] + [Graphics..stroke [[shift [p theLength*[Numeric..Math..cos ahAngle]].p]*[ztf [p theLength*[Numeric..Math..cos ahAngle]].T] [immerse [..Shapes..Geometry..circle theLength*[Numeric..Math..sin ahAngle]]]]] cut: 0mm <) } @@ -43,15 +43,15 @@ twoCirclesArrow: triangleArrow: \ p normal:(0,0,1) ahLength:void ahAngle:30° → { sl: [p 0] z: sl.p - l: [if [typeof ahLength]=§Void @width*6 ahLength] - rotDir1: [cross sl.T [orthogonal sl.T]] + l: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] + rotDir1: [Geometry3D..cross sl.T [Geometry..orthogonal sl.T]] (> picture: { rotDir: rotDir1 - ( (0m,0m,0m)--([rotate3D dir:rotDir angle:ahAngle*0.5][](l*sl.T))--([rotate3D dir:rotDir angle:~ahAngle*0.5][](l*sl.T))--cycle ) >> [shift z] >> fill } + ( (0m,0m,0m)--([Geometry3D..rotate dir:rotDir angle:ahAngle*0.5][](l*sl.T))--([Geometry3D..rotate dir:rotDir angle:~ahAngle*0.5][](l*sl.T))--cycle ) >> [shift z] >> fill } & - { rotDir: [cross sl.T rotDir1] - ( (0m,0m,0m)--([rotate3D dir:rotDir angle:ahAngle*0.5][](l*sl.T))--([rotate3D dir:rotDir angle:~ahAngle*0.5][](l*sl.T))--cycle ) >> [shift z] >> fill} + { rotDir: [Geometry3D..cross sl.T rotDir1] + ( (0m,0m,0m)--([Geometry3D..rotate dir:rotDir angle:ahAngle*0.5][](l*sl.T))--([Geometry3D..rotate dir:rotDir angle:~ahAngle*0.5][](l*sl.T))--cycle ) >> [shift z] >> fill} cut: 2*@width <) } @@ -59,22 +59,22 @@ triangleArrow: \ p normal:(0,0,1) ahLength:void ahAngle:30° → triangleBundleArrow: \ p count:'4 ahLength:void ahAngle:30° → { sl: [p 0] z: sl.p - l: [if [typeof ahLength]=§Void @width*6 ahLength] + l: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] angleStep: 180°/count - normal: [cross sl.T [orthogonal sl.T]] - oneTriangle: [fill (0m,0m,0m)--([rotate3D dir:normal angle:ahAngle*0.5][](l*sl.T))--([rotate3D dir:normal angle:~ahAngle*0.5][](l*sl.T))--cycle] - oneCorner: [rotate3D dir:normal angle:ahAngle*0.5][](l*sl.T) + normal: [Geometry3D..cross sl.T [Geometry..orthogonal sl.T]] + oneTriangle: [Graphics..fill (0m,0m,0m)--([Geometry3D..rotate dir:normal angle:ahAngle*0.5][](l*sl.T))--([Geometry3D..rotate dir:normal angle:~ahAngle*0.5][](l*sl.T))--cycle] + oneCorner: [Geometry3D..rotate dir:normal angle:ahAngle*0.5][](l*sl.T) pT: sl.T (> picture: [[shift z] - [[range '0 (count-'1)].foldl - \ p e → p & [[rotate3D dir:pT angle:e*angleStep] oneTriangle] - null3D] + [[Data..range '0 (count-'1)].foldl + \ p e → p & [[Geometry3D..rotate dir:pT angle:e*angleStep] oneTriangle] + Graphics3D..null] & - [fill [[range '0 ('2*count-'1)].foldl - \ p e → p--[[rotate3D dir:pT angle:e*angleStep] oneCorner] - emptypath3D]--cycle]] + [Graphics..fill [[Data..range '0 ('2*count-'1)].foldl + \ p e → p--[[Geometry3D..rotate dir:pT angle:e*angleStep] oneCorner] + Geometry3D..emptypath]--cycle]] cut: 2*@width <) } diff --git a/resources/extensions/Shapes/Graphics3D/elementary.shext b/resources/extensions/Shapes/Graphics3D/elementary.shext index 687d27e5..a4e152f9 100644 --- a/resources/extensions/Shapes/Graphics3D/elementary.shext +++ b/resources/extensions/Shapes/Graphics3D/elementary.shext @@ -19,28 +19,28 @@ cylinderWall: \ radius height sides → { deltaAngle: 360° / sides - r: radius * ( 2 / ( 1 + [cos deltaAngle / 2] ) ) - oneSide: [facet (r,0m,0m)--(r*[cos deltaAngle],r*[sin deltaAngle],0m)--(r*[cos deltaAngle],r*[sin deltaAngle],height)--(r,0m,height)--cycle - [facetnormal (r,0m,0m) (1,0,0)] - [facetnormal (r*[cos deltaAngle],r*[sin deltaAngle],0m) ([cos deltaAngle],[sin deltaAngle],0)] ] + r: radius * ( 2 / ( 1 + [Numeric..Math..cos deltaAngle / 2] ) ) + oneSide: [Graphics3D..facet (r,0m,0m)--(r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],0m)--(r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],height)--(r,0m,height)--cycle + [Graphics3D..facetnormal (r,0m,0m) (1,0,0)] + [Graphics3D..facetnormal (r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],0m) ([Numeric..Math..cos deltaAngle],[Numeric..Math..sin deltaAngle],0)] ] - [[range '0 sides-'1].foldl + [[Data..range '0 sides-'1].foldl \ p e → - p & [[rotate3D (0,0,1) e*deltaAngle] oneSide] - null3D] + p & [[Geometry3D..rotate (0,0,1) e*deltaAngle] oneSide] + Graphics3D..null] } block: \ x1 y1 z1 x2 y2 z2 → ( - [facet (x1,y1,z1)--(x2,y1,z1)--(x2,y2,z1)--(x1,y2,z1)--cycle] + [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y2,z1)--(x1,y2,z1)--cycle] & - [facet (x1,y1,z2)--(x2,y1,z2)--(x2,y2,z2)--(x1,y2,z2)--cycle] + [Graphics3D..facet (x1,y1,z2)--(x2,y1,z2)--(x2,y2,z2)--(x1,y2,z2)--cycle] & - [facet (x1,y1,z1)--(x2,y1,z1)--(x2,y1,z2)--(x1,y1,z2)--cycle] + [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y1,z2)--(x1,y1,z2)--cycle] & - [facet (x1,y2,z1)--(x2,y2,z1)--(x2,y2,z2)--(x1,y2,z2)--cycle] + [Graphics3D..facet (x1,y2,z1)--(x2,y2,z1)--(x2,y2,z2)--(x1,y2,z2)--cycle] & - [facet (x1,y1,z1)--(x1,y1,z2)--(x1,y2,z2)--(x1,y2,z1)--cycle] + [Graphics3D..facet (x1,y1,z1)--(x1,y1,z2)--(x1,y2,z2)--(x1,y2,z1)--cycle] & - [facet (x2,y1,z1)--(x2,y1,z2)--(x2,y2,z2)--(x2,y2,z1)--cycle] + [Graphics3D..facet (x2,y1,z1)--(x2,y1,z2)--(x2,y2,z2)--(x2,y2,z1)--cycle] ) diff --git a/resources/extensions/Shapes/Graphics3D/metapostarrow.shext b/resources/extensions/Shapes/Graphics3D/metapostarrow.shext index a750fbff..68ad00c9 100644 --- a/resources/extensions/Shapes/Graphics3D/metapostarrow.shext +++ b/resources/extensions/Shapes/Graphics3D/metapostarrow.shext @@ -18,14 +18,14 @@ MetaPostArrow: \ normal p ahLength:void ahAngle:30° → { z: [p 0].p - theLength: [if [typeof ahLength]=§Void @width*6 ahLength] - l: [min theLength 0.9*[abs p]] + theLength: [if [typeof ahLength]=Data..Type..§Void @width*6 ahLength] + l: [Numeric..Math..min theLength 0.9*[Numeric..Math..abs p]] e: [p 0]--[p l] - rev: [reverse [[shift z]*[rotate3D dir:normal angle: ~ahAngle*0.5]*[shift ~z] e]] + rev: [Geometry..reverse [[shift z]*[Geometry3D..rotate dir:normal angle: ~ahAngle*0.5]*[shift ~z] e]] (> - picture: [fill [[shift z]*[rotate3D dir:normal angle:ahAngle*0.5]*[shift ~z] e]--rev--cycle] + picture: [Graphics..fill [[shift z]*[Geometry3D..rotate dir:normal angle:ahAngle*0.5]*[shift ~z] e]--rev--cycle] & - [fill [[shift z]*[rotate3D dir:normal angle:ahAngle*0.5]*[shift ~z] e]--[reverse [[shift z]*[rotate3D dir:normal angle: ~ahAngle*0.5]*[shift ~z] e]]--cycle] - cut: 0.8*[cos ahAngle*0.5]*theLength + [Graphics..fill [[shift z]*[Geometry3D..rotate dir:normal angle:ahAngle*0.5]*[shift ~z] e]--[Geometry..reverse [[shift z]*[Geometry3D..rotate dir:normal angle: ~ahAngle*0.5]*[shift ~z] e]]--cycle] + cut: 0.8*[Numeric..Math..cos ahAngle*0.5]*theLength <) } diff --git a/resources/extensions/Shapes/Graphics3D/revolutionbody.shext b/resources/extensions/Shapes/Graphics3D/revolutionbody.shext index 118f7aa7..fcb869f8 100644 --- a/resources/extensions/Shapes/Graphics3D/revolutionbody.shext +++ b/resources/extensions/Shapes/Graphics3D/revolutionbody.shext @@ -20,45 +20,45 @@ makeSectionThreeNormals: \ profile phiSteps thetaSteps → { - stepLength: [abs profile] / phiSteps - T: [rotate3D dir:(0,0,1) angle: 360° / thetaSteps] + stepLength: [Numeric..Math..abs profile] / phiSteps + T: [Geometry3D..rotate dir:(0,0,1) angle: 360° / thetaSteps] - [[range '0 phiSteps-'1].foldl + [[Data..range '0 phiSteps-'1].foldl \ p e → { sl1: [profile e * stepLength] sl2: [profile ( e + '1 ) * stepLength] p & - [facet sl1.p--sl2.p--[T sl2.p]--cycle - [facetnormal sl1.p ~sl1.N] - [facetnormal sl2.p ~sl2.N] - [facetnormal [T sl2.p] [T ~sl2.N]]] + [Graphics3D..facet sl1.p--sl2.p--[T sl2.p]--cycle + [Graphics3D..facetnormal sl1.p ~sl1.N] + [Graphics3D..facetnormal sl2.p ~sl2.N] + [Graphics3D..facetnormal [T sl2.p] [T ~sl2.N]]] & - [facet sl1.p--[T sl2.p]--[T sl1.p]--cycle - [facetnormal sl1.p ~sl1.N] - [facetnormal [T sl2.p] [T ~sl2.N]] - [facetnormal [T sl1.p] [T ~sl1.N]]] + [Graphics3D..facet sl1.p--[T sl2.p]--[T sl1.p]--cycle + [Graphics3D..facetnormal sl1.p ~sl1.N] + [Graphics3D..facetnormal [T sl2.p] [T ~sl2.N]] + [Graphics3D..facetnormal [T sl1.p] [T ~sl1.N]]] } - null3D + Graphics3D..null ] } makeSectionDefaultNormal: \ profile phiSteps thetaSteps → { - stepLength: [abs profile] / phiSteps - T: [rotate3D dir:(0,0,1) angle: 360° / thetaSteps] + stepLength: [Numeric..Math..abs profile] / phiSteps + T: [Geometry3D..rotate dir:(0,0,1) angle: 360° / thetaSteps] - [[range '0 phiSteps-'1].foldl + [[Data..range '0 phiSteps-'1].foldl \ p e → { sl1: [profile e * stepLength] sl2: [profile ( e + '1 ) * stepLength] p & - [facet sl1.p--sl2.p--[T sl2.p]--[T sl1.p]--cycle] + [Graphics3D..facet sl1.p--sl2.p--[T sl2.p]--[T sl1.p]--cycle] } - null3D + Graphics3D..null ] } @@ -67,13 +67,13 @@ makeSectionDefaultNormal: \ profile phiSteps thetaSteps → revolutionBody: \ profile phiSteps:36 thetaSteps:36 → { section: [makeSectionDefaultNormal profile phiSteps thetaSteps] - [[range '0 thetaSteps-'1].foldl + [[Data..range '0 thetaSteps-'1].foldl \ p e → { p & - [[rotate3D dir:(0,0,1) angle: 360°*((e*1)/thetaSteps)] section] + [[Geometry3D..rotate dir:(0,0,1) angle: 360°*((e*1)/thetaSteps)] section] } - null3D + Graphics3D..null ] } diff --git a/resources/extensions/Shapes/Layout/basic-layout.shext b/resources/extensions/Shapes/Layout/basic-layout.shext index 26eafb29..97caf982 100644 --- a/resources/extensions/Shapes/Layout/basic-layout.shext +++ b/resources/extensions/Shapes/Layout/basic-layout.shext @@ -16,6 +16,9 @@ ** Copyright 2008, 2014, 2015 Henrik Tidefelt **/ +##lookin ..Shapes +##lookin ..Shapes..Geometry + /** ** Functions for finding coordinates of rectangle bounding a path. **/ @@ -78,7 +81,7 @@ center_wlm: \ obj z → **/ mediate: \ r x1 x2 → (1-r)*x1 + r*x2 -mspoint: \ pth mediation slide:0cm → [pth mediation * [abs pth] + slide].p +mspoint: \ pth mediation slide:0cm → [pth mediation * [Numeric..Math..abs pth] + slide].p @@ -90,36 +93,36 @@ mspoint: \ pth mediation slide:0cm → [pth mediation * [abs pth] + slide].p bboxed_sym: \ obj → { bb: [bbox obj] - rx: [max ~[xmin bb] [xmax bb]] - ry: [max ~[ymin bb] [ymax bb]] - [bboxed obj [rectangle (~rx,~ry) (rx,ry)]] + rx: [Numeric..Math..max ~[xmin bb] [xmax bb]] + ry: [Numeric..Math..max ~[ymin bb] [ymax bb]] + [bboxed obj [Geometry..rectangle (~rx,~ry) (rx,ry)]] } |** This function enlarges the bbox vertically so that its vertical midpoint is 0. bboxed_sym_y: \ obj → { bb: [bbox obj] - ry: [max ~[ymin bb] [ymax bb]] - [bboxed obj [rectangle (~[xmin bb],~ry) ([xmax bb],ry)]] + ry: [Numeric..Math..max ~[ymin bb] [ymax bb]] + [bboxed obj [Geometry..rectangle (~[xmin bb],~ry) ([xmax bb],ry)]] } |** This function enlarges the bbox horizontally. Compare bboxed_sym_y. bboxed_sym_x: \ obj → { bb: [bbox obj] - rx: [max ~[xmin bb] [xmax bb]] - [bboxed obj [rectangle (~rx,[ymin bb]) (rx,[ymax bb])]] + rx: [Numeric..Math..max ~[xmin bb] [xmax bb]] + [bboxed obj [Geometry..rectangle (~rx,[ymin bb]) (rx,[ymax bb])]] } |** This function enlarges the bbox in all directions. bboxed_enlarge: \ obj xy → { bb: [bbox obj] - [bboxed obj [rectangle ([xmin bb]-xy.x,[ymin bb]-xy.y) ([xmax bb]+xy.x,[ymax bb]+xy.y)]] + [bboxed obj [Geometry..rectangle ([xmin bb]-xy.x,[ymin bb]-xy.y) ([xmax bb]+xy.x,[ymax bb]+xy.y)]] } enlarge_bleedbox: \ obj xy → { bb: [bbox obj 'bleed] - [bboxed obj [rectangle ([xmin bb]-xy.x,[ymin bb]-xy.y) ([xmax bb]+xy.x,[ymax bb]+xy.y)] 'bleed] + [bboxed obj [Geometry..rectangle ([xmin bb]-xy.x,[ymin bb]-xy.y) ([xmax bb]+xy.x,[ymax bb]+xy.y)] 'bleed] } diff --git a/resources/extensions/Shapes/Layout/centering-X.shext b/resources/extensions/Shapes/Layout/centering-X.shext index 665ae509..826710b9 100644 --- a/resources/extensions/Shapes/Layout/centering-X.shext +++ b/resources/extensions/Shapes/Layout/centering-X.shext @@ -19,5 +19,5 @@ ##needs / basic-layout Xcenter_y: - {thebb: [bbox [TeX `$X$´]] + {thebb: [Layout..bbox [Graphics..TeX `$X$´]] \ obj y:0 → [[shift (0cm, ~(y+1)/2*[ymax thebb])] obj]} diff --git a/resources/extensions/Shapes/Layout/shiftoff.shext b/resources/extensions/Shapes/Layout/shiftoff.shext index ff34ffc6..9ee9e1ef 100644 --- a/resources/extensions/Shapes/Layout/shiftoff.shext +++ b/resources/extensions/Shapes/Layout/shiftoff.shext @@ -38,34 +38,34 @@ dirtopoint: \ d → [if d = to_lrt (~1,1) [if d = to_urt (~1,~1) [if d = to_ulft (1,~1) - [error [sprintf [`The following direction constant was not recognized by dirtopoint: %g´ d]]]]]]]]]]]] + [error [String..sprintf [`The following direction constant was not recognized by dirtopoint: %g´ d]]]]]]]]]]]] to_dir: \ z → [if z.x > 0 [if z.y > 0 - [if [abs z.x] > 2*[abs z.y] + [if [Numeric..Math..abs z.x] > 2*[Numeric..Math..abs z.y] to_rt - [if [abs z.y] > 2*[abs z.x] + [if [Numeric..Math..abs z.y] > 2*[Numeric..Math..abs z.x] to_top to_urt]] - [if [abs z.x] > 2*[abs z.y] + [if [Numeric..Math..abs z.x] > 2*[Numeric..Math..abs z.y] to_rt - [if [abs z.y] > 2*[abs z.x] + [if [Numeric..Math..abs z.y] > 2*[Numeric..Math..abs z.x] to_bot to_lrt]]] [if z.y > 0 - [if [abs z.x] > 2*[abs z.y] + [if [Numeric..Math..abs z.x] > 2*[Numeric..Math..abs z.y] to_lft - [if [abs z.y] > 2*[abs z.x] + [if [Numeric..Math..abs z.y] > 2*[Numeric..Math..abs z.x] to_top to_ulft]] - [if [abs z.x] > 2*[abs z.y] + [if [Numeric..Math..abs z.x] > 2*[Numeric..Math..abs z.y] to_lft - [if [abs z.y] > 2*[abs z.x] + [if [Numeric..Math..abs z.y] > 2*[Numeric..Math..abs z.x] to_bot to_llft]]]] -dir_to: \ d → [dir 180° + d * 45°] +dir_to: \ d → [..Shapes..Geometry..dir 180° + d * 45°] shiftoff: \ obj d → [center obj [dirtopoint d]] shiftoff_wlm: \ obj d → [Layout..center_wlm obj [dirtopoint d]] diff --git a/resources/extensions/Shapes/Numeric/Constant/constants.shext b/resources/extensions/Shapes/Numeric/Constant/constants.shext index 05cdd33e..62c8ac68 100644 --- a/resources/extensions/Shapes/Numeric/Constant/constants.shext +++ b/resources/extensions/Shapes/Numeric/Constant/constants.shext @@ -16,5 +16,5 @@ ** Copyright 2008, 2014, 2015 Henrik Tidefelt **/ -golden: ( [sqrt 5] + 1 ) / 2 +golden: ( [Numeric..Math..sqrt 5] + 1 ) / 2 Golden: 1 / golden diff --git a/source/astvar.cc b/source/astvar.cc index c99c0187..54cf874f 100644 --- a/source/astvar.cc +++ b/source/astvar.cc @@ -1750,7 +1750,7 @@ Ast::LexiographicType::~LexiographicType( ) { delete *idKey_; } - delete idKey_; // This can be done only as long as this is not shared! + delete idKey_; /* This can be done only as long as this is not shared! */ } void diff --git a/source/consts.cc b/source/consts.cc index 6ffdb2ad..953f2cd2 100644 --- a/source/consts.cc +++ b/source/consts.cc @@ -61,7 +61,7 @@ const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_String const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Text = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Text" ); const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Text_Font = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Text, "Font" ); const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits = makeCoreNamespacePath( *Lang::THE_NAMESPACE_Shapes, "Traits" ); -const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Gray = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Gray" ); +const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_BW = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "BW" ); const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Blend = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Blend" ); const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Cap = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Cap" ); const RefCountPtr< const Ast::NamespacePath > Lang::THE_NAMESPACE_Shapes_Traits_Device = makeCoreNamespacePath( *THE_NAMESPACE_Shapes_Traits, "Device" ); @@ -111,8 +111,8 @@ const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_WIDTH( Lang::THE_NAMESPACE const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_NONSTROKING( Lang::THE_NAMESPACE_Shapes_Traits, "nonstroking" ); const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_AUTOINTENSITY( Lang::THE_NAMESPACE_Shapes_Traits_Light, "autointensity" ); -const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_SIZE( Lang::THE_NAMESPACE_Shapes_Text, "text_size" ); -const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_FONT( Lang::THE_NAMESPACE_Shapes_Text, "text_font" ); +const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_SIZE( Lang::THE_NAMESPACE_Shapes_Text, "size" ); +const Ast::PlacedIdentifier Lang::DYNAMIC_VARIABLE_ID_TEXT_FONT( Lang::THE_NAMESPACE_Shapes_Text, "font" ); const Ast::MemberMode Ast::MEMBER_ACCESS_BITS = 0x000F; const Ast::MemberMode Ast::MEMBER_ACCESS_PRIVATE = 0x0000; diff --git a/source/consts.h b/source/consts.h index 51264cc1..ca7a53ce 100644 --- a/source/consts.h +++ b/source/consts.h @@ -73,7 +73,7 @@ namespace Shapes extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Text; extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Text_Font; extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits; - extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits_Gray; + extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits_BW; extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits_Blend; extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits_Cap; extern const RefCountPtr< const Ast::NamespacePath > THE_NAMESPACE_Shapes_Traits_Device; diff --git a/source/coreast.cc b/source/coreast.cc index b270f43f..1dab4090 100644 --- a/source/coreast.cc +++ b/source/coreast.cc @@ -266,7 +266,7 @@ namespace Shapes RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_coords2D( new Lang::Core_coords2D( Lang::THE_NAMESPACE_Shapes_Geometry, "coords" ) ); RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_cornercoords2D( new Lang::Core_cornercoords2D( Lang::THE_NAMESPACE_Shapes_Geometry, "cornercoords" ) ); -RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_coords3D( new Lang::Core_coords3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "coords3D" ) ); +RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_coords3D( new Lang::Core_coords3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "coords" ) ); RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_polarHandle2DFree_r( new Lang::Core_polarHandle2DFree_r( Lang::THE_NAMESPACE_Shapes_Geometry, "polarHandleFree_r" ) ); RefCountPtr< const Lang::CoreFunction > Ast::THE_FUNCTION_polarHandle2DFree_ra( new Lang::Core_polarHandle2DFree_ra( Lang::THE_NAMESPACE_Shapes_Geometry, "polarHandleFree_ra" ) ); /* This belongs in consts.cc but we must make sure it is initialized before we use it below. Note that the identifier will actually be destroyed diff --git a/source/coreconstruct.cc b/source/coreconstruct.cc index 052ca828..0d70d01a 100644 --- a/source/coreconstruct.cc +++ b/source/coreconstruct.cc @@ -3056,10 +3056,10 @@ Kernel::registerCore_construct( Kernel::Environment * env ) env->initDefineCoreFunction( new Lang::Core_affinetransform( Lang::THE_NAMESPACE_Shapes_Geometry, "affinetransform" ) ); env->initDefineCoreFunction( new Lang::Core_shift( Lang::THE_NAMESPACE_Shapes_Geometry, "shift" ) ); env->initDefineCoreFunction( new Lang::Core_rotate( Lang::THE_NAMESPACE_Shapes_Geometry, "rotate" ) ); - env->initDefineCoreFunction( new Lang::Core_rotate3d( Lang::THE_NAMESPACE_Shapes_Geometry3D, "rotate3D" ) ); + env->initDefineCoreFunction( new Lang::Core_rotate3d( Lang::THE_NAMESPACE_Shapes_Geometry3D, "rotate" ) ); env->initDefineCoreFunction( new Lang::Core_scale( Lang::THE_NAMESPACE_Shapes_Geometry, "scale" ) ); - env->initDefineCoreFunction( new Lang::Core_scale3d( Lang::THE_NAMESPACE_Shapes_Geometry3D, "scale3D" ) ); - env->initDefineCoreFunction( new Lang::Core_affinetransform3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "affinetransform3D" ) ); + env->initDefineCoreFunction( new Lang::Core_scale3d( Lang::THE_NAMESPACE_Shapes_Geometry3D, "scale" ) ); + env->initDefineCoreFunction( new Lang::Core_affinetransform3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "affinetransform" ) ); env->initDefineCoreFunction( new Lang::Core_inverse( Lang::THE_NAMESPACE_Shapes_Geometry, "inverse" ) ); env->initDefineCoreFunction( new Lang::Core_formxo( Lang::THE_NAMESPACE_Shapes_Graphics_PDF, "formxo" ) ); diff --git a/source/coredecomp.cc b/source/coredecomp.cc index 7283d7dc..5bd84921 100644 --- a/source/coredecomp.cc +++ b/source/coredecomp.cc @@ -360,5 +360,5 @@ void Kernel::registerCore_decomp( Kernel::Environment * env ) { env->initDefineCoreFunction( new Lang::Core_Schur_decomposition( Lang::THE_NAMESPACE_Shapes_Geometry3D, "Schur_decomp" ) ); - env->initDefineCoreFunction( new Lang::Core_rotationMapping3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "rotationMap3D" ) ); + env->initDefineCoreFunction( new Lang::Core_rotationMapping3D( Lang::THE_NAMESPACE_Shapes_Geometry3D, "rotationMap" ) ); } diff --git a/source/coremisc.cc b/source/coremisc.cc index 711ea363..93cbd8ab 100644 --- a/source/coremisc.cc +++ b/source/coremisc.cc @@ -443,9 +443,9 @@ Kernel::registerCore_misc( Kernel::Environment * env ) env->initDefineCoreFunction( new Lang::Core_typeof( Lang::THE_NAMESPACE_Shapes, "typeof" ) ); env->initDefineCoreFunction( new Lang::Core_error( Lang::THE_NAMESPACE_Shapes, "error" ) ); env->initDefineCoreFunction( new Lang::Core_show( Lang::THE_NAMESPACE_Shapes_String, "show" ) ); - env->initDefineCoreFunction( new Lang::Core_typename( Lang::THE_NAMESPACE_Shapes, "typename" ) ); - env->initDefineCoreFunction( new Lang::Core_debuglog_before( Lang::THE_NAMESPACE_Shapes_Debug, "debuglog_before" ) ); - env->initDefineCoreFunction( new Lang::Core_debuglog_after( Lang::THE_NAMESPACE_Shapes_Debug, "debuglog_after" ) ); + env->initDefineCoreFunction( new Lang::Core_typename( Lang::THE_NAMESPACE_Shapes_Debug, "typename" ) ); + env->initDefineCoreFunction( new Lang::Core_debuglog_before( Lang::THE_NAMESPACE_Shapes_Debug, "log_before" ) ); + env->initDefineCoreFunction( new Lang::Core_debuglog_after( Lang::THE_NAMESPACE_Shapes_Debug, "log_after" ) ); env->initDefineCoreFunction( new Lang::Core_if( Lang::THE_NAMESPACE_Shapes, "if" ) ); env->initDefineCoreFunction( new Lang::NullFunction( Lang::THE_NAMESPACE_Shapes, "ignore" ) ); env->initDefineCoreFunction( new Lang::Core_rectangle( Lang::THE_NAMESPACE_Shapes_Geometry, "rectangle" ) ); diff --git a/source/globals.cc b/source/globals.cc index be7ea320..8adecbd8 100644 --- a/source/globals.cc +++ b/source/globals.cc @@ -167,9 +167,9 @@ Shapes::Kernel::registerGlobals( Kernel::Environment * env ) env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Join, "MITER", RefCountPtr< const Lang::JoinStyle >( new Lang::JoinStyle( Lang::JoinStyle::JOIN_MITER ) ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Join, "ROUND", RefCountPtr< const Lang::JoinStyle >( new Lang::JoinStyle( Lang::JoinStyle::JOIN_ROUND ) ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Join, "BEVEL", RefCountPtr< const Lang::JoinStyle >( new Lang::JoinStyle( Lang::JoinStyle::JOIN_BEVEL ) ) ); - env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Gray, "BLACK", Lang::THE_BLACK ); - env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Gray, "OCCLUDING", Lang::THE_OCCLUDING_WHITE ); - env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_Gray, "WHITE", RefCountPtr< const Lang::Gray >( new Lang::Gray( Concrete::Gray( 1 ) ) ) ); + env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_BW, "BLACK", Lang::THE_BLACK ); + env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_BW, "OCCLUDING", Lang::THE_OCCLUDING_WHITE ); + env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_BW, "WHITE", RefCountPtr< const Lang::Gray >( new Lang::Gray( Concrete::Gray( 1 ) ) ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_RGB, "BLACK", RefCountPtr< const Lang::RGB >( new Lang::RGB( Concrete::RGB( 0, 0, 0 ) ) ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_RGB, "WHITE", RefCountPtr< const Lang::RGB >( new Lang::RGB( Concrete::RGB( 1, 1, 1 ) ) ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Traits_RGB, "RED", RefCountPtr< const Lang::RGB >( new Lang::RGB( Concrete::RGB( 1, 0, 0 ) ) ) ); diff --git a/source/hottypes.cc b/source/hottypes.cc index 790d6cf1..b1e82fdd 100644 --- a/source/hottypes.cc +++ b/source/hottypes.cc @@ -2079,8 +2079,8 @@ Kernel::registerHot( Kernel::Environment * env ) env->initDefine( Lang::THE_NAMESPACE_Shapes_Graphics3D, "newGroup", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmGroup3D > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Graphics3D, "newZBuf", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmZBuf > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Graphics3D, "newZSorter", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmZSorter > ) ); - env->initDefine( Lang::THE_NAMESPACE_Shapes_Graphics3D, "newString", Kernel::ValueRef( new Lang::HotDefault< Kernel::Warm_ostringstream > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Graphics3D, "newLights", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmGroupLights > ) ); + env->initDefine( Lang::THE_NAMESPACE_Shapes_String, "newString", Kernel::ValueRef( new Lang::HotDefault< Kernel::Warm_ostringstream > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes, "newTimer", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmTimer > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Text, "newText", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmText > ) ); env->initDefine( Lang::THE_NAMESPACE_Shapes_Text, "newFont", Kernel::ValueRef( new Lang::HotDefault< Kernel::WarmType3Font > ) ); diff --git a/source/testers/dist.cc b/source/testers/dist.cc index 6c181774..3ca88c8a 100644 --- a/source/testers/dist.cc +++ b/source/testers/dist.cc @@ -551,7 +551,7 @@ main( int argc, char ** argv ) break; case 3: { - std::cout << std::fixed << "poly1: @nonstrokingalpha:[alphaopacity 0.5] & @nonstroking:[rgb 0.7 0.3 0.3] | ( newGroup3D" ; + std::cout << std::fixed << "poly1: @nonstrokingalpha:[alphaopacity 0.5] & @nonstroking:[rgb 0.7 0.3 0.3] | ( Graphics3D..newGroup" ; { const double * begin = g1; const double * end = begin + dim * n1; @@ -579,7 +579,7 @@ main( int argc, char ** argv ) } } std::cout << ")" << std::endl ; - std::cout << "poly2: @nonstrokingalpha:[alphaopacity 0.5] & @nonstroking:[rgb 0.3 0.7 0.3] | ( newGroup3D" ; + std::cout << "poly2: @nonstrokingalpha:[alphaopacity 0.5] & @nonstroking:[rgb 0.3 0.7 0.3] | ( Graphics3D..newGroup" ; { const double * begin = g2; const double * end = begin + dim * n1; diff --git a/test/graphics/approximate2d.shape b/test/graphics/approximate2d.shape index d64ccefd..1879141c 100644 --- a/test/graphics/approximate2d.shape +++ b/test/graphics/approximate2d.shape @@ -1,16 +1,16 @@ -pth: @defaultunit:1%c | (0cm,0cm)>(^90°)--(^90°)<(2cm,0cm) +pth: Geometry..@defaultunit:1%c | (0cm,0cm)>(^90°)--(^90°)<(2cm,0cm) -•page ≪ [stroke pth] +IO..•page ≪ [Graphics..stroke pth] -•page ≪ +IO..•page ≪ ( @width: 0.2bp | - [[range '1 '10].foldl + [[Data..range '1 '10].foldl \ pile i →! { p: (~2cm+i*0.5cm,0.6cm) - pile & [stroke p--[approximator pth p].p ] + pile & [Graphics..stroke p--[approximator pth p].p ] } null] ) diff --git a/test/graphics/bad.shape b/test/graphics/bad.shape index 541020ed..cc2c688b 100644 --- a/test/graphics/bad.shape +++ b/test/graphics/bad.shape @@ -1 +1 @@ -•stderr ≪ `This file forgets to produce graphics...´ ≪ "{n} +IO..•stderr ≪ `This file forgets to produce graphics...´ ≪ "{n} diff --git a/test/graphics/dyn-thunk.shape b/test/graphics/dyn-thunk.shape dissimilarity index 88% index e80fa68d..f1d3a485 100644 --- a/test/graphics/dyn-thunk.shape +++ b/test/graphics/dyn-thunk.shape @@ -1,72 +1,72 @@ -/** - ** This test was introduced after a bug was detected. - **/ - -font: @text_size:1cm -##unit dx = 4cm - -{ -fun: \ str tobj → - ( font | ( newText << str << tobj << [kerning str] << `B´ << [kerning `b´] ) ) -x:0dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} - -{ -fun: \ str tobj → - ( newText << ( font | str ) << tobj << [kerning str] << `B´ << [kerning `b´] ) -x:1dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} - -{ -fun: \ str tobj → - ( newText << str << ( font | tobj ) << [kerning str] << `B´ << [kerning `b´] ) -x:2dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} - -{ -fun: \ str tobj → - ( newText << str << tobj << ( font | [kerning str] ) << `B´ << [kerning `b´] ) -x:3dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} - -{ -fun: \ str tobj → - ( newText << str << tobj << [kerning str] << ( font | `B´ ) << [kerning `b´] ) -x:4dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} - -{ -fun: \ str tobj → - ( newText << str << tobj << [kerning str] << `B´ << ( font | [kerning `b´] ) ) -x:5dx - -•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] -•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) -•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] -•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] -} +/** + ** This test was introduced after a bug was detected. + **/ + +font: Text..@size:1cm +##unit dx = 4cm + +{ +fun: \ str tobj → + ( font | ( Text..newText << str << tobj << [kerning str] << `B´ << [kerning `b´] ) ) +x:0dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} + +{ +fun: \ str tobj → + ( Text..newText << ( font | str ) << tobj << [kerning str] << `B´ << [kerning `b´] ) +x:1dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} + +{ +fun: \ str tobj → + ( Text..newText << str << ( font | tobj ) << [kerning str] << `B´ << [kerning `b´] ) +x:2dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} + +{ +fun: \ str tobj → + ( Text..newText << str << tobj << ( font | [kerning str] ) << `B´ << [kerning `b´] ) +x:3dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} + +{ +fun: \ str tobj → + ( Text..newText << str << tobj << [kerning str] << ( font | `B´ ) << [kerning `b´] ) +x:4dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} + +{ +fun: \ str tobj → + ( Text..newText << str << tobj << [kerning str] << `B´ << ( font | [kerning `b´] ) ) +x:5dx + +IO..•page << [shift (x,~0cm)] [] [fun `A´ [kerning `a´]] +IO..•page << font | ( [shift (x,~2cm)] [] [fun `A´ [kerning `a´]] ) +IO..•page << [shift (x,~4cm)] [] [fun (font | `A´) [kerning `a´]] +IO..•page << [shift (x,~6cm)] [] [fun `A´ (font | [kerning `a´])] +} diff --git a/test/graphics/hello.shape b/test/graphics/hello.shape index 9166cfb8..8d5b3159 100644 --- a/test/graphics/hello.shape +++ b/test/graphics/hello.shape @@ -1 +1 @@ -•page ≪ stroke [] (0cm,0cm)--(1cm,1cm) +IO..•page ≪ stroke [] (0cm,0cm)--(1cm,1cm) diff --git a/test/graphics/texlabel.shape b/test/graphics/texlabel.shape index 3b37b5d4..fbcdf59d 100644 --- a/test/graphics/texlabel.shape +++ b/test/graphics/texlabel.shape @@ -1,17 +1,17 @@ ##preamble \usepackage{fancybox} ##preamble \usepackage{mypackage} -helper: \ obj → ( @nonstroking:[gray 0.8] | [fill [bbox obj 'bounding]] ) & obj +helper: \ obj → ( @nonstroking:[gray 0.8] | [Graphics..fill [Layout..bbox obj 'bounding]] ) & obj -/** In order to make the test insensitive to minor font differences between different TeX distributions, - ** the content of the TeX label has been changed from a piece of display math to a very simple figure +/** In order to make the test insensitive to minor font differences between different Graphics..TeX distributions, + ** the content of the Graphics..TeX label has been changed from a piece of display math to a very simple figure ** using only the \rule commands. **/ -@TeX_bleed:5bp +Layout..@TeX_bleed:5bp | helper [] -[TeX ` +[Graphics..TeX ` \newlength{\U} \setlength{\U}{10mm} \newlength{\w} diff --git a/test/text/bad.shape b/test/text/bad.shape index 226b313d..d7767d63 100644 --- a/test/text/bad.shape +++ b/test/text/bad.shape @@ -1 +1 @@ -•page ≪ stroke [] +IO..•page ≪ stroke [] diff --git a/test/text/dynamic.shape b/test/text/dynamic.shape index 7dff13a6..e0b99429 100644 --- a/test/text/dynamic.shape +++ b/test/text/dynamic.shape @@ -1,10 +1,10 @@ dynamic @a ( \ x → 2 * x ) 1 -•stdout << @a << "{n} +IO..•stdout << @a << "{n} << @a:2 | @a << "{n} dynamic @b identity [error `Dynamic variable has no default binding.´] -•stdout << @b:(4+3) | @b << ` No error see?´ << "{n} +IO..•stdout << @b:(4+3) | @b << ` No error see?´ << "{n} @spot diff --git a/test/text/scopes.shape b/test/text/scopes.shape index ceff83a9..7f603ac4 100644 --- a/test/text/scopes.shape +++ b/test/text/scopes.shape @@ -3,17 +3,17 @@ a: 1 a: 2 { a: 3 - •stdout ≪ `a0 = ´ ≪ a ≪ "{n} - •stdout ≪ `a1 = ´ ≪ ../a ≪ "{n} - •stdout ≪ `a2 = ´ ≪ ../../a ≪ "{n} + IO..•stdout ≪ `a0 = ´ ≪ a ≪ "{n} + IO..•stdout ≪ `a1 = ´ ≪ ../a ≪ "{n} + IO..•stdout ≪ `a2 = ´ ≪ ../../a ≪ "{n} } } { odd: \ n → [if n = 0 false [even n-1]] even: \ n → [if n = 0 true [odd n-1]] - •stdout ≪ `Is 0 odd? --> ´ ≪ [odd 0] ≪ "{n} - •stdout ≪ `Is 4 even? --> ´ ≪ [even 4] ≪ "{n} + IO..•stdout ≪ `Is 0 odd? --> ´ ≪ [odd 0] ≪ "{n} + IO..•stdout ≪ `Is 4 even? --> ´ ≪ [even 4] ≪ "{n} } -- 2.11.4.GIT