add rtgui_dc_draw_color_point function.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@610 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
4fd321c36e
commit
06f58468b6
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "demo_view.h"
|
#include "demo_view.h"
|
||||||
|
#include <rtgui/dc.h>
|
||||||
#include <rtgui/rtgui_system.h>
|
#include <rtgui/rtgui_system.h>
|
||||||
#include <rtgui/widgets/label.h>
|
#include <rtgui/widgets/label.h>
|
||||||
#include <rtgui/widgets/slider.h>
|
#include <rtgui/widgets/slider.h>
|
||||||
|
@ -41,7 +42,7 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
||||||
/* 获得demo view允许绘图的区域 */
|
/* 获得demo view允许绘图的区域 */
|
||||||
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
||||||
|
|
||||||
rtgui_dc_set_textalign(dc, RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL);
|
RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL;
|
||||||
/* 显示GUI的版本信息 */
|
/* 显示GUI的版本信息 */
|
||||||
#ifdef RTGUI_USING_SMALL_SIZE
|
#ifdef RTGUI_USING_SMALL_SIZE
|
||||||
rtgui_dc_draw_text(dc, "RT-Thread/GUI小型版本", &rect);
|
rtgui_dc_draw_text(dc, "RT-Thread/GUI小型版本", &rect);
|
||||||
|
@ -50,19 +51,19 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 绘制一个圆形 */
|
/* 绘制一个圆形 */
|
||||||
rtgui_dc_set_color(dc, red);
|
RTGUI_DC_FC(dc) = red;
|
||||||
rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10);
|
rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10);
|
||||||
|
|
||||||
/* 填充一个圆形 */
|
/* 填充一个圆形 */
|
||||||
rtgui_dc_set_color(dc, green);
|
RTGUI_DC_FC(dc) = green;
|
||||||
rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10);
|
rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10);
|
||||||
|
|
||||||
/* 画一个圆弧 */
|
/* 画一个圆弧 */
|
||||||
rtgui_dc_set_color(dc, RTGUI_RGB(250, 120, 120));
|
RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120);
|
||||||
rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120);
|
rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120);
|
||||||
|
|
||||||
/* 多边形 */
|
/* 多边形 */
|
||||||
rtgui_dc_set_color(dc, blue);
|
RTGUI_DC_FC(dc) = blue;
|
||||||
rtgui_dc_draw_polygon(dc, vx, vy, 6);
|
rtgui_dc_draw_polygon(dc, vx, vy, 6);
|
||||||
|
|
||||||
/* 绘制不同的边框 */
|
/* 绘制不同的边框 */
|
||||||
|
|
|
@ -24,7 +24,6 @@ static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t *
|
||||||
{
|
{
|
||||||
struct rtgui_dc* dc;
|
struct rtgui_dc* dc;
|
||||||
rtgui_rect_t rect;
|
rtgui_rect_t rect;
|
||||||
rtgui_point_t point = {0, 0};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view
|
* 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view
|
||||||
|
@ -41,7 +40,9 @@ static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t *
|
||||||
/* 获得demo view允许绘图的区域 */
|
/* 获得demo view允许绘图的区域 */
|
||||||
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
||||||
|
|
||||||
rtgui_dc_blit(dc_buffer, &point, dc, &rect);
|
rect.x1 += 10;
|
||||||
|
rect.y1 += 10;
|
||||||
|
rtgui_dc_blit(dc_buffer, NULL, dc, &rect);
|
||||||
|
|
||||||
/* 绘图完成 */
|
/* 绘图完成 */
|
||||||
rtgui_dc_end_drawing(dc);
|
rtgui_dc_end_drawing(dc);
|
||||||
|
@ -62,9 +63,13 @@ rtgui_view_t *demo_view_dc_buffer(rtgui_workbench_t* workbench)
|
||||||
|
|
||||||
if (dc_buffer == RT_NULL)
|
if (dc_buffer == RT_NULL)
|
||||||
{
|
{
|
||||||
|
rtgui_rect_t rect = {0, 0, 50, 50};
|
||||||
|
|
||||||
/* 创建 DC Buffer,长 50,宽 50 */
|
/* 创建 DC Buffer,长 50,宽 50 */
|
||||||
dc_buffer = rtgui_dc_buffer_create(50, 50);
|
dc_buffer = rtgui_dc_buffer_create(50, 50);
|
||||||
rtgui_dc_set_color(dc_buffer, blue);
|
RTGUI_DC_FC(dc_buffer) = blue;
|
||||||
|
rtgui_dc_fill_rect(dc_buffer, &rect);
|
||||||
|
RTGUI_DC_FC(dc_buffer) = red;
|
||||||
rtgui_dc_draw_circle(dc_buffer, 25, 25, 10);
|
rtgui_dc_draw_circle(dc_buffer, 25, 25, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ static rt_bool_t demo_workbench_event_handler(struct rtgui_widget* widget, struc
|
||||||
static void workbench_entry(void* parameter)
|
static void workbench_entry(void* parameter)
|
||||||
{
|
{
|
||||||
rt_mq_t mq;
|
rt_mq_t mq;
|
||||||
struct rtgui_view* view;
|
|
||||||
struct rtgui_workbench* workbench;
|
struct rtgui_workbench* workbench;
|
||||||
|
|
||||||
/* 创建GUI应用需要的消息队列 */
|
/* 创建GUI应用需要的消息队列 */
|
||||||
|
@ -53,7 +52,7 @@ static void workbench_entry(void* parameter)
|
||||||
|
|
||||||
/* 初始化各个例子的视图 */
|
/* 初始化各个例子的视图 */
|
||||||
demo_view_dc(workbench);
|
demo_view_dc(workbench);
|
||||||
/* demo_view_dc_buffer(workbench); */
|
demo_view_dc_buffer(workbench);
|
||||||
demo_view_animation(workbench);
|
demo_view_animation(workbench);
|
||||||
demo_view_window(workbench);
|
demo_view_window(workbench);
|
||||||
demo_view_label(workbench);
|
demo_view_label(workbench);
|
||||||
|
|
|
@ -15,7 +15,7 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me)
|
||||||
/* 获得窗口的尺寸 */
|
/* 获得窗口的尺寸 */
|
||||||
rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect);
|
rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect);
|
||||||
/* 绘制背景色 */
|
/* 绘制背景色 */
|
||||||
rtgui_dc_set_color(dc, white);
|
RTGUI_DC_BC(dc) = white;
|
||||||
rtgui_dc_fill_rect(dc, &rect);
|
rtgui_dc_fill_rect(dc, &rect);
|
||||||
|
|
||||||
/* 计算中心原点 */
|
/* 计算中心原点 */
|
||||||
|
@ -23,15 +23,15 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me)
|
||||||
y = (rect.y2 + rect.y1)/2;
|
y = (rect.y2 + rect.y1)/2;
|
||||||
|
|
||||||
/* 绘制十字架 */
|
/* 绘制十字架 */
|
||||||
rtgui_dc_set_color(dc, black);
|
RTGUI_DC_BC(dc) = black;
|
||||||
rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y);
|
rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y);
|
||||||
rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2);
|
rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2);
|
||||||
|
|
||||||
/* 根据状态绘制圆圈 */
|
/* 根据状态绘制圆圈 */
|
||||||
if (me->status == MYWIDGET_STATUS_ON)
|
if (me->status == MYWIDGET_STATUS_ON)
|
||||||
rtgui_dc_set_color(dc, green);
|
RTGUI_DC_BC(dc) = green;
|
||||||
else
|
else
|
||||||
rtgui_dc_set_color(dc, red);
|
RTGUI_DC_BC(dc) = red;
|
||||||
rtgui_dc_fill_circle(dc, x, y, 5);
|
rtgui_dc_fill_circle(dc, x, y, 5);
|
||||||
|
|
||||||
/* 结束绘图 */
|
/* 结束绘图 */
|
||||||
|
|
Loading…
Reference in New Issue