Package zebkit.draw

View package




protected $view (v)

Build a view instance by the given object.


Parameters:
  • v <Object>

    an object that can be used to build a view. The following variants of object types are possible

    • null null is returned
    • String if the string is color or border view id than "zebkit.draw.rgb" or border view is returned. Otherwise an instance of zebkit.draw.StringRender is returned.
    • String if the string starts from "#" or "rgb" it is considered as encoded color. "zebkit.draw.rgb" instance will be returned as the view
    • Array an instance of "zebkit.draw.CompositeView" is returned
    • Function in this case the passed method is considered as ans implementation of "paint(g, x, y, w, h, d)" method of "zebkit.draw.View" class. Ans instance of "zebkit.draw.View" with the method implemented is returned.
    • Object an instance of "zebkit.draw.ViewSet" is returned

Returns:

zebkit.draw.View a view


Example:
 // string render
 var view = zebkit.draw.$view("String render");

 // color render
 var view = zebkit.draw.$view("red");

 // composite view
 var view = zebkit.draw.$view([
     zebkit.draw.rgb.yellow,
     "String Render"
 ]);

 // custom view
 var view = zebkit.draw.$view(function(g,x,y,w,h,d) {
     g.drawLine(x, y, x + w, y + w);
     ...
  });
public void wrapToLines (font, maxWidth, line, result)

Break the given line to parts that can be placed in the area with the specified width.


Parameters:
  • font <zebkit.Font>

    a font to compute text metrics

  • maxWidth <Integer>

    a maximal area with

  • line <String>

    a line

  • result <Array>

    a result array to accumulate wrapped lines


protected <Object> $views

Dictionary of predefined views. Every view is accessible by an id associated with the view.

public <zebkit.Font> boldFont

Default bold font

protected <Object> Context2D

Dictionary of useful methods an HTML Canvas 2D context can be extended. The following methods are included:

  • setFont(f) set font
  • setColor(c) set background and foreground colors
  • drawLine(x1, y1, x2, y2, [w]) draw line of the given width
  • ovalPath(x,y,w,h) build oval path
  • polylinePath(xPoints, yPoints, nPoints) build path by the given points
  • drawDottedRect(x,y,w,h) draw dotted rectangle
  • drawDashLine(x,y,x2,y2) draw dashed line
public <zebkit.Font> font

Default normal font

public <zebkit.Font> smallFont

Default small font