a language for making art using mathematics
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.
Curv 0.5 includes a prebuilt AppImage for Linux.
make upgrade
commandjgpu
export file format (GPU program as JSON)GLTF
export file formatcurvc
(no longer being built)curv dirname
reads a directory as a Curv program (directory format)#foo
exports as "foo"
. sin
exports as "<function sin>"
.curv -le
, default is new.curv
~/.config/curv
contains defaults for -O options,
is a Curv source file, a record containing {viewer,export} fields.
See docs/Config.rst
--depr=
option controls deprecation warningshelp
in REPL is extremely experimental, only partially implementeddocs/REPL.rst
curv --help
.
-Oname=value
.
What's new: value
is an arbitrary Curv expression.viewer
section. [new]render
field
to the shape structure. [new, experimental]shader
-- lighting & shadow function for object surface [experimental]lib.builder
with snowman
example [experimental]soroban
examplepolyline
primitiverepeat_finite
primitivecapped_cone
show_axes
to preserve the bounding boxpolygon
primitive (can be non-convex, self-intersecting)a >> into union [b, c]
means union [a, b, c]
dot
)docs/Implementation
(source code structure, lang. implementation)'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.42
or -0.5
sign
function returns -1, 0 or 1sum
added to SubCurva++b
infix list catenation operator(a,b,c)
list syntax; use [a,b,c]
instead"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.$_
-> $
and "_
-> "
symbol
function constructs symbol from stringis_symbol
predicate.is_null
predicate (breaking change).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 statementsa.[indexlist1,indexlist2]
a.[i]
indexes a data structure with index value i
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.is_fun
deprecated, replaced by is_func
and is_primitive_func
error
is a function value (previously was magic syntax)id
-- identity functionidentity
renamed to idmatrix
compose
is generalized to work correctly on partial functionsnot
function; unary !
operator is deprecatedand
, or
, xor
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 elsesc_test
statement, for unit testing SubCurv [experimental]assert_error
statement, for writing unit testslet ...
and {...}
.
Previously only ;
was allowed as separator.where
is deprecated, use let
instead.locative!func1!func2
is a statement, mutates a local variable by
applying one or more functions to the contents.until
clause for early exit from a for
loopvar
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.let
or in a module
(not actions). Use test
definitions to add unit tests to a module.do
expressions are supported.1..3==[1,2,3]
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
Contributed features:
Language changes:
parametric
) remember how they were
constructed by storing metadata.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.:=
(assignment statement) works on all local variables
defined using let
, where
, for
var
definitions are deprecateddo
works in list/record/string comprehensionswhile
works in list/record/string comprehensionswhere
operator is now higher precedence than ,
or ;
.
a = b where (bindings)
is now legal syntax, is equivalent to
a = (b where (bindings))
.error
now appear in stack traceShape Library:
cylinder
with no argument is cylinder{d:2,h:2}
.box
with no argument defaults to box[2,2,2]
.Geometry Compiler:
-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:
parametric
keyword.lib.blend
, there are two recent changes:
lib.blend.stairs(r,n)
: n is now the # of stair stepslib.blend.pipe(d)
: d is now the pipe diameter$$
and ""
escapes have been replaced by ${dol}
and ${quot}
.var
variable definition syntax has been deprecated, will be removed in some future release.pred pat
pattern syntax has been removed, replaced by pat :: pred
.Other changes:
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.-o json
(escaping of control characters in string literals)make uninstall
to uninstall CurvBecause the location of the library files has changed, you may wish to perform a clean install by using:
[sudo] make uninstall
[sudo] make install
Changes from release 0.2:
New options for controlling the viewer window:
-Obg=black
.Other changes to the 3D viewer window:
New options for PNG export:
Language changes:
frac n
returns the fractional part of n
.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:
make -j4
for parallel compilation (Ivo Cavalcante)curv --help -o format
now documents the -O options
supported by the specified output format.I would like to thank Ivo Cavalcante for his contributions to this release.
changes since version 0.1
where
not parenthesized.sort
to stdlib.curv -le foo.curv
creates a 3 window GUI
for "live editing" a source file.