wiris provides procedures for graphical display in two dimensions. The main application of these procedures is to display 2D geometrical figures and functions.
The graphical display is produced on a Plotter using the commands plot, if it you only wish to draw an object, or represent, if we wish the system to draw certain characteristic elements of the object, such as asymptotes and critical points in the case of functions. To add text to the drawing, use the command write.
You can also use the command geometry_status to learn how to simplify this command.
draw an object: plot(d:Plotable2d)
This function is generally used to draw d on a "drawing board". Some objects that can be drawn include: Point, Line, Circumference, Segment, Triangle, Polygonal, Function, Curve or Text_box. If the argument is a List, then all its elements are drawn.
It is worth mentioning the case where parameter d is an identifier (variable). If its value is a drawable object then it is drawn, otherwise no action is taken and a warning is returned. Later, if the value of d changes then the drawing is updated to show the new object. You could say that the drawing board remembers the elements that are drawn on it and redraws them if their value changes.
The example below demonstrates this behaviour. If P is defined as point (3,5,0) and we draw it (first block), it appears drawn as point (3,5,0) on the drawing board. If then P takes as its value the point (2,-1), this is the point that appears on the drawing board. Note that this happens without having to use the command plot with point P.
|
Draw a function : command plot
We can specify how to draw a function in many ways. In most cases it is sufficient to specify the expression of the function that we wish to draw and the system will take care of selecting the path and what variables act as x and y coordinates.
The following examples show how we can also indicate the variable and the path.
Parametric curves
To draw parametric curves we will always have to indicate the variable that acts as a parameter and its path.
|
options plot: Optionally, the last argument to the plot command can be a List of options. Options give the user control over the figure appearance (colour, thickness, etc.). The functionality or quality of some options depends on the version of Java™ (JVM) installed on your computer. If you have Java™ version 1.3 (Java 2) or later, then in the second example you can see lines of different width. Download the latest version of Java.
Enter the option values separated by commas in the following format 'option_name=option_value'. Example: color=green.
The main options for the plot command are color Here, enter the colour to be used for drawing.
Possible values
: lists of three integers between 0 and 255 in '{r,g,b}' form, where r,g,b correspond to the amount of red, green and blue, which define the colour. For simplicity, some colours have been defined: black, white, red, green, blue, cyan, magenta, yellow, brown, orange, pink, grey, dark_grey, light_grey and the complete list of HTML colours.
Default value
: black
border This defines whether or not the border of closed figures is painted.
Possible values
: true and false.
Default value
: true
fill In the case of a closed figure, the command determines whether the interior is filled.
Possible values
: true and false.
Default value
: false
fill_color If working with a closed figure, and if the value defined for fill is true, this command indicates the colour to be used to paint the inside of the figures.
Possible values
: A Color and "automatic"; if the second option is chosen, the inside of the figure is filled using the colour given by the colour option color.
Default value
: "automatic"
visible This command determines whether the element is visible or not.
Possible values
: true and false.
Default value
: true
mobile If the object to plot has not been defined as static, the image is allowed to move, or not move, in the plane.
Possible values
: true and false.
Default value
: true
evaluate This command defines whether the element should be evaluated when drawing or not.
Possible values
: true and false.
Default value
: false
fixed_dimensions This defines whether or not objects must be repositioned in the plane, when the drawing board dimensions are changed. By default, they are repositioned.
Possible values
: true and false.
Default value
: false
point_size This sets the size of points plotted on the drawing board.
Possible values
: any positive Realnumber.
Default value
: 5
line_width This command is used to set the thickness of lines, segments or functions drawn on the drawing board.
Possible values
: any positive Real number.
Default value
: 1
show_label This command defines whether or not a label is displayed for the figure.
Possible values
: true and false.
Default value
: false
label This defines the label that should be displayed next to the figure.
Possible values
: any object and "automatic". If we choose the second option, the label will be the name of the figure.
Default value
: "automatic"
label_font This sets the type of font that should be used to write the labels on the drawing board.
Possible values
: any object of type Font.
Default value
: {bold=false,italic=false,name="SansSerif",size=12}
name If the command plot does not know the name of the object to be drawn, enter it. This only has an effect when working with a single element and not with a list.
Possible values
: any object of type String.
Default value
: null
seed_name If the command plotdoes not know the name of the object to be drawn, the name of the figure is the value of this option concatenated with a number.
Possible values
: any object of type String.
Default value
: null
|
represent: represent(...)
The purpose of this function is to draw objects and show the relevant information for each one. For example, functions are represented by plotting the graph and features of interest such as individual points, asymptotes and local maximum values. It accepts the same arguments as the function plot.
It is defined for objects of type: Function, Circumference and Conic
( Hyperbola, Ellipse and Parabola)
If the command is applied to an object that wiris does not regard as applicable or for which it does not know how to calculate any particular element, the command works in the same way as plot.
|
write: write(d,P:Point)
This function allow us to write d at point P. Usually d will be of type String although it can be any object. In general, you can think of the command write as a quick way of drawing objects of type Text_box.
|
options write: Optionally, the last argument to the write command can be a List of options. Options that can be used with the command write include the command text_box commands such as plot (they can be viewed here) since write(t,d,P,O) is the same as plot(t,text_box(d,P,O),O), where t is a Drawing board, O is a List of options and d and P are as described in the previous paragraph.
The main options for the text_box command are background This indicates whether or not the background of the object being represented should be painted.
Possible values
: true and false.
Default value
: false
background_color If the value for background is true, this indicates the colour to paint the background of the object being represented.
Possible values
: any Color, in {r,g,b} format, or by name if it has been defined.
Default value
: {255,255,255} (white)
border This defines whether or not a border will be applied around the displayed object, and in the former case it defines the border thickness.
Possible values
: any non-negative Integerinteger.
Default value
: 0
border_color If the value for border is a positive Integer, the value defines the border colour.
Possible values
: any Color, in {r,g,b} format, or by name if it has been defined.
Default value
: {0,0,0} (black)
horizontal_position This defines the horizontal position of the Text_box from the specified reference point.
Possible values
: "left", "center" and "right".
Default value
: "right"
vertical_position This defines the vertical position of the Text_box from the specified reference point.
Possible values
: "top", "center", "base_line" and "bottom".
Default value
: "base_line"
max_width This defines the maximum width of the Text_box. When the text exceeds this width, a line break will be inserted.
Possible values
: any positive Real number.
Default value
: ∞ (infinity).
font This defines the font to be used when writing text on the drawing board.
Possible values
: any object of type Font.
Default value
: {bold=false,italic=false,name="SansSerif",size=12}
bold_font This defines whether or not the text on the drawing board should be bold.
Possible values
: true and false.
Default value
: false
italic_font This defines whether or not the text on the drawing board should be in italics.
Possible values
: true and false.
Default value
: false
font_name This indicates the name of the font type used.
Possible values
: "Serif", "SansSerif" and "Monospaced".
Default value
: "SansSerif"
font_size This indicates the size of the font type used.
Possible values
: any positive Integer.
Default value
: 12
|
The commands plot, represent or write can optionally accept, as the first argument, the drawing board where the graphic should be displayed. If the first argument is not a drawing board, wiris provides one with predefined features.
Each set of calculations has a default drawing board. In practice, you can have as many as you wish. The commands to create a drawing board are plotter() or plotter(P,x,y); the latter creates a drawing board centred on point P, of width x and height y.
By default, when a drawing board is created the coordinate axes and an orange grid are shown. If the user does not want these elements to appear, he or she should execute show_axis(false) and show_grid(false), respectively, before creating the drawing board or drawing anything. If a drawing board has a visible grid, the points can only be moved to the vertices of the grid. Once a drawing board has been generated, the axes and grid can be controlled with the icons or , respectively.
In the example below we create a drawing board where, unlike with the default, there are neither axes nor grid:
The drawing board icons ( , , , , etc. ) are described in the section Menus,icons....
options plotter: The main options for the plotter command are center Sets the centre point of the drawing board.
Possible values
: any Point.
Default value
: point(0,0)
height Sets the height of the drawing board.
Possible values
: any positive Real number.
Default value
: 21
width Sets the width of the drawing board.
Possible values
: any positive Real number.
Default value
: 21
visible This defines whether the drawing board is visible or not.
Possible values
: true and false.
Default value
: true
background_color Sets the background colour of the drawing board.
Possible values
: any Color, in {r,g,b} format, or by name if it has been defined.
Default value
: {255,255,240}(cream)
aspect_ratio This defines the height to width ratio (aspect ratio) for the drawing board.
Possible values
: any positive Real number.
Default value
: 1
information This defines the information that should be displayed when the mouse is scrolled over a figure. This information can be changed, once the drawing is on the screen, using the icons , and on the drawing board toolbar: More information on label or show_label.
Possible values
: "none", "name", "definition" and "value".
Default value
: "name"
· Window attributes
window_height Sets the height of the drawing window, in pixels.
Possible values
: any positive Integer.
Default value
: 450
window_width Sets the width of the drawing window, in pixels.
Possible values
: any positive Integer.
Default value
: 450
window_aspect_ratio This attribute defines the ratio between the window’s height and width (aspect ratio).
Possible values
: any positive Real number.
Default value
: 1
· Coordinate axis attributes
show_axis Determines whether or not the coordinate axes appear in the drawing.
Possible values
: true and false.
Default value
: true
axis_color If the value for show_axis is true, this command indicates the colour of the axes.
Possible values
: any Color, in {r,g,b} format, or by name if it has been defined.
Default value
: {150,150,255} (light blue)
axis_style This defines how the coordinate axes will be displayed: as two perpendicular lines or as a pair of arrows, one perpendicular to the other. Additionally, in the second case, the abscissa axis can be identified by x or by X and the ordinate axis can be defined by y or by Y.
Possible values
: "none", "arrow", "arrow_xy" and "arrow_XY".
Default value
: "none"
axis_font This defines the font to be used when writing the text and values associated with the axes.
Possible values
: any object of type Font.
Default value
: {bold=false,italic=false,name="SansSerif",size=10}
axis_label This defines the coordinate axis names. The first component in the list names the abscissa axis, and the second names the ordinate axis.
Possible values
: any List of two components.
Default value
: {,} (an Empty_list of two elements).
· Grid attributes
show_grid Determines whether or not the grid appears in the drawing. If the grid is displayed, the movement of drawn points is limited to the points on the grid. If the grid is not displayed, the points can be moved freely around the drawing board.
Possible values
: true and false.
Default value
: true
grid_color Sets the grid colour.
Possible values
: any Color, in {r,g,b} format, or by name if it has been defined.
Default value
: {255,200,100} (light orange)
|
We can draw a series of objects using geometrical relations and see how these relations are maintained by moving some of them. To do so, we need to declare what objects depend on others using the symbol :=.
After calculating the following example, try moving point P.
slider: command slider
We will use the slider command and declare a variable with := for choosing real numbers interactively.
This command receives a path and optionally, an initial value as arguments.
|
closest point: command closest_point
In interactive geometry we sometimes need to fix a point to stay over a figure. This command receives as a first argument a geometrical object and as a second argument the value of the initial point.
|
|