WLJS LogoWLJS Notebook

Rectangle

Supports Offload
Rectangle[{xmin_, ymin_}, {xmax_, ymax_}, opts___]

represents a basic rectangle

Graphics[{Red, Rectangle[{0, 0}], Blue, Rectangle[{0.5, 0.5}]}]

Options

RoundingRadius

Accepts _Real | _Integer or a list of values for X and Y rounding. By the default is 0. It uses printer points.

Parameters

RGBColor

filling color

EdgeForm

stroke color

Opacity

global opacity of an object

Methods

Area

Calculates total area (symbolically as well)

Area[Rectangle[{x1, y1}, {x2, y2}]]

RegionCentroid

RegionCentroid[Rectangle[{x1, y1}, {x2, y2}]]

EventHandler

One can listen to a several events produced by this primitive using EventHandler

EventHandler[t_Rectangle, {event_ -> handler_, ...}]

where event can be

  • "mousemove" detects and sends coordinates of a mouse, when it is over this element
  • "drag" makes primitive draggable and emits coordinates
  • "zoom" detects zoom / mouse-wheel
  • "click" detects mouse clicks

Transitions and updates

It fully supports updates. Use Offload on coordinates.

Example

A simple bar chart

data = RandomReal[{3, 10}, {10, 2}];

Graphics[{
	EdgeForm[Black], Blue, 
	Table[{Blue, Rectangle[{i - .4, 0}, {i, data[[i, 1]]}], 
	Red, Rectangle[{i + .4, 0}, {i, data[[i, 2]]}]}, {i, 10}]
}, Frame -> True]

On this page