Jux Reference (deprecated version)

From Picogen-doc

(Redirected from Height Slang Reference)

Contents

Abstract

Height-Slang is a language for the definition of heightmaps [1].It is used in mkheightmap, itself being a powerfull tool (a part of the puzzle of picogen [2]) to generate heightmaps on the command-line.

This article is based on a transcription of [3].



Height-Slang Reference

The next sections show the currently supported instructions of height-slang, following this convention:

  • A greek letter (α, β, γ, etc.) indicates an arbitrary expression
  • Each item looks like <function-syntax> \equiv <math~notation> or <function-syntax> = <equivalent~expression> \equiv <math~notation>

Note that there is only one data type in Height-Slang: real. This means we have to introduce kludges to anyway be able to solve boolean expressions:


  • A real-value α is considered true, if and only if \alpha\ge0.5, else it is considered false


This rule applies to the first parameter of the "?"-function, and to any parameter of the logical functions "and", "or", "xor", "not". Additionally, a value of either 1.0 (true) or 0.0 (false) is returned by the comparison functions, so they can safely be used for the "?"-function as the first parameter, but also as a "on/off"-factor in general expressions (that leads to a kind of branch free code).



Comparison Functions

Name Syntax picogen-version
Less-Than (<~\alpha~\beta) \equiv {\alpha}<{\beta} 0.1
Less-Or-Equal (<=~\alpha~\beta) \equiv {\alpha}\le{\beta} 0.1
Greater-Than (>~\alpha~\beta) \equiv {\alpha}>{\beta} 0.1
Greater-Or-Equal (>=~\alpha~\beta) \equiv {\alpha}\ge{\beta} 0.1
Equal (=~\alpha~\beta) \equiv {\alpha}={\beta} 0.1
Not-Equal (<>~\alpha~\beta) \equiv {\alpha}\ne{\beta} 0.1

Basic Arithmetics

Name Syntax picogen-version
Addition (+~\alpha~\beta) \equiv \alpha+\beta 0.1
Subtraction (-~\alpha~\beta) \equiv \alpha-\beta 0.1
Multiplication (*~\alpha~\beta) \equiv \alpha\cdot\beta 0.1
Division (/~\alpha~\beta) \equiv \alpha \div \beta 0.1
Power (^\wedge\alpha~\beta) \equiv \alpha^\beta 0.1

Functions With One Parameter

Name Syntax picogen-version
Inverse (inv~\alpha) = (/~1~\alpha) \equiv 1 \div \alpha 0.1
Sine (sin~\alpha) \equiv \sin(\alpha) 0.1
Cosine (cos~\alpha) \equiv \cos(\alpha) 0.2 (actually 0.1, but it had a bug then)
Floor (floor~\alpha) \equiv floor(\alpha) 0.1
Absolute (abs~\alpha) \equiv abs(\alpha) 0.1
Truncate (trunc~\alpha) \equiv trunc(\alpha) 0.1
Fractional (frac~\alpha) = (-~\alpha~(floor~\alpha)) \equiv \alpha - floor(\alpha) 0.1
Negate (neg~\alpha) = (-~0~\alpha) \equiv -\alpha 0.1
Square-Root (sqrt~\alpha) \equiv \sqrt{\alpha} 0.1
Logical Not (not~\alpha) \equiv ? 0.1

Functions With Two Parameters

Name Syntax picogen-version
Logical And (and~\alpha~\beta) \equiv \alpha \texttt{ and }\beta 0.1
Logical Or (or~\alpha~\beta) \equiv \alpha \texttt{ or }\beta 0.1
Logical Xor (xor~\alpha~\beta) \equiv \alpha \texttt{ xor }\beta 0.1
Min (Minimum) (min~\alpha~\beta) \equiv \alpha ~~if\alpha\le\beta, ~~else~\beta 0.2
Max (Maximum) (max~\alpha~\beta) \equiv \alpha ~~if\alpha\ge\beta, ~~else~\beta 0.2
Delta (delta~\alpha~\beta) \equiv 0 ~~if~\alpha<\beta,~~else~1 0.2

Functions With Three Parameters

Name Syntax picogen-version
If-Then-Else (?~\alpha~\beta~\gamma) = \beta ~~if~\alpha,~~else~\gamma 0.1
Linear Interpolation (lerp~\alpha~\beta~\gamma) = (+~(*~\alpha~(-~1~\gamma))~(*~\beta~\gamma))  \equiv \alpha\cdot(1-\gamma) + \beta\cdot \gamma 0.1

Configurable Functions

LayeredNoise

   ([2 LayeredNoise 
         seed(<positive integer>)                                <default: 42>
         frequency(<real number>)                                <default: 2.0>
         layercount(<positive integer>)                          <default: 4>        
         filter(<nearest|bilinear|cosine>)                       <default: nearest>
         persistence(<1-dimensional HS expression>)              <default: 0.5>
         levelEvaluationFunction(<1-dimensional HS expression>)) <default: x>
    ] 
    parameter_a
    parameter_b
   )

Noise

(new in picogen 0.2)

   ([2 Noise
         seed(<positive integer>)                                <default: 42>
         frequency(<real number>                                 <default: 2.0>
         filter(<nearest|bilinear|cosine>)                       <default: nearest>
    ] 
    parameter_a
    parameter_b
   )

Layers

(new in picogen 0.2)

   ([2 Layers 
         base(<base-function>)                                   <default: ([2 Noise] xy) >
         frequency(<real number>)                                <default: 2.0>
         layercount(<positive integer>)                          <default: 4>        
         persistence(<1-dimensional HS expression>)              <default: 0.5>
         levelEvaluationFunction(<1-dimensional HS expression>)) <default: x>
    ] 
    parameter_a
    parameter_b
   )