- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我试图在开罗设置一个面具,但无法让它产生任何影响。下面我有一个基于这里的简单程序:http://snipplr.com/view/22584/cairo-hello-world-examble/ .
我正在设置一个完全透明的蒙版,因此不应该绘制任何内容,但它似乎没有任何效果 - 文本仍然被绘制。我的代码如下。我错过了什么?
谢谢!
int main(int argc, char* argv[])
{
cairo_surface_t* surface;
cairo_t* cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 200, 40);
cr = cairo_create (surface);
//****
// Here I create a pattern with an alpha of zero and set it to be cairo's mask
// According to http://www.cairographics.org/manual/cairo-context.html#cairo-mask
// "Opaque areas of pattern are painted with the source, transparent areas are not painted."
// Shouldn't this make it so nothing gets drawn?
//****
cairo_pattern_t* nothing = cairo_pattern_create_rgba(0,0,0,0);
cairo_mask (cr, nothing);
cairo_text_extents_t te;
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_select_font_face (cr, "Georgia",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20.0);
cairo_text_extents (cr, "hello cairo!", &te);
cairo_move_to (cr, 20, 20);
cairo_show_text (cr, "hello cairo!");
cairo_fill(cr);
// An image gets drawn that says "hello cairo!" in big letters
cairo_surface_write_to_png(surface, "hello_cairo.png");
return 0;
}
最佳答案
好吧,我想通了。我期待 cairo_mask() 表现得像 cairo_clip()。 (在 cairo_clip() 中,它建立了一个剪辑路径,用于剪辑之后绘制的每个元素)
cairo_mask 的解释非常简单:“cairo_mask -- 使用 alpha channel 蒙版图案绘制当前源填充图案。”这正是它所做的 - 用当前的填充图案填充整个屏幕,并通过 mask 上该像素的任何 alpha 将其混合。
关于vector-graphics - 开罗掩蔽 - 有什么我遗漏的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3096188/
我正在尝试运行某人给我的一些 C++ 代码。起初有一个指向 istream 文件的断开链接,我通过添加包含路径修复了这个问题: C:\Program Files (x86)\Embarcadero\R
谁能告诉我如何防止 .git 目录的内容被上传到 PyPi。我的 MANIFEST.in 看起来像这样: global-include *.py *.js *.rst *.html *.css *.l
最近在 typescript 项目的VSCode中遇到如下情况: 文件:some-interface.ts // no import statements have been skipped. Thi
为我找到这个问题的合适标题有点困难,所以也许这个例子会澄清我的问题。 我正在发出 ajax 请求以将一些变量从 JS 传递到 PHP。这些变量之一是带有一些选项的 URL,即 https://www.
我是一名优秀的程序员,十分优秀!