Promotic
WikipediaLinkedInYoutubeTwitterFacebook

PmiCanvas - Deatiled object description

See: Object PmiCanvas
 
The PmiCanvas graphic item permanently contains the drawing area (raster image in memory - bitmap) the size of the graphic item. The drawing area (represented by the CanvasCtx object) is available for onDraw drawing event (JavaScript) via the pEvent.GetCtx(state) method. When drawing the item physicaly into the PROMOTIC panel window the current remembered content of the drawing area is used, the onDraw event is not used for redrawing the area.
 
The concept of foreground/background:

If the anumated 2D content is complex, large and some portion of it is changing rapidly, the CPU load could be quite high. The possible solution of such situation is to divide the complex PmiCanvas item up into two overlaping PmiCanvas items. One portion being static complex background and the second part being dynamic simple foreground. The item representing the dynamic foreground is embedded in the static background, constituting one compound item. This is the standard solution used for creating most of the preconfigured PmiCanvas items.

The embedded item (foreground) can access Vars variables of the parent item (background). If the Vars variables of the parent item (background) are modified, the refresh of embedded item (background) is provided.

See the configurator "In onDraw the pEvent.GetParentVar() method will be used".
 

PmiCanvas graphic item allows automated calling of onDraw drawing event for redrawing the draw area CanvasCtx if needed:

1) If the drawing area is not initialised (empty) after opening the panel or after changing the dimensions of the PmiCanvas graphic item, or after calling the CtxReset method. In such case the drawing area is always empty (transparent).
2) If the input variables (Variables) of the PmiCanvas graphic item were changed. The drawing method may request an existing drawing area, see pEvent.GetCtx(1), or more commonly non-initialized (empty) drawing area, see pEvent.GetCtx(0).
3) If the imput variables (Variables) of the parent grafiphic item (background) PmiCanvas were changed (valid for embedded item - foreground).

The drawing area is redrawn by the onDraw event only if changed. If no change occurs it is not necessary to use the script for redrawing the area and the remembered appearance is used. The onDraw event can access only the values of local variables (Variables) of the PmiCanvas item, that are currently used as data interface of the drawing function. It can also use the Pm object and the drawing area object CanvasCtx. The scripting interface of the CanvasCtx object enables most of the methods and properties for 2D drawing used in HTML5 in the <canvas> tag.

 
Advantages:
- Drawing by script allows conditioned drawing, repeated drawing, recounting, obtaining and formatting values, (the commands if...else, for, the Pm object, local variables Variables, etc.).
- It is functional also in web panels, drawing directly in client PC browsers, most browsers are supported. The methods and properties for drawing are present in the CanvasCtx object. A standard HTML5 item canvas that is commonly supported; there are many exemples, editors and testers online.
- Faster than SVG in PmiRasterImage (localy and on the WEB) and supports text displaying.
- when editing the PmiCanvas item including the onDraw drawing event the item is displayed immediatelly in the development environment (in panel editor).
- The designers can use and modify the preconfigured items based on PmiCanvas.
- On the WEB, the graphics (drawing scripts) are integral part of the panel, there is no need to download any aditional graphic files.
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice