前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >UGL之封闭图形的填充

UGL之封闭图形的填充

作者头像
Taishan3721
发布2020-06-23 16:21:21
9040
发布2020-06-23 16:21:21
举报
文章被收录于专栏:这里只有VxWorks这里只有VxWorks

一个封闭的2D图形,当其背景色不透明时,默认使用背景色进行填充

还有一种方案是使用uglFillPatternSet()设置图形填充

换个复杂点的图形

代码如下

代码语言:javascript
复制

#include <ugl/ugl.h>

void uglTest ()
    {
    #define WIDTH 32
    #define HIGHT 32
    UINT8 patternData[WIDTH*HIGHT/__SIZEOF_INT__] = 
        {
        0x00,0x0f,0xf0,0x00,
        0x00,0x7f,0xfe,0x00,
        0x01,0xff,0xff,0x80,
        0x03,0xff,0xff,0xc0,
        0x07,0xff,0xff,0xe0,
        0x0f,0xff,0xff,0xf0,
        0x1f,0xff,0xff,0xf8,
        0x3f,0xff,0xff,0xfc,
        0x3f,0x8f,0xf1,0xfc,
        0x7f,0x07,0xe0,0xfe,
        0x7f,0x07,0xe0,0xfe,
        0x7f,0x07,0xe0,0xfe,
        0xff,0x8f,0xf1,0xff,
        0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,
        0xf9,0xff,0xff,0x9f,
        0x79,0xff,0xff,0x9e,
        0x78,0xff,0xff,0x1e,
        0x7c,0xff,0xff,0x3e,
        0x3c,0x7f,0xfe,0x3c,
        0x3e,0x1f,0xf8,0x7c,
        0x1f,0x03,0xe0,0xf8,
        0x0f,0xc0,0x03,0xf0,
        0x07,0xf8,0x1f,0xe0,
        0x03,0xff,0xff,0xc0,
        0x01,0xff,0xff,0x80,
        0x00,0x7f,0xfe,0x00,
        0x00,0x0f,0xf0,0x00 
        };
    UGL_REG_DATA *pRegData;
    UGL_GC_ID     gc;
    UGL_MDDB_ID   patternDdb;
    UGL_MDIB      patternDib = {WIDTH, HIGHT, WIDTH, patternData};

    uglDisplayOpen(0, 0, 0); 
    pRegData = uglRegistryFind (UGL_DISPLAY_TYPE, 0, 0, 0);
    gc = uglGcCreate((UGL_DEVICE_ID)pRegData->id);

    patternDdb = uglMonoBitmapCreate((UGL_DEVICE_ID)pRegData->id, &patternDib, 
                                      UGL_DIB_INIT_DATA, 0, UGL_NULL);
    uglFillPatternSet(gc, patternDdb);

    uglForegroundColorSet(gc, 0xff0000);
    uglBackgroundColorSet(gc, 0x00ff00);
    uglEllipse(gc, 10, 10, 200, 300, 0, 0, 0, 0);
    uglRectangle(gc, 250, 10, 350, 300);
    return;
    }

我是泰山,专注VX好多年!

一起学习,共同进步!

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-06-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 这里只有VxWorks 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档