imj-base-0.1.0.2: Game engine with geometry, easing, animated text, delta rendering.

Imj.Graphics.UI.RectContainer

Contents

Synopsis

# RectContainer

RectContainer represents a rectangular UI container. It contains the Size of its content, and an upper left coordinate.

Being Colorable, it can be wrapped in a Colored to gain the notion of color.

r----------------------------+
| u--+                       |
| |//|                       |
| |//|                       |
| +--l                       |
|                            |
+----------------------------+

r = Terminal origin, at (0,0)
/ = RectContainer's content, of size (2,2)
u = RectContainer's upper left corner, at (2,1)
l = RectContainer's lower left corner, at (5,4)


Constructors

 RectContainer Fields_rectFrameContentSize :: !SizeContent size._rectFrameUpperLeft :: !(Coords Pos)Upper left corner.

Instances

 Source # Methods Source # MethodsshowList :: [RectContainer] -> ShowS # Source # Smoothly transforms the 4 sides of the rectangle simultaneously, from their middle to their extremities. Methods Source # MethodsdrawUsingColor :: (Draw e, MonadReader e m, MonadIO m) => RectContainer -> LayeredColor -> m () Source # Source # MethodsdrawMorphingUsingColor :: (Draw e, MonadReader e m, MonadIO m) => RectContainer -> RectContainer -> Int -> LayeredColor -> m () Source #

Arguments

 :: RectContainer Reference container -> Length Width Horizontal distance -> Length Height Horizontal distance -> (Coords Pos, Coords Pos, Coords Pos, Coords Pos) (center Up, center Down, center Left, center Right)

Returns points centered on the sides of a container which is at a given distances (dx and dy) from the reference container.

container at a distance from another container
In this illustration, cont' is at dx = dy = 3 from cont:
    cont'
+--------+..-
|        |  |  dy = 3
|  cont  |  |
|  +--+..|..-
|  |  |  |
|  |  |  |
|  +--+  |
|  .     |
|  .     |
+--------+
.  .
.  .
>|--|<
dx = 3

Favored direction for centers of horizontal sides
When computing the center of an horizontal side, if the side has an even length, we must favor a Direction. (Note that if the side has an odd length, there is no ambiguity.)

In align implementation, Centered alignment favors the RIGHT Direction:

   1
12
123
1234
^

• If we, too, favor the RIGHT Direction, when the returned point is used as reference for a Centered alignment, the text will tend to be too far to the RIGHT, as illustrated here (^ indicates the chosen center):
   1
+--+
12
+--+
123
+--+
1234
+--+
^

• So we will favor the LEFT Direction, to counterbalance the choice made in align 's implementation:
  1
+--+
12
+--+
123
+--+
1234
+--+
^


# Reexports

class Colorable a where Source #

A Colorable is a colourless graphical element.

Minimal complete definition

drawUsingColor

Methods

drawUsingColor :: (Draw e, MonadReader e m, MonadIO m) => a -> LayeredColor -> m () Source #

To draw a Colorable, we need to pass a LayeredColor.

Instances

 Source # MethodsdrawUsingColor :: (Draw e, MonadReader e m, MonadIO m) => RectContainer -> LayeredColor -> m () Source #