Introduction

fũnkplot is a niche piece of mathematical modeling and plotting software, which is based on an interpreted descriptive language.

Using this programming language you can instruct fũnkplot to generate 2-dimensional plots to help you with your mathematic tasks.

After generation these plots and surfaces can be exported into various formats for further operations on them.

fũnkplot has python language bindings, it is possible to run python scripts on your generated data to further enlarge the interoperability of data between various programming platforms.

First steps

After the installation when you have started fũnkplot it will be possible to load a few samples (from the samples directory) or just type in and run your program to see the generated plot in the plotting area.

The fũnkplot programming language

fũnkplot uses its own programming language influenced by basic in its simplicity, with some extensions to allow more complex mathematical notions to be easily handled, and having a decent enough verbosity to feel like a natural language.

The process of creating a plot is very straightforward, just write a small program and run it. One of the most simple ones would take up just the following 2 lines:

And this will generate the following plot:

image-20220425144408774

fũnkplot supports a range of built-in mathematical functions, most of the default operators and has syntax for changing the color, line and rotation of the current plot.

A generic fũnkplot program

It is recommended, but not mandatory that the fũnkplot programs adhere to the following structure:

This makes possible that the function declaration will use variables without raising an error of undefined variables and that all logical blocks of the program that belong in one place are grouped together.

The generic scene settings deal with parts of the program that for simple scenarios contain settings that affect the whole of the scene, such as the size of the pixels, or whether the coordinate system is visible or not, or the palette used.

The variable declarations declare the variables that will be used in the program, it is preferred to keep one line declarations.

The function declaration contain the functions that will be used in the program, it is possible to have more than one function.

In the variable initialization block you have to initialize the variables. Uninitialized variable don’t play well with the program.

Then finally in the code section you can start playing with the function.

Lines starting with the # symbol are considered comments and are ignored by the interpreter.

Keywords

The following are the keywords recognized by the fũnkplot interpreter.

KeywordDescription
ifChecks for a condition and executes the given block of code in case of a statement which evaluates to non zero.
forCreates a loop for traversing over a set of data. The loop can be numeric loop with indexes or looping through a list of points.
functionDefines a function that can be used in plotting or experimenting.
letDefines the value for the given variable.
plotPlots the given function or list of points.
rotateRotates the given point(s) around a given point with a specific angle.
scriptRuns a python script.
setSets variables altering the behaviour and visualization of the scene.
varDeclares a variable.

The if keyword

The if keyword is used to execute a block of code depending on the value of an expression. The generic form of if is:

This will declare a variablei, and assign the value 4 to it, upon execution it will print the value to the output window:

The if can have an else branch too:

This will generate the following plot:

image-20221012104843960

The for keyword

The for keyword is used to declare a loop that will execute a block of code a specific time. There are two forms a for loop can take in fũnkplot. The first one is a standard numeric loop:

This will declare a variablei, and execute the body of the loop 5 times, which is calling a one line python script printing the value of i. The output should look like:

Looping through a list

The other form of the for loop is when looping through a list. This looks like:

This will generate the following output:

Looping through the points of a function

The for loop can be used to loop through the points of the plot of a function, and it will make possible to perform various operations on individual points, like in the example below:

This will generate the following image:

image-20221006115636896

The function keyword

The function keyword is used to declare the mathematical functions you intend to plot. The syntax is:

Where expression might consist of any of the following terms, even combined with one another:

The order of evaluation of the operators is a mathematical one.

It is possible to declare more than one function in a program.

Example

The following code plots a colourful Lissajous curve by defining two functions:

Resulting in the following plot:

image-20221021092112328

The let keyword

The let keyword is used to make an assignment to a declared variable. It’s basic syntax is:

This will assign the value 1.2 to the variable a, which was declared to be of type number. It will raise a syntax error to assign to a variable which was not declared, or if the type is different.

It is possible to assign arithmetic expressions to numeric type variables, so the following is syntactically correct:

Creating a point

The let keyword is also used to create a point on the scene.

The following assignment assigns to the point type variable called p the point at (1,2) and plots it, the result is a small dot, indicating the point has been drawn.

The points of a function

The let keyword can be also used to assign the points of a drawable object (such as a function) to a variable which can be manipulated in various ways.

The following piece of code will create such a variable:

and running it will result in the following drawing:

image-20220519143757398

The algorithm operating on the default interval [1,1] is a simple iterative one, that starts x from the first point in the default drawing interval (-1) till the end of the default drawing interval (1) and will use a default step of 0.01 for advancing the function drawing, while calculating the value f(x) as per the mathematical formula of the function.

Advanced points assignment

Since there can be situations where we want to plot functions outside of the default [1,1] interval, the let keyword accepts extra parameters too, specifying the interval, the number of points or segments we want to draw and whether we want to plot using points of function or a continuous drawing.

Specifying the interval

The following example specifies the interval which is to be used to draw the function:

and results in the following plot:

image-20220519144309975

Specifying the number of points in a plot

It is possible to specify how many points should a drawing contain to have a better control over your data using the counts keyword. The following example specifies the number of points that will be used to draw the function:

and results in the following plot:

image-20221005133909496

This approach will calculate the step value considering the length of the interval to obtain the required number of points.

Specifying the step used in a plot

It is possible to specify the step used when drawing the plot of the function using the step keyword. The following example specifies the steps that will be used to draw the function:

and results in the following plot:

image-20221005141804680

Since the step is calculated based on the number of points, it is not possible to specify both the steps and the number of points.

A list of points

The let keyword can be used to make an assignment to a list of points by using predefined values.

This will assign the two points at (1,2) and (3,4) to the ps variable.

The plot keyword

The plot keyword is used to draw the graphical representation of an expression. The colour, and the pixel size for the plot can be specified using the set keyword.

Plotting a point

The following program plots one point on the screen:

Generating the following plot:

image-20221114103033355

Plotting a function

The following code plots the function sin(x) over the interval (π,π).

For plotting functions It is possible to specify the plot interval and the type of the plot (ie. a continuous plot, the increase step or the number of points used to represent the drawing).

If there is no plot interval, the default interval of (1,1) is used. If there is no step or point count defined the default step of 0.01 is used.

The program above will generate the following image:

image-20221114103139259

Plotting the points of a function

It is possible to plot the points of a function while iterating over them with an index counter, or by point reference.

Generating the following plot:

image-20221114103240152

The rotate keyword

It is possible to rotate some of the objects found in fũnkplot applications. The following syntax is used to achieve this:

Where

The following program:

Generates the following plot:

image-20221114103953276

The script keyword

It is possible to embed python scripts in fũnkplot code. The following syntax is used to achieve this:

The python script will have access to the variables defined in the fũnkplot code in the following manner:

Example

Will generate the following python script:

And the following output when executed:

 

The set keyword

The set keyword is used to set variables altering the behaviour of the rendered scene. It is recommended to place the scene altering code sequences before any of the other code sequences.

The following values can be set:

SettingDescription
colour / colorSets the colour of the next pixel to be drawn. Both UK and US spellings are allowed.
paletteSets the palette to be used for drawing the scene.
coordinatesSets the properties of the coordinate system.
pixelSets the properties of the next pixel to be drawn.

Setting the colour

Setting the colour can be done using one of the following available syntaxes:

By name

Using the syntax set colour name sets the colour based on the name of it, using 255 as alpha value. A list of all colour names is available in the Miscellaneous section of this help system.

By name and alpha

Using the syntax set colour name,alpha sets the colour based on the name of it, using the specified alpha value.

From a palette

Using the syntax set colour palette[index] will make possible to set the colour with the given index from the palette that was selected with the set palette … statement, and will use the alpha channel set to 255. If there is no such palette found this statement has no effect and the colour black will be used.

From a palette with alpha value

Using the syntax set colour palette[index],alpha will make possible to set the colour with the given index from the palette that was selected with the set palette … statement and will calculate the alpha from the specified value. If there is no such palette this statement has no effect and the colour black will be used.

By RGB code

Using the syntax set colour #<value> will allow you to directly set the red, green and blue values of the colour using the well know HTML syntax. The following combinations are accepted:

Setting the palette

The syntax set palette name sets the palette that can be accessed in a set color palette[index] statement. A list of available palettes can be found in the Miscellaneous section of this help system.

Setting the properties of the coordinate system

It is possible to modify the properties of the coordinate system, such as the bounding box of it, the rotation and the zoom, or to hide the coordinate system if desired. The following table lists the values that can be changed.

WhatDescriptionExample
on / offShows or hides the coordinate system. The coordinate system by default is shown so you might consider hiding it if you wish.set coordinates off
start xSets the start value of the coordinate systems’ X axis.set coordinates start x -4
start ySets the start value of the coordinate systems’ Y axis.set coordinates start y -4
end xSets the start end of the coordinate systems’ X axis.set coordinates end x 4
end ySets the end value of the coordinate systems’ Y axis.set coordinates end y 4
zoomSets the zoom used on the coordinate system. The optimal value is depending on your screen resolution.set coordinates zoom 110
rotationSets the rotation of the coordinate system. The value can be either degrees or radians (default).set coordinates rotation 45 degrees
gridShows or hides the grid of the coordinate system. By default the grid is visible, so you might consider hiding it. Accepts on or off as parameter.set coordinates grid off

Due to the way the presentation of data is handled in the application, the statements affecting the behaviour of the coordinate system are executed before any other code is executed, so it is recommended to group the before any other statements

Setting the pixel properties

For the moment it is possible to set the size of a pixel with the command set pixel size X where X denotes an expression that will be evaluated.

Example

The following program sets the basic properties of the coordinate system and then draws a colourful line with increasing pixel sizes.

Resulting in the following plot:

image-20221019145527702

The var keyword

The var keyword is used to declare variables that later can be used to perform various operations with. The syntax is

This will declarea, b and c to be numeric variables. In order for proper behaviour you have to initializer the variables and then you can use them in operations later on.

The following variable types are recognized in fũnkplot.

For easier readability it is recommended that you organize your variables by type like in the example below:

Error messages

The following error messages and associated codes are used in fũnkplot:

ERRORDESCRIPTION
0Erroneous looping conditions detected. A loop with a negative step value, but with the start value being smaller than the end might generate this error.
1Invalid variable declaration. Not specifying the type of a variable might cause this error to pop up.
2Invalid variable type. The list of valid variable types is number, point and list. Anything else will lead to this error.
3Missing the keyword of in a statement.
4Invalid list variable type.
5Untyped lists are not supported.
6Untyped lists are not supported
7Index error
8Variable was not declared
9Invalid assignment (missing assignment operator)
10Conflicting type assignment
11Invalid point assignment
12Conflicting type assignment: array assigned to a non array type
13Invalid array assignment: missing [ from the expression
14Invalid assignment: arithmetic expression assigned to non numeric type
15Invalid data to plot (not a point, not an indexed point, not a function)
16Invalid function definition. Missing assignment in body
17Improper parametrization of the given function.
18Possible error in a statement. No data before a certain position.
19Possible error in a statement. No data after a certain position
20Syntax error in a statement. Unmatched empty parenthesis.
21Error in a statement. Not found enclosing parenthesis
22Possible error in a statement. No parameters were found for a function.
23Possible error in statement. Meaningless use of a function.
24Possible error in statement. No parameters for a function.
25Invalid plotting interval
26Possible error in statement. Improper power expression.
27Possible error in formula. Looks like an invalid statement.
28Possible error in a statement. No data before a certain position.
29Possible error in a statement. No data after a certain position.
30Possible error in a statement. The statement is not fully understood.
31Unknown pixel property
32Wrong palette indexing
33Invalid color to set.
34Cannot identify the object assigning from
35Invalid statement
36Syntax error: unsupported set target.
37Undeclared variables cannot be used in for loops.
38for statement with direct assignment does not contain the to keyword
39Invalid for statement.
40for statement does not contain the do keyword.
41Internal error from the underlying libraries
42Invalid expression
43for body does not end with done.
44rotate statement tries to rotate undeclared variable
45rotate statement does not contain with keyword
46Rotation unit must be either degree or radians (default)
47Unknown keyword in rotation.
48Invalid reference: (missing at keyword)
49A value was declared and used but not defined to hold a value
50Cannot plot a number
51Invalid assignment missing of keyword
52No such function
53Invalid keyword
54Something messy with an index
55Index out of bounds
56Invalid index (ie: the resulted index is <0).
57Cannot identify the object to assign to.
58Incompatible assignment types don't match.
59Append statement does not contain the TO keyword
60No function for points of assignment
61Cannot assign a non numeric value to a numeric variable
62Cannot identify the object assigning from
64Cannot identify the assignment source
65Cannot use a point type variable in that context

 

Colours used

The following colours are the colours that can be used by name in funkplot:

aliceblue 
antiquewhite 
aqua 
aquamarine 
azure 
beige 
bisque 
black 
blanchedalmond 
blue 
blueviolet 
brown 
burlywood 
cadetblue 
chartreuse 
chocolate 
coral 
cornflowerblue 
cornsilk 
crimson 
cyan 
darkblue 
darkcyan 
darkgoldenrod 
darkgray 
darkgreen 
darkkhaki 
darkmagenta 
darkolivegreen 
darkorange 
darkorchid 
darkred 
darksalmon 
darkseagreen 
darkslateblue 
darkslategray 
darkturquoise 
darkviolet 
deeppink 
deepskyblue 
dimgray 
dodgerblue 
firebrick 
floralwhite 
forestgreen 
fuchsia 
gainsboro 
ghostwhite 
gold 
goldenrod 
gray 
green 
greenyellow 
honeydew 
hotpink 
indianred 
indigo 
ivory 
khaki 
lavender 
lavenderblush 
lawngreen 
lemonchiffon 
lightblue 
lightcoral 
lightcyan 
lightgoldenrodyellow 
lightgray 
lightgreen 
lightpink 
lightsalmon 
lightseagreen 
lightskyblue 
lightslategray 
lightsteelblue 
lightyellow 
lime 
limegreen 
linen 
magenta 
maroon 
mediumaquamarine 
mediumblue 
mediumorchid 
mediumpurple 
mediumseagreen 
mediumslateblue 
mediumspringgreen 
mediumturquoise 
mediumvioletred 
midnightblue 
mintcream 
mistyrose 
moccasin 
navajowhite 
navy 
oldlace 
olive 
olivedrab 
orange 
orangered 
orchid 
palegoldenrod 
palegreen 
paleturquoise 
palevioletred 
papayawhip 
peachpuff 
peru 
pink 
plum 
powderblue 
purple 
red 
rosybrown 
royalblue 
saddlebrown 
salmon 
sandybrown 
seagreen 
seashell 
sienna 
silver 
skyblue 
slateblue 
slategray 
snow 
springgreen 
steelblue 
tanned 
teal 
thistle 
tomato 
turquoise 
violet 
wheat 
white 
whitesmoke 
yellow 
yellowgreen 

Palettes used

The following are the names of the palettes can be used by name in funkplot:

Each palette has exactly 256 colours, indexable from 0.

acid
african_sunset
african_wild_flower
afternoon_heat
aladdin
alice_through_the_looking_glass
alien
almost_fire
almost_lava
almost_like_germany
almost_like_sahara
amelie
american_beauty
american_psycho
anchorman
animals
annie_hall
apple_shades
archeron
are_you_ok
asian_garden
aussie_outback
australian_outback
autumn_blush
autumn_fire
autumn_park
avengers
baby_blue
baby_drive_my_car
backyard_bbq
basic_neuroscience
bearded_iris
beer
best_vacation_ever
birdman
black_blue_gray
black_brownish_white
black_dakcyan_white
black_gray_white
black_green_whita
black_green_yellow
black_lightsteel_white
black_lila
black_lila_white
black_navy_white
black_red_white
black_sand
black_steel_white
black_yellow_white
blade_runner
blowin_smoke
blue_01
blue_clarity
blue_haze
blue_pastels
blue_sea_in_karpathos
blue_velvet
bluered
blues
blues_brothers
blueserpent
bluesoo
bright_fall
burberry_grey_and_gold
ca
cadet
calm
candy
candy_apple
candy_corn
carina_nebula
chewbacca
chic_glow
chocolate_ice_cream
chocolate_locust
chocolate_rain
choppedgold
chroma
chromadepth
clay_pot
clockwork_orange
clooney
clouds2
cloudy_sunset
cobalt
cobblestone_jazz
cold_construction
cold_harbour
coldfire
confidential
coolest
copper
corporate_blue_complement
corpse_bride
coup_de_grace
criminal_pimento
crocus
cumulonimbus
cyan_orange_red
dark_night
day_dream
day_into_night
dead_presidents
deadpool
depressed_sky
django_unchained
dreaming_in_the_desert
drholwegneu
dutch_iris
earth_and_sky
earth_light
earthica
edward_scissorhands
electric_punch
empire_strikes_back
english_winter
espresso_shot
eternal_sunshine
evening_shade
factory_manganese_blue
fadeblue
faded_happines
faded_photo
fadegreen
fadered
fadewhite
fadeyellow
fanstastic_mr_fox
fargo
fear_and_loathing
fight_club
fire
fire_2
fire_and_ice
fire_dance
firefox
firestrm
flamey
fleshtones
fluid_fire
force_awakens
forrest_gump
froth3
froth6
frozen
fruit_of_passion
game_bookers
giger
giger2
giger3
giger4
glamour_3
glass
global_warming
godfather
gold_01
gold_agleam
golden_butterfly
golf_course
gone_girl
good_friends
grease
green_01
green_centre
greenin
greenout
greens
grey
halloween
harry_potter
harvest_time
hawaiian_sunset
hay_field
heaven
hello_september
herbal_mist
high_energy
highs_and_lows
honies
hsb_nature_13
hunger_games
i_demand_a_pancake
i_salute_king_tut
ifs23
inception
influenza
inglorious_basterds
iq_01
iq_02
iq_03
iq_04
iq_05
iq_06
iq_07
iq_08
iq_09
iq_10
iq_11
iq_12
jaguar
jason14
jason8
jaws
jill_olantern
jupiter
jurassic_park
kenya_cocoa
kill_bill
kill_me_romantically
kitty_latte
koi_carp
kona_coffee_beans
kuler_peacock
kung_fu_panda
lagoon_nebula
lagoon_nebula_2
large_egypt_flag
lavender_sand
lazy_plethora
leek
lenticular_odyssey
leon
let_them_eat_cake
letoile
leviathan
life_aquatic
life_of_pi
light_blue_01
light_green_01
lilas
lion_king
lipstick
looney_tunes
lost_in_translation
mad_max_fury_road
magic_csl
magnolias_for_life
main_street
marmalade_skies
martian
matrix
mean_girls
metallic_midnight_blue
mexican_blanket
minimal_blue
minotaur
mint_dream
ml43
ml67
ml8
monogreens
moonlight_sonata
moonrise_kingdom
more_like_germany
morgan1
morgan2
morgan3
mosaic
mossy_slate
mystery_machine
napoli
neon_nights
neutrality_first
newly_risen_moon
night_blooming
nightcrawler
nordic_blonde
nothing_gold
nuts
ocean_breaker
ocean_five
october_sky
old_recording
on_your_bees_knees
one_fish_two_fish
orange_lavendel
orange_tweak
orion_nebula
osx
pale_black_sand
pale_waters
pales
palette_482
paris_modern
passing_shower
passion
pastel_rainbow
peach_blossoms
peachy_lilas
peacock
persian_nights
peter_pan
phoenix_flame
pink_01
pistachio
platoon
plumb_purple
pollock
precolombinas
prime_symmetry
pulp_fiction
pulse
pumpkin_attack
purple_people_eater
pyroclastic
pyroclastic_2
quatblue
quatfire
quatgold
quatgray
quatgreen
quatred
rageforst_bar
rainbowsmooth12
raspberry_whip
red_01
red_and_black
red_silk
remember_november
reservoir_dogs
retro_circus
revenant
rhodedendron
roll
rose_with_thorn
royal_tenenbaums
rural_landscape
rusted_steel
samhain
sandstone
sardegna
saturated_classics
seaside
seeds_of_change
serena
shades_of_plum
sharky
she_is_french
shining
silence_of_the_lambs
silver_01
silverback_gorilla
simultaneous_copper
skin_tones
sleep_mode
slow_motion
small_egypt_flags
smoke
softly_softly
sognefjord
solutions
spirited_away
starry_night
strawberry_mousse
striped_lamp_shade
suede_fantasy
sugar
suicide_squad
sunflower
sunlight_trees
sunshine
supernatural
supersonic
sweet_funk
take_me_back
talented_hearts
tamora
taxi_driver
temple_of_joy
the_eagle
the_incredible_hulk
the_perfect_storm
theory_of_everything
thought_provoking
thru_the_woods
thunder_sunset
tiny_spikes_of_happines
titanic
top_gun
traileq
trance
tree_frog
tropical_fish
truman_show
tulip_field
tuscan_sunset
underwater_voices
valentine
vinters_harvest
violet_vermont
warm_green
warp
warrior_eyebrow
wasabi_soy
water
waynes_world
white_gray_blue_black
white_white_black
white_white_black_red
white_white_red
wine
winter
wolf_of_wall_street
woodpile
woods
yard_dogs
you_are_beautiful
you_owe_me_a_shirt