简体   繁体   English

如何限制Xlib图形基元绘制的表面?

[英]How can I limit the surface in which Xlib graphics primitives draw?

I think that's what clip are used for but I can't find any example to do this. 我认为这就是剪辑的用途,但我找不到任何示例可以做到这一点。 I need to: 我需要:

  • Limit the region by setting a new clipmask (altering the GC) 通过设置新的剪贴蒙版(更改GC)来限制区域
  • Draw
  • Set the GC back to its previous state 将GC恢复到先前的状态

You can do it by using XSetClipRectangles() referenced here and XSetClipMask() referenced here 您可以通过做XSetClipRectangles()引用在这里XSetClipMask()引用在这里

So: 所以:

Display dpy; //This is your display, we'll assume it is a valid Display
GC gc; //This is your GC, we'll assume it is a valid GC
XRectangle recs[]; //This is an array containing the clipping regions you want.
int recs_n; //This is the number of rectangles in the 'recs' array.

XSetClipRectangles(dpy, gc, 0, 0, recs, recs_n, Unsorted); //Enable clipping
drawMyClippedGraphics(); //Call to whatever you want to use for drawing
XSetClipMask(dpy, gc, None); //Restore the GC

For further information type man functionName in your terminal. 有关更多信息,请在终端中输入man functionName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM