3.emwin5.26 (Ucgui) VS2008 2-d Graphics Library-Basic drawing "worldsing notes"

Source: Internet
Author: User

Ucgui (emWin) 2-d Graphics Library-The basic board drawing, in the basic graphics function of Ucgui, the function is still relatively full, this routine mainly uses the basic interface, the two main concept is to draw (draw) and fill (fill), the difference between the two is a hollow, Another is solid, time to note added to the distinction, another noteworthy is the drawing mode, Gui_setdrawmode (), the current emWin5.2 has two modes, one is normal drawing, the other is the way to draw the inverse.

?

Routine code Download:3.emwin5.26 (Ucgui) VS2008 2-d Graphics Library-Basic drawing. zip

?

Gui_getpixelindex () returns the color index for the given position.

?

Drawing mode

Gui_getdrawmode () returns the current drawing mode.

Gui_setdrawmode () sets the drawing mode.

?

Brush size

Gui_getpensize () returns the current brush size (in pixels).

Gui_setpensize () Sets the brush size (in pixels).

?

Querying the current customer area rectangle

Gui_getclientrect () returns the currently available drawing area.

?

Basic drawing Routines

Gui_clearrect () fills the rectangular area with the background color.

Gui_copyrect () Duplicates a rectangular area in the display.

Gui_drawgradienth () Draws a rectangle filled with horizontal color gradients.

Gui_drawgradientv () Draws a rectangle filled with a vertical color gradient.

Gui_drawgradientroundedh () Draws a rounded rectangle filled with a horizontal color gradient.

Gui_drawgradientroundedv () Draws a rounded rectangle filled with a vertical color gradient.

Gui_drawpixel () draws a single pixel.

Gui_drawpoint () draws a point.

Gui_drawrect () draws a rectangle.

Gui_drawrectex () draws a rectangle.

Gui_drawroundedframe () Draws a rounded corner box.

Gui_drawroundedrect () draws a rounded rectangle.

Gui_fillrect () draws the filled rectangle.

Gui_fillrectex () draws the filled rectangle.

Gui_fillroundedrect () Draws a filled rounded rectangle.

Gui_invertrect () reverses the rectangular area.

?

The following is an example of how to use each interface above

?

#include "GUI.h"

#include "WM.h"

?

#include "CHECKBOX.h"

#include "FRAMEWIN.h"

#include "PROGBAR.h"

#include "TEXT.h"

#include "BUTTON.h"

#include "SLIDER.h"

#include "HEADER.h"

#include "GRAPH.h"

#include "ICONVIEW.h"

#include "LISTVIEW.h"

#include "TREEVIEW.h"

?

void Maintask (void) {

int SEC = 60;

int State;

Gui_rect Exrect = {220, 40, 300, 50};

#if Gui_winsupport

Wm_setcreateflags (Wm_cf_memdev);

#endif

Gui_init ();

#if Gui_winsupport

Wm_multibuf_enable (1);

#endif

while (1)

{

Gui_gotoxy (0,0);

Delay

Gui_delay (90);

sec++;

Sec%= 61;

State = Sec% 4;

Switch (state)

{

Case 0:

???? Gui_dispstring ("0-"); break;

Case 1:

???? Gui_dispstring ("1/"); break;

Case 2:

???? Gui_dispstring ("2 |"); break;

Case 3:

???? Gui_dispstring ("3 \ \"); break;

}

Gui_dispstring ("\ngui_getpixelindex:");

Gui_dispdecmin (gui_getpixelindex (0, 0));

Gui_dispstring ("Gui_getdrawmode:");

Gui_dispdecmin (Gui_getdrawmode ());

The default drawing mode

Gui_setdrawmode (Gui_drawmode_normal);

Fills a circle with a radius at the x=250,y=10 position

Gui_fillcircle (20, 10, 10);

Inverted drawing Mode

Gui_setdrawmode (Gui_drawmode_xor);

Fills a circle with a radius at the x=280,y=10 position

Gui_fillcircle (280, 10, 10);

Set Brush size

Gui_dispstring ("\n\ngui_getpensize:");

Gui_setpensize (1);

Get brush size

Gui_dispdecmin (Gui_getpensize ());

Gui_dispstring ("gui_setpensize:");

Set Brush size

Gui_setpensize (10);

Gui_dispdecmin (Gui_getpensize ());

Empty, 5, 285, 15 square areas

Gui_clearrect (275, 5, 285, 15);

Copy, 0 start-up content to, 32 target location, copy size x=50,y=8

Gui_dispstring ("\n\ngui_copyrect (0,0,50,0,50,8):->");

Gui_copyrect (0,0, 180, 40, 50, 8);

Fills the color vertically on the rectangle, the rectangle x0=400,y0=0,x1=450,y1=50, the starting color x0000ff the end color x00ffff

Gui_drawgradienth (0, Max, 0x0000FF, 0X00FFFF);

Fills the color vertically on the rectangle, the rectangle x0=400,y0=0,x1=450,y1=50, the starting color x0000ff the end color x00ffff

Gui_drawgradientv (0, 0x0000FF, 0X00FFFF);

Gui_drawgradientroundedh (370, ten, 0x0000FF, 0X00FFFF);

Gui_drawgradientroundedv (n, ten, 0x0000FF, 0X00FFFF);

Draw points and dots in pixels with brush size

Gui_dispstring ("\n\ngui_drawpoint:");

Gui_dispstring ("Gui_drawpixel:");

Gui_drawpoint (90, 60);

Gui_drawpixel (190, 60);

Draw a hollow rectangle.

Gui_drawrect (20,25, 300, 35);

Gui_drawrectex (&exrect);

Rounded rectangle filled with monochrome, radius < Xd && 3 < Yd

Gui_fillroundedrect (220, 55, 30, 75, 3);

Set Brush size

Gui_setpensize (1);

Rounded rectangle filled with monochrome, radius < Xd && 3 < Yd

Gui_fillroundedframe (0, 70, 99, 110, 4,3);

Fillet frame, radius, width

Gui_drawroundedframe (110, 70, 20, 110, 4,3);

Inverse fill Rectangle (data inversion)

Gui_invertrect (220, 80, 300, 100);

}

}

The running effect of routine under VS2008:

3.emwin5.26 (Ucgui) VS2008 2-d Graphics Library-Basic drawing "worldsing notes"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.