Color and Plotting

Adding color and label to variables

After defining the variables, you can add label and color for the variables.

For labels, you can use Tex, and while defining colors you can also optionally define the transparency between 0 and 1 where 0 has no transparency at all, and 1 will make the plotted variable object not visible.

Possible values for color are:

_WHITE, BLACK, GRAY, LIGHT_GRAY, DARK_GRAY, RED, LIGHT_RED, DARK_RED, PINK, LIGHT_PINK, DARK_PINK, ORANGE,
LIGHT_ORANGE, DARK_ORANGE, YELLOW, LIGHT_YELLOW, DARK_YELLOW, GREEN, LIGHT_GREEN, DARK_GREEN, MAGENTA,
LIGHT_MAGENTA, DARK_MAGENTA, CYAN, LIGHT_CYAN, DARK_CYAN, BLUE, LIGHT_BLUE, DARK_BLUE_

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\begin{variables}
  \point{p1}{real}{0,0}
  \point{p2}{real}{1,2}
  \line{g}{real}{var(p1),var(p2)}
\end{variables}
 
%set up label only
\label{p1}{${P_1}$} %set a label to p1
 
%set up label and color
\label{p1}{$\textcolor{RED}{P_1}$} %set a label to p1
\label{p2}{$\textcolor{RED}{P_2}$} %set a label to p1
 
alternatively for labels on canvas only:
\label{p1}{@2d[$\textcolor{RED}{P_1}$]} %set a label to p1
\label{p2}{@2d[$\textcolor{RED}{P_2}$]} %set a label to p1
 
\color{p1}{RED} %set o1 color to red
\color{p2}{RED}
\color[0.1]{g}{DARK_GREEN} % set g color to dark green with 10% transparency

Plotting

We can plot function and geometry variables into a canvas. First we need to setup the canvas by defining the left and right bounds and how big the canvas should be.
Then we can decide whether or not we want the coordinate system to be displayed and put all the variables we want to plot separated by ",".

The "update during mouse action" in a canvas (e.g. dragging a point) can be disabled with the command \updateOnDrag[false]. Due to performance, this might be necessary if there are many complicated calculations for an update cycle. The default value for this command is true. If set to false the update of the depending canvas objects will be performed after finishing the mouse action (e.g. mouse button is released).
1
2
3
4
5
6
7
\begin{canvas}
  \updateOnDrag[false]
  \plotLeft{-5}
  \plotRight{5}                     % the default scene will goes from -5 to 5
  \plotSize{400}                    % creates a 400px X 400px canvas
  \plot[coordinateSystem]{p1,p2,g}  % plots p1, p2 and g with coordinate system
\end{canvas}
You can have multiple canvas in one visualization, but make sure you only plot a single object in one canvas only. If you need to display the same object in more than one canvas, you need to create an object with the same values for each canvas.

The canvas can be set to different pixel width and hight by setting the plot size with \plotsize{<width value>,<height value>}.
If you want a number line (x-axis only) displayed instead of a 2-dimensional coordinate system (with x- and y-axis) use the optional parameter
numberLine in the \plot-command instead of coordinateSystem.

You can disable the toolbar menu by using the optional parameter noToolbar ind the \plot-command. By default it's enabled.

Remark: The \plot-command expects comma seperated values as optional parameters.

1
2
3
4
5
6
\begin{canvas}
  \plotLeft{-5}
  \plotRight{5}         % the default scene will goes from -5 to 5
  \plotSize{400,100}    % creates a 400px X 100px canvas
  \plot[numberLine,noToolbar]{p}  % plots p in the canvas with a number line
\end{canvas}

Plotting 3D objects

To plot 3D objects you should use the \plotddd command instead of the \plot command

1
2
3
4
5
6
\begin{canvas}
  \plotLeft{-5}
  \plotRight{5} %the default scene will goes from -5 to 5
  \plotSize{400} %creates a 400px * 400px canvas
  \plotddd[coordinateSystem]{sphere} %3d objects with a coordinate system
\end{canvas}