nodesnim/graphics/drawable

Types

DrawableObj = object of RootObj
  shadow*: bool
  border_width*: float
  border_detail*: array[4, int] ## left-top, right-top, right-bottom, left-bottom
  border_radius*: array[4, float] ## left-top, right-top, right-bottom, left-bottom
  shadow_offset*: Vector2Obj
  border_color*: ColorRef
  shadow_color*: ColorRef
  background_color*: ColorRef
  texture*: GlTextureObj
DrawableRef = ref DrawableObj

Lets

standard_shadow_color: ColorRef = Color(0.0'f32, 0.0'f32, 0.0'f32, 0.5'f32)

Procs

proc Drawable(): DrawableRef {...}{.raises: [], tags: [].}

Methods

method enableShadow(self: DrawableRef; val: bool = true) {...}{.base, raises: [],
    tags: [].}
Enables shadow, when val is true.
method draw(self: DrawableRef; x1, y1, width, height: float) {...}{.base,
    raises: [GLerror], tags: [].}
method getColor(self: DrawableRef): ColorRef {...}{.base, raises: [], tags: [].}
Returns background color.
method loadTexture(self: DrawableRef; path: string) {...}{.base,
    raises: [ResourceError, GLerror], tags: [].}

Loads texture from the file.

Arguments:

  • path is an image path.
method setBorderColor(self: DrawableRef; color: ColorRef) {...}{.base, raises: [],
    tags: [].}
Changes border color.
method setBorderWidth(self: DrawableRef; width: float) {...}{.base, raises: [],
    tags: [].}
Changes border width.
method setColor(self: DrawableRef; color: ColorRef) {...}{.base, raises: [], tags: [].}
Changes background color.
method setCornerRadius(self: DrawableRef; radius: float) {...}{.base, raises: [],
    tags: [].}

Changes corners radius.

Arguments:

  • radius is a new corner radius.
method setCornerRadius(self: DrawableRef; r1, r2, r3, r4: float) {...}{.base,
    raises: [], tags: [].}

Changes corners radius.

Arguments:

  • r1 is a new left-top radius.
  • r2 is a new right-top radius.
  • r3 is a new right-bottm radius.
  • r4 is a new left-bottm radius.
method setCornerDetail(self: DrawableRef; detail: int) {...}{.base, raises: [],
    tags: [].}

Changes corners details.

Arguments:

  • detail is a new corner detail.
method setCornerDetail(self: DrawableRef; d1, d2, d3, d4: int) {...}{.base,
    raises: [], tags: [].}

Changes corners details.

Arguments:

  • d1 is a new left-top detail.
  • d2 is a new right-top detail.
  • d3 is a new right-bottm detail.
  • d4 is a new left-bottm detail.
method setTexture(self: DrawableRef; texture: GlTextureObj) {...}{.base, raises: [],
    tags: [].}
Changes drawable texture.
method setShadowColor(self: DrawableRef; clr: ColorRef) {...}{.base, raises: [],
    tags: [].}
method setShadowOffset(self: DrawableRef; offset: Vector2Obj) {...}{.base,
    raises: [], tags: [].}
Changes shadow offset.
method setStyle(self: DrawableRef; s: StyleSheetRef) {...}{.base,
    raises: [ValueError, RegexError, ResourceError, GLerror], tags: [].}

Sets new stylesheet.

Styles:

  • background-color - rgb(1, 1, 1); rgba(1, 1, 1, 1); #ffef.
  • background-image - "assets/image.jpg". - `background - the same as background-image and background-color.
  • border-color - the same as background-color.
  • border-width - 0; 8.
  • border-detail - corners details. 8; 8 8 8 8.
  • border-radius - corners radius. same as border-detail.
  • border - corners radius and border color. 8 #ffef.
  • shadow - enables shadow. true; yes; on; off; no; false.
  • shadow-offset - XY shadow offset. 3; 5 10.