WINDEX
Public Member Functions | List of all members
wex::shapes Class Reference

A class that offers application code methods to draw on a window. More...

#include <wex.h>

Public Member Functions

 shapes (PAINTSTRUCT &ps)
 Constructor. More...
 
void color (int r, int g, int b)
 Set color for drawings. More...
 
void color (int c)
 
void bgcolor (int c)
 set background color
 
void bgcolor (int r, int g, int b)
 
void transparent (bool f=true)
 enable/disable transparent background
 
void penThick (int t)
 Set pen thickness in pixels.
 
void fill (bool f=true)
 Set filling option.
 
void pixel (int x, int y)
 Color a pixel.
 
void line (const std::vector< int > &v)
 Draw line between two points. More...
 
void polyLine (POINT *pp, int n)
 
void rectangle (const std::vector< int > &v)
 Draw rectangle. More...
 
void polygon (const std::vector< int > &v)
 Draw Polygon. More...
 
void arc (int x, int y, double r, double sa, double ea)
 Draw Arc of circle. More...
 
void circle (int x0, int y0, double r)
 Draw circle. More...
 
void text (const std::string &t, const std::vector< int > &v)
 Draw text. More...
 
void textCenterHz (const std::string &t, const std::vector< int > &v)
 
void textVertical (bool f=true)
 Enable / disable drawing text in vertical orientation.
 
void textHeight (int h)
 Set text height. More...
 
void textFontName (const std::string &fn)
 set text font name
 
int textWidthPixels (const std::string &t)
 

Detailed Description

A class that offers application code methods to draw on a window.

    // construct top level  window
    gui& form = wex::windex::topWindow();
    form.move({ 50,50,400,400});
    form.text("A windex draw demo");

    form.events().draw([]( PAINTSTRUCT& ps )
    {
        shapes S( ps );
        S.color( 255, 0, 0 );
        S.line( { 10,10, 50,50 } );
        S.color( 255,255,255 );
        S.rectangle( { 20,20,20,20});
        S.color( 255,255,0 );
        S.text( "test", {50,50,50,25} );
        S.color(0,0,255);
        S.circle( 100,100,40);
        S.arc( 100,100,30, 0, 90 );
    });

    form.show();

Constructor & Destructor Documentation

◆ shapes()

wex::shapes::shapes ( PAINTSTRUCT &  ps)
inline

Constructor.

Parameters
[in]psThe PAINTSTRUCT passed as parameter into the draw event handler

Member Function Documentation

◆ arc()

void wex::shapes::arc ( int  x,
int  y,
double  r,
double  sa,
double  ea 
)
inline

Draw Arc of circle.

Parameters
[in]xfor center, pixels 0 at left of window
[in]yfor center, pixels 0 at top of window
[in]rradius, pixels
[in]sastart angle degrees anti-clockwise from 3 o'clock
[in]seend angle degrees anti-clockwise from 3 o'clock

The arc is drawn from sa to se in the anti-clockwise direction.

◆ circle()

void wex::shapes::circle ( int  x0,
int  y0,
double  r 
)
inline

Draw circle.

Parameters
[in]x0x for center, pixels 0 at left of window
[in]y0y for center, pixels 0 at left of window
[in]rradius, pixels

◆ color()

void wex::shapes::color ( int  r,
int  g,
int  b 
)
inline

Set color for drawings.

Parameters
[in]rred 0-255
[in]ggreen 0-255
[in]bblue 0-255

◆ line()

void wex::shapes::line ( const std::vector< int > &  v)
inline

Draw line between two points.

Parameters
[in]vvector with x1, y1, x2, y2

◆ polygon()

void wex::shapes::polygon ( const std::vector< int > &  v)
inline

Draw Polygon.

Parameters
[in]pointarray of points, such as x0,y0,x1,y1,x2,y2,x3,y3...

◆ rectangle()

void wex::shapes::rectangle ( const std::vector< int > &  v)
inline

Draw rectangle.

Parameters
[in]vvector with left, top, width, height

◆ text()

void wex::shapes::text ( const std::string &  t,
const std::vector< int > &  v 
)
inline

Draw text.

Parameters
[in]tthe text
[in]vvector of left, top ( unclipped )
[in]vvector of left, top, width, height ( clipping )

◆ textHeight()

void wex::shapes::textHeight ( int  h)
inline

Set text height.

Parameters
hheight default height 20 if not called

The documentation for this class was generated from the following file: