[cairo] How to take cairo_set_source_rgb effect for different color points?
xiangzhai83 at gmail.com
Mon Oct 7 20:29:57 PDT 2013
Thanks for your advice :)
I used XFillArc(Xlib stuff) instead
> On Sun, Oct 06, 2013 at 03:50:59PM +0800, Leslie Zhai wrote:
>> Hi cairo developers,
>> I wanna draw some points indicating mouse`s X and Y, and used random
>> number from 0 to 255 for RGB color of the points, such as:
>> for loop
>> double r = Map(i, 0, 100, 0, 255); // Re-maps a number from one
>> range to another
>> double g =
>> double b = 255 -
>> cairo_set_source_rgb(c, r / 255.0, g / 255.0, b /
>> cairo_move_to(c, x,
>> It is unable to put cairo_stroke into the for loop, it might be a heavy
>> operation when draw the path too often.
>> But cairo_set_source_rgb failed to take effect in the loop if cairo_stroke
>> was outside.
>> The source code is available via
>> So how to take cairo_set_source_rgb effect for drawing different color
>> Please someone give me some advice, Thanks a lot :)
> You can't store color per-path as stroke/fill operate upon the path union.
> For the same reason calling stroke 100 times for a simple path is likely to
> be a lot cheaper than calling it once with a 100-fold more complex path.
> And you probably don't want to use stroke here unless you have a wide
> pen and wish to use the pen to draw dots.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo