x11 color-drawing

彩色绘画

  1. 获取屏幕颜色空间
      screen_colormap = DefaultColormap(display, DefaultScreen(display));
    
  2. 通过颜色名分配颜色结构体
      rc = XAllocNamedColor(display, screen_colormap, "red", &red, &red);
      if (rc == 0) {
        fprintf(stderr, "XAllocNamedColor - failed to allocated 'red' color.\n");
        exit(1);
      }
    
  3. 四个角落各画了一个小红点
      XSetForeground(display, gc, red.pixel);
      XDrawPoint(display, win, gc, 5, 5);
      XDrawPoint(display, win, gc, 5, height-5);
      XDrawPoint(display, win, gc, width-5, 5);
      XDrawPoint(display, win, gc, width-5, height-5);
    
  4. 两条棕色的线条
      XSetForeground(display, gc, brown.pixel);
      XDrawLine(display, win, gc, 50, 0, 50, 200);
      XDrawLine(display, win, gc, 0, 100, 200, 100);
    
  5. 花了一个蓝色的圆
      XSetForeground(display, gc, blue.pixel);
      XDrawArc(display, win, gc, 50-(30/2), 100-(30/2), 30, 30, 0, 360*64);
    
  6. 通过相邻点画黄色的线条组
        XSetForeground(display, gc, yellow.pixel);
        XDrawLines(display, win, gc, points, npoints, CoordModeOrigin);
    
  7. 画一个矩形
      XSetForeground(display, gc, BlackPixel(display, screen_num));
      XDrawRectangle(display, win, gc, 120, 150, 50, 60);
    
  8. 画一个填充的矩形
      XSetForeground(display, gc, green.pixel);
      XFillRectangle(display, win, gc, 60, 150, 50, 60);
    
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值