Curv Versions Save

a language for making art using mathematics

0.5

2 years ago

Curv Changes since Release 0.4

There are multiple language changes, with deprecation warnings for old syntax. You should fix deprecation warnings now if you have old Curv code, because the old syntax will be removed in a future release. By default, deprecation warnings are throttled. Use curv -v to see all warnings. Features marked experimental are unstable, subject to change.

Platform/Build Support

Curv 0.5 includes a prebuilt AppImage for Linux.

  • @ComFreek -- Windows port.
  • @zeeyang: automated MacOS build (using github actions)
  • @A-G-D: automated AppImage build for Linux (using github actions)
  • Apple Silicon support on Macintosh.
  • AMD GPUs supported on Linux using AMD Mesa 19.x driver.
  • documented/tested exporting images on a headless Linux server.
  • make upgrade command

File Import/Export

  • @Xiaoyuew -- Faster mesh export (multi-threaded, multi-core).
  • @zeeyang: add jgpu export file format (GPU program as JSON)
  • @zeeyang: add GLTF export file format
  • @zeeyang: remove curvc (no longer being built)
  • curv dirname reads a directory as a Curv program (directory format)
  • JSON export no longer tries hard to distinguish JSON from non-JSON data. Non-JSON data is now exported as a string. #foo exports as "foo". sin exports as "<function sin>".

Command Line

  • @A-G-D: filename now optional in curv -le, default is new.curv
  • Configuration file ~/.config/curv contains defaults for -O options, is a Curv source file, a record containing {viewer,export} fields. See docs/Config.rst
  • All -O option values are now specified as Curv expressions. Symbols used in -O options: -Ocolouring=#vertex or -Ocolouring=#face
  • rename -Ocolour= to -Ocolouring=
  • --depr= option controls deprecation warnings

REPL

  • supports := (assignment) statement
  • fully supports generator expressions
  • help in REPL is extremely experimental, only partially implemented
  • see docs/REPL.rst

Rendering in Viewer Window

  • @zeeyang: improved raymarching (backup if overstep due to bad SDF)
  • There are configurable render parameters. For a list, use curv --help.
    • You can set them on the command line using -Oname=value. What's new: value is an arbitrary Curv expression.
    • You can set them in the config file, in the viewer section. [new]
    • You can set them in a shape value by manually adding a render field to the shape structure. [new, experimental]
  • new render parameters:
    • ray_max_iter, ray_max_depth: bug #78 [experimental]
    • shader -- lighting & shadow function for object surface [experimental]

Shape Library

  • @lf94: add lib.builder with snowman example [experimental]
  • @lf94: add soroban example
  • @zeeyang: add 2D polyline primitive
  • @zeeyang: add repeat_finite primitive
  • capped_cone
  • fix show_axes to preserve the bounding box
  • generalized polygon primitive (can be non-convex, self-intersecting)
  • lib.noise [experimental]
  • a >> into union [b, c] means union [a, b, c]

Compiler and Interpreter

  • general tail call optimization
  • better compile/runtime error messages
  • function names in stack traces
  • SubCurv enhancements (more things that compile to GLSL shader language):
    • numeric matrix data types: 2x2, 3x3, 4x4
    • matrix multiplication (dot)
    • boolean vector types: bool2, bool3, bool4, bool32
    • boolean vector operations: and, or, xor, not
    • boolean matrix types: bool2x32, bool3x32, bool4x32
    • better support for parametric variables
  • add docs/Implementation (source code structure, lang. implementation)

Curv Language

  • Quoted identifiers: 'foo bar' is an identifier with an embedded space. 'if' is an identifier, not a reserved word. '_ is an escape sequence representing a literal ' within a quoted identifier.
  • Numbers
    • number patterns like 42 or -0.5
    • sign function returns -1, 0 or 1
    • sum added to SubCurv
  • Lists
    • a++b infix list catenation operator
    • deprecate (a,b,c) list syntax; use [a,b,c] instead
  • A string like "abc" is now a list of characters. Lists are heterogenous, so "abc" ++ [1,2,3] is a list of 6 elements.
    • #"a" is a character literal, and works as a pattern.
    • is_char x is true if x is a character value.
    • char converts an integer or list of integers to a character or string.
    • ucode converts a character or string to an integer or list of integers.
    • encode removed, replaced by ucode.
    • decode removed, replaced by char.
    • string converts an arbitrary value to a string.
    • new escape sequences in string literals: $_ -> $ and "_ -> "
  • Symbols are abstract named values. They replace some uses of strings, but symbols are scalars, not lists. They replace 'enum' values in some languages.
    • #foo or #'hello world' is a symbol literal, which works as a pattern.
    • symbol function constructs symbol from string
    • is_symbol predicate.
    • true, false, null are now just aliases for #true, #false, #null
    • JSON export exports #true, #false, #null as JSON true, false, null.
    • Remove is_null predicate (breaking change).
  • Data structure indexing
    • a.[i] is new array indexing syntax. a[i] is deprecated.
    • r.[#foo] is same as r.foo. Syntax r."foo" is deprecated.
    • a.foo.[i] := ... assignment statements
    • multi-dimensional array slicing using a.[indexlist1,indexlist2]
    • generalized index values (aka lenses, experimental):
      • a.[i] indexes a data structure with index value i
      • integers are index values (they index lists)
      • symbols are index values (they index records)
      • a.[[i1,i2,i3]] yields [a.[i1],a.[i2],a.[i3]]
      • a.[this] yields a`
      • a.[tpath[i1,i2]] yields a.[i1].[i2]
      • a.[i1,i2] is a multidimensional array slice, short for a.[tslice[i1,i2]].
      • amend index newelem tree is pure functional update, like tree.[index]:=newelem without the side effect.
  • Functions:
    • is_fun deprecated, replaced by is_func and is_primitive_func
    • error is a function value (previously was magic syntax)
    • id -- identity function
    • identity renamed to idmatrix
    • compose is generalized to work correctly on partial functions
  • Boolean array operators.
    • SubCurv supports new types Bool32, Bool[2-4], Bool[2-4]x32
    • experimental boolean array operations (also in SubCurv):
      • float_to_bool32, bool32_to_float
      • nat_to_bool32 (in SubCurv, argument must be a constant)
      • bool32_to_nat (not in SubCurv)
      • bool32_sum, bool32_product
      • lshift, rshift
    • vectorized boolean not function; unary ! operator is deprecated
    • vectorized boolean reduction functions and, or, xor
    • vectorized: <, <=, >, >=, bit
    • select [experimental]
  • parametric records have a call field that reruns the constructor with different parameter values. The result is another parametric record, also with a call field.
  • test definitions, for unit tests in a module, or anywhere else
  • sc_test statement, for unit testing SubCurv [experimental]
  • assert_error statement, for writing unit tests
  • comma separated definition lists in let ... and {...}. Previously only ; was allowed as separator.
  • in a statement context, () and (a,b,c) are generators.
  • where is deprecated, use let instead.
  • in a dynamic record literal, [#a,1] is equivalent to a:1, both expressions
  • locative!func1!func2 is a statement, mutates a local variable by applying one or more functions to the contents.
  • deprecate "foo":expr, in expression or pattern context.
  • until clause for early exit from a for loop
  • var definitions are deprecated, use local definitions instead.
  • local <definition> is a generalized local definition, with sequential (not recursive) scope. Legal in any imperative context: do expression, compound statement, list constructor, dynamic record constructor.
  • Only definitions are permitted in the head of a let or in a module (not actions). Use test definitions to add unit tests to a module.
  • Remove 'generalized do'. Only do expressions are supported.
  • fewer levels of operator precedence:
    • unite Power with Unary; not a breaking change; grammar becomes more liberal.
    • unite Relation with Range, breaking change, parse error for 1..3==[1,2,3]

0.4

5 years ago

Graphical value pickers for interactively tweaking shape parameters.

  • parametric constructs a parametric shape, with named parameters that are bound to value-picker types. See docs/language/Parametric_Shapes.rst
  • HUD (head up display) overlays the value picker GUI on top of the shape displayed in the Viewer window. See docs/Viewer.rst

Contributed features:

Language changes:

  • New features used to construct parametric shapes:
    • Parametric records (constructed by parametric) remember how they were constructed by storing metadata.
    • Picker predicates specify a value picker type & its configuration.
    • Predicate assertion patterns associate a predicate function with a variable. Syntax is name :: predicate, eg pi :: is_num = 3.1416. Can be used to associate a "type" with a variable definition or function parameter, or to associate a picker predicate with a shape parameter.
  • Imperative programming
    • generalized := (assignment statement) works on all local variables defined using let, where, for
    • var definitions are deprecated
    • generalized do works in list/record/string comprehensions
    • generalized while works in list/record/string comprehensions
    • See docs/language/Statements.rst
  • String literals
    • multi-line string literals
    • new character names: dol, quot, tab
    • string comprehensions using ${...}
    • $. $= ($$ and "" escapes removed)
    • See docs/language/Strings.rst
  • predicate assertion patterns and expressions using ::
  • where operator is now higher precedence than , or ;. a = b where (bindings) is now legal syntax, is equivalent to a = (b where (bindings)).
  • calls to error now appear in stack trace

Shape Library:

  • lib.blend See docs/lib/Blend.rst
  • cylinder with no argument is cylinder{d:2,h:2}.
  • box with no argument defaults to box[2,2,2].

Geometry Compiler:

  • Experimental support for 1D and 2D arrays of numbers and vectors See docs/language/Geometry_Compiler.rst
  • polymorphic == and != (works on vectors and bools now)
  • a primitive code optimizer
  • -o frag file format replaced by -o gpu. This is a human readable data file that contains the output of the Geometry Compiler. This feature is for debugging and developing the geometry compiler, and the file format is subject to change. The curv tool can now also read GPU files, display them in the Viewer, and you can live edit them.

Breaking Changes:

  • During the development of parametric shapes, the syntax changed multiple times. It has stabilized with the parametric keyword.
  • If you have used the prerelease version of lib.blend, there are two recent changes:
    • lib.blend.stairs(r,n): n is now the # of stair steps
    • lib.blend.pipe(d): d is now the pipe diameter
  • In a string literal, the $$ and "" escapes have been replaced by ${dol} and ${quot}.
  • The var variable definition syntax has been deprecated, will be removed in some future release.
  • The pred pat pattern syntax has been removed, replaced by pat :: pred.

Other changes:

  • Curv now requires OpenGL 3.3
  • curvc is a new statically linked executable that provides a JSON API for running Curv programs. It's for @sebastien's Web GUI work, and may be replaced in the future by a webassembly executable.
  • fix bug in -o json (escaping of control characters in string literals)
  • can export empty/infinite 2D shapes as PNG (defaults to Viewer behaviour)
  • use make uninstall to uninstall Curv
  • all Curv library files are now stored under /usr/local/lib/curv

Because the location of the library files has changed, you may wish to perform a clean install by using:

  [sudo] make uninstall
  [sudo] make install

0.3

5 years ago

Changes from release 0.2:

New options for controlling the viewer window:

  • ctrl-W (or command-W on MacOS) closes the window.
  • The HOME key or R key resets the camera to its home position. (Ivo Cavalcante)
  • -Olazy : Redraw only on user input. Disables animation & FPS counter. This reduces GPU power consumption on a laptop. (Ivo Cavalcante)
  • -Obg=colour sets the background colour (default is white). Use any Curv colour expression, eg -Obg=black.
  • -Oaa=supersampling_factor : enables spatial antialiasing. Try 2, 3 or 4, or 1 to disable. This is expensive and slow, but looks nice.
  • -v : show GLSL shader compile time & object size
  • docs: https://github.com/doug-moen/curv/blob/master/docs/Viewer.rst

Other changes to the 3D viewer window:

  • You can zoom out further before clipping occurs (Ivo Cavalcante).
  • You can zoom in closer before clipping occurs.

New options for PNG export:

  • Export of 3D shapes now possible.
  • -v : log verbose output to stderr
  • -Obg=colour : set background colour
  • -Oaa=supersampling_factor : spatial antialiasing, defaults to '4'
  • -Oanimate=duration_in_seconds : export an image sequence. Used to create animated GIFs or video files from an animated shape.
  • -Ofstart=frame_start_time
  • -Ofdur=frame_duration, used with -Oanimate or -Otaa
  • -Otaa=supersampling_factor : temporal antialiasing
  • PNG export now uses RGB format, instead of RGBA format. Smaller files.
  • docs: https://github.com/doug-moen/curv/blob/master/docs/Image_Export.rst

Language changes:

  • frac n returns the fractional part of n.
  • The hyperbolic functions: sinh cosh tanh asinh acosh atanh.
  • lib: a hierarchical module namespace for the standard library.
  • lib.web_colour: standard CSS colour names. Eg, lib.web_colour.peach_puff.
  • file import now supports directory syntax: https://github.com/doug-moen/curv/blob/master/docs/language/File_Import.rst A prerequisite for lib and the future package manager.

Other changes:

  • Makefile supports make -j4 for parallel compilation (Ivo Cavalcante)
  • in -Oname=value, values are now Curv expressions.
  • Improved error messages.
  • Improved --help text. curv --help -o format now documents the -O options supported by the specified output format.
  • Various minor bug fixes.

I would like to thank Ivo Cavalcante for his contributions to this release.

0.2

5 years ago

changes since version 0.1

  • Deprecation warning if right argument of where not parenthesized.
  • new syntax for file export: 'curv -o foo.stl foo.curv'
  • mesh export: '-O jit' makes export 33x faster using JIT compiler.
  • X3D export: supports both vertex and face colouring.
  • PNG export: rewritten and improved.
  • STL export: now writes facet normals.
  • FRAG export: improved compatibility with shadertoy.com
  • add sort to stdlib.
  • syntax colouring in gedit, the default text editor.
  • colourized error messages.
  • improved error messages and more readable stack traces.
  • improved 'curv --version' output, for use in bug reports.
  • improved 'curv --help' output.
  • removed glslViewer dependency, now use OpenGL APIs directly.
  • removed readline dependency, now using replxx.
  • misc bug fixes and build system improvements.

0.1

6 years ago
  • Shapes can be exported as mesh files for 3D printing (.stl, .obj, .x3d). Full colour 3D printing is supported using .x3d.
  • The GUI is improved: curv -le foo.curv creates a 3 window GUI for "live editing" a source file.
  • The interpreter is faster.