Previous Page Next Page Contents

plot::Rectangle2d -- graphical primitive for a two-dimensional rectangle

Introduction

plot::Rectangle2d(p, w, h) represents a plot of a two-dimensional rectangle with lower left corner p = (px; py), width w and height h.

Creating Elements

plot::Rectangle2d(c, w, h <, option1, option2...>)
plot::Rectangle2d(p, w, h <, option1, option2...>)

Parameters

c - a list of two arithmetical expressions
p - a two-dimensional point, i.e., an object of the domain plot::Point or DOM_POINT
w, h - arithmetical expressions
option1, option2, ... - plot option(s) of the form OptionName = value

Related Domains

plot::Ellipse2d, plot::Point, plot::Polygon, plot::Scene, RGB

Related Functions

plot, plot2d, plot::copy, plot::line

Details

Operands

An object of plot::Rectangle2d consists of the three operands c, w and h.

Important Operations

Operands of a rectangle primitive can be accessed either using the system function op, the index operator [ ], or using the attributes corner, height and width described above. For example, if rectangle is such an object, then the calls op(rectangle,1), rectangle[1] and rectangle::corner return the list representing the lower left corner of rectangle.

Via rectangle[1] := new_point or rectangle::corner := new_point, the lower left corner of rectangle is replaced by the list new_point.

See the methods "op", "_index", "set_index" and "slot" below.

Use the slot operator :: to get or set plot options of such objects afterwards, i.e., when they have been created. For example, if rectangle is such an object, then rectangle::Color := RGB::Red changes the color of of rectangle to red.

Result of Evaluation

Evaluating an object of type plot::Rectangle2d returns itself.

Function Call

Calling an object of plot::Rectangle2d as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.

Entries

defaultOptions

is a table of plot options for rectangle primitives and their default values. Each entry has the form OptionName = default.

When an object of the domain plot::Rectangle2d is created, then a copy of this table is stored under the attribute options (see the table of attributes above), where those options are added and replaced, respectively, which are given by the (optional) parameters option1, option2... of the creating call (see ``Creating Elements'' above).

Plot options, which are not contained in this table, will not be included in the plot data of the object created by the method "getPlotdata" (see below).

optionNames

is a set of the available options for plots of two-dimensional rectangles.

Method _index: indexed access to the operands of a rectangle primitive

Method dimension: dimension of a rectangle primitive

Method getPlotdata: create the plot data of a rectangle primitive

Method nops: number of operands of a rectangle primitive

Method op: extract operands of a rectangle primitive

Method set_index: set operands of a rectangle primitive

Method slot: read and write attributes and plot options

Method checkOption: check a plot option

Method copy: create a copy of a rectangle primitive

Method modify: modify a copy of a rectangle primitive

Method print: print a rectangle primitive

Example 1

We define a rectangle with lower left corner at point (1;2), width 3 and height 4, and a square of length one with lower left corner at the point (0;0):

>> r := plot::Rectangle2d([1, 2], 3, 4);
   s := plot::Rectangle2d([0, 0], 1, 1, Filled = TRUE)
                      plot::Rectangle2d([1, 2], 3, 4)
      
                      plot::Rectangle2d([0, 0], 1, 1)

The area of the square is filled in the color of the border of the rectangle (which is red by default). We plot these two objects in a graphical scene, without showing axes:

>> plot(r, s, Axes = None)

Example 2

The attribute corner, which specifies the lower left point of the rectangle, is a list of two arithmetical expressions also if the corner point of the object created was given as an object of the domain plot::Point or DOM_POINT:

>> c := plot::Point([-1, 1]):
   r := plot::Rectangle2d(c, 2, -2): 
   r::corner
                                  [-1, 1]

If you replace the value of the attribute corner, then the point must be given as a list of two arithmetical expressions, otherwise a warning message is issued, saying that the assignment is ignored:

>> r::corner:= point(0, 0)
      Warning: 3rd argument: expecting a list of two arithmetical ex\
      pressions; assignment ignored [plot::Rectangle2d::slot]
      
                                point(0, 0)
>> r::corner
                                  [-1, 1]

Note that if you specify an object of the domain plot::Point or DOM_POINT as the corner of the rectangle, then plot options of the point are ignored. For example, if we change the color of the point c created above to blue and create a new rectangle:

>> c::Color := RGB::Blue: r := plot::Rectangle2d(c, 1, 1): 
   plot(r)

then the rectangle is still drawn in red color (the default color of objects of the domain plot::Rectangle2d). You must use the color option of the object r to change the color of the rectangle:

>> r::Color := RGB::Blue: plot(r)

See the help page of plot::Curve2d for more examples for working with attributes of graphical primitives.

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000