UISF-0.4.0.0: Library for Arrowized Graphical User Interfaces.

Copyright(c) Daniel Winograd-Cort 2015
Licensesee the LICENSE file in the distribution
Maintainerdwc@cs.yale.edu
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

FRP.UISF.Graphics

Description

 

Synopsis

Documentation

type Point = (Int, Int) Source

Point describes a point on the GUI.

type Angle = Double Source

Angles are used when making arcs, circles, etc. or when performing rotations. Angles are measured in Degrees

type Dimension = (Int, Int) Source

A dimension specifies size.

type Rect = (Point, Dimension) Source

A rectangle has a (bottom left) corner point and a dimension.

data Color Source

We provide a data type for colors to allow users to easily and clearly specify common colors. Primary and secondary RGB colors are represented along with a few beige colors for use in many GUI elements.

Constructors

Black 
Blue 
Green 
Cyan 
Red 
Magenta 
Yellow 
White 
Gray 
VLightBeige 
LightBeige

This is the default background color for the UI window.

MediumBeige 
DarkBeige 

data RGB Source

RGB can be used to specify colors more precisely. Create them with one of the two smart constructors rgb or rgbE.

Instances

colorToRGB :: Color -> RGB Source

Generally used as an internal function for converting Color to RGB, but can be used by anyone.

rgb :: (Integral r, Integral g, Integral b) => r -> g -> b -> Maybe RGB Source

This function takes three integral values between 0 and 255 inclusive and create an RGB value with them. If any of the values fall outside the acceptable range, Nothing is returned.

rgbE :: (Integral r, Integral g, Integral b, Show r, Show g, Show b) => r -> g -> b -> RGB Source

This is a version of rgb that throws an error when a given value falls outside the acceptable 0-255 range. The error message shows the bad input, so the extra Show constraint is necessary.

extractRGB :: (Integral r, Integral g, Integral b) => RGB -> (r, g, b) Source

Use this to extract the values from an RGB color.

data Graphic Source

The main Graphic data type stores graphic information. Constructors are not directly exposed to encourage the use of the smart constructors.

If you would like to add custom rendering functions for Graphic, you will clearly need access to the constructors to destruct the graphics. Please request this, and I can either export them or we can discuss adding more rendering functions to this library.

nullGraphic :: Graphic Source

The absence of a graphic.

overGraphic :: Graphic -> Graphic -> Graphic Source

The overlay of two graphics, the first over the second.

withColor :: Color -> Graphic -> Graphic Source

Use the given color to paint the given graphic.

withColor' :: RGB -> Graphic -> Graphic Source

Use the given RGB color to paint the given graphic.

text :: UITexty s => Point -> s -> Graphic Source

Paint the given text at the given point.

textLines :: UITexty s => [(Point, s)] -> Graphic Source

A convenience function for painting a set of (Point,String) pairs.

ellipse :: Rect -> Graphic Source

Draw an ellipse bounded by the given rectangle.

shearEllipse :: Point -> Rect -> Graphic Source

Draw a shear ellipse bounded by the given rectangle. This code was written originally by Paul Liu.

line :: Point -> Point -> Graphic Source

Draw a line segment connecting the given two points.

polygon :: [Point] -> Graphic Source

Draw a filled polygon with corners defined by the given points.

polyline :: [Point] -> Graphic Source

Draw a sequence of line segments defined by the given points.

polybezier :: [Point] -> Graphic Source

Draw a Bezier curve defined by the given points.

arc :: Rect -> Angle -> Angle -> Graphic Source

Draw an arc of the ellipse bounded by the given rectangle that starts at the first angle measure and ends at the second.

circleFilled :: Point -> Int -> Graphic Source

Draw a filled circle with given center and radius.

circleOutline :: Point -> Int -> Graphic Source

Draw the outline of a circle with given center and radius.

rectangleFilled :: Rect -> Graphic Source

Draw a filled rectangle.

rectangleOutline :: Rect -> Graphic Source

Draw the outline of a rectangle.

translateGraphic :: Point -> Graphic -> Graphic Source

Translate the given graphic so that its origin is at the given point.

rotateGraphic :: Point -> Angle -> Graphic -> Graphic Source

Rotate the given graphic around the given point by the given number of degrees.

scaleGraphic :: Double -> Double -> Graphic -> Graphic Source

Scale the given graphic in the X and Y dimension respectively.

boundGraphic :: Rect -> Graphic -> Graphic Source

Cut the given graphic so that nothing outside of the given rectangle is visible.

newtype UIText Source

Text in UISF can be rendered in multiple fonts and colors, so we need a more powerful data type to encode it. The UIText data type does this.

Constructors

UIText 

class UITexty a where Source

To retain easy compatibility with Strings (or other text representations), we also provide the UITexty class, which is how all widgets that accept UIText should do so.

Methods

toUIText :: a -> UIText Source

uitextToString :: UIText -> String Source

Removes all font and color formatting from a UIText, returning its underlying String representation.

splitUIText :: Int -> UIText -> (UIText, UIText) Source

Split a UIText at the given character point.

takeUIText :: Int -> UIText -> UIText Source

Take a certain number of characters off of a UIText

dropUIText :: Int -> UIText -> UIText Source

Drop a certain number of characters from a UIText

uitextLen :: UIText -> Int Source

Returns the number of characters in a UIText.

pureUIText :: String -> UIText Source

Lifts a String to a UIText (with default color and font).

appendUIText :: (UITexty s1, UITexty s2) => s1 -> s2 -> UIText Source

Appends two UITexty objects together.

coloredUIText :: UITexty s => Color -> s -> UIText Source

Colors a UITexty object.

rgbUIText :: UITexty s => Maybe RGB -> s -> UIText Source

Colors a UITexty object with an exact RGB value.

fontUIText :: UITexty s => BitmapFont -> s -> UIText Source

Converts the UITexty object to the given font.

textWidth :: UITexty s => s -> Int Source

Returns the width of the String in pixels as it will be rendered

textWithinPixels :: UITexty s => Int -> s -> (UIText, UIText) Source

Given a String and a number of pixels, returns the leading substring that fits within the horizontal number of pixels along with the remaining text of the String.

textHeight :: UITexty s => s -> Int Source

Returns the height of the String in pixels as it will be rendered

data WrapSetting Source

The Wrap Setting is used to determine how to split up a long piece of text.

Constructors

NoWrap 
CharWrap 
WordWrap 

prepText Source

Arguments

:: UITexty s 
=> WrapSetting

Whether we prefer newer or older text

-> Double

Line spacing

-> Rect

Bounding Box

-> s

The text to print (which is allowed to have new lines)

-> ([Point], [UIText]) 

Turn the given String into a list of Strings. If the wrap setting is NoWrap, then this is basically just the lines function. If it is CharWrap or WordWrap, then no string in the list will be wider than the width of the bounding box. The returned list of points indicate each Point where a line should be drawn. Note that this list may not be the same length as the list of strings.

Typically, this will be used in conjunction with zip and textLines to produce text graphics.

textWidth' :: BitmapFont -> String -> Int Source

Returns the text width of a String rendered in the given bitmap font.

textWithinPixels' :: BitmapFont -> Int -> String -> (String, String) Source

Splits a String based on what can fit within the given number of pixels (the fst of the result) and what's left over (the snd).

textHeight' :: BitmapFont -> String -> Int Source

Returns the text height of a String rendered in the given bitmap font.

data BitmapFont :: *

The bitmap fonts available in GLUT. The exact bitmap to be used is defined by the standard X glyph bitmaps for the X font with the given name.

Constructors

Fixed8By13

A fixed width font with every character fitting in an 8 by 13 pixel rectangle. (-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1)

Fixed9By15

A fixed width font with every character fitting in an 9 by 15 pixel rectangle. (-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1)

TimesRoman10

A 10-point proportional spaced Times Roman font. (-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1)

TimesRoman24

A 24-point proportional spaced Times Roman font. (-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1)

Helvetica10

A 10-point proportional spaced Helvetica font. (-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1)

Helvetica12

A 12-point proportional spaced Helvetica font. (-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1)

Helvetica18

A 18-point proportional spaced Helvetica font. (-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1)