-
Notifications
You must be signed in to change notification settings - Fork 1
Built In Functions
In the following we list all built-in functions that are supported in Hydra, in alphabetical order. A Funktion is described as function(parameter1:(Type1), parameter2:(Type2), ...).
circle(center:(Pol), radius:(Number))Draws a hyperbolic circle with the passed radius, centered at the specified polar coordinate.
var r = 10
var point = Pol(r: 7.0, phi: M_PI / 8)
circle(center: point, radius: r)clear()Removes all objects from the canvas.
cos(x:(Number))Evaluates the cosine function at the passed value.
var a = cos(x: M_PI) // a = -1cosh(x:(Number))Evaluates the hyperbolic cosine function at the passed value.
var a = cosh(x: 0) // a = 1curve_angle(from:(Pol), to:(Pol), angle:(Number)) {_p:(Pol)}Draws a curve containing the points that have an angular distance of angle to the line between the points from and to.
The parameters from and to are polar coordinates that are required to have the same angular coordinate and the radius of from must be smaller than the radius of to.
The angle parameter needs to evaluate to a number. It is the only parameter that may contain the hidden variable _p. Basically curve_angle draws the curve by walking from point from to point to, and evaluating angle at each point _p.
var R = 10.0
var start = Pol(r: R / 2.0, phi: 0.0)
var end = Pol(r: R, phi: 0.0)
curve_angle(from: start, to: end, angle: theta(r1: _p.r, r2: _p.r, R))distance(from:(Pol), to:(Pol))Returns the hyperbolic distance between the points from and to.
The parameters from and to are polar coordinates.
exp(x:(Number))Evaluates the exponential function at the passed value.
var a = exp(x: 1) // a = 2.71828...line(from:(Pol), to:(Pol))Draws a hyperbolic line between the polar coordinates from and to.
var start = Pol(r: 7.0, phi: 0.0)
var end = Pol(r: 3.0, phi: M_PI / 4.0)
line(from: start, to: end)log(x:(Number))Evaluates the natural logarithm at the passed value.
var a = log(x: exp(x: 1)) // a = 1print(message:(String))Prints the passed message to the console. The message may contain new lines "\n" and is allowed to have escape sequences indicated by \( ).
var a = log(x: exp(x: 1)) // a = 1
print(message: "The natural logarithm of e is: \(a)!\n") // The natural logarithm of e is: 1!random(from:(Number), to:(Number))Returns a random number that is uniformly distributed between from and to. The lower bound from has to be smaller than the upper bound to.
var a = random(from: M_PI, to: 2.0 * M_PI) // a in [M_PI, " * M_PI]rotate(point:(Pol), by:(Number))Returns a Pol object that is obtained by rotating the point around the origin by an angle of by.
save(file:(String))Saves the current canvas to a file at the path defined by file. The file may contain escape sequences indicated by \( ). Currently .ipe is the only supported output format.
var a = 1
save(file: "empty_\(a).ipe") // Canvas is saved to "empty_1.ipe"set_resolution(x:(Number))Sets the resolution of the canvas to x which must be a positive number. As a result, objects that are added to the canvas after the resolution update are drawn using the specified resolution. (Objects drawn before the call are not affected)
All objects in Hydra are drawn by walking along the outline of the object in a step-wise manner and connecting the obtained positions with straight lines. The higher the resolution, the smaller these steps.
The default value is 100.0.
set_resolution(x: 200.0) // Double the default resolution.sin(x:(Number))Evaluates the sine function at the passed value.
var a = sin(x: M_P / 2.0) // a = 1sinh(x:(Number))Evaluates the hyperbolic sine function at the passed value.
var a = sinh(x: 0) // a = 0theta(r1:(Number), r2:(Number), R:(Number))This function represents hyperbolic law of cosines, rearranged to determine the angle between r1 and r2, to the opposite of R. The parameters are the lengths of the sides of the triangle.
var a = theta(r1: 5.0, r2: 7.0, R: 10.0)translate(point:(Pol), by:(Number))Returns a Pol object that represents a point which is obtained by applying the following translation to the passed point. The translation that is applied moves a point p on the origin to the point p' whose radius is the absolute value of by. If by is negative the angular coordinate of p' is π, otherwise it is 0.
