我认为这就是剪辑的用途,但我找不到任何示例来执行此操作。 我需要:
- 通过设置新的剪辑蒙版(更改 GC)来限制区域
- 画画
- 将 GC 设置回之前的状态
最佳答案
您可以使用引用 here 的 XSetClipRectangles()
来完成此操作和 XSetClipMask()
引用 here
所以:
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
有关更多信息,请在终端中输入 man functionName
。
关于c - 如何限制 Xlib 图形基元绘制的表面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9037676/