[cairo] Linen Texture

ed44 ed44 at xs4all.nl
Fri Aug 2 05:41:07 PDT 2013


On 07/30/2013 02:00 PM, Bobby Salazar wrote:
> On 7/29/13, Simon Sapin<simon.sapin at exyr.org>  wrote:
>> Le 29/07/2013 13:35, Bobby Salazar a écrit :
>>> Does anyone know if it is possible to produce a linen texture using
>>> Cairo? Ideally I would like to create a Cairo pattern than can be used
>>> to fill a path. Ideally, I would like something similar to this:
>>>
>>> http://tutvid.com/create-linen-texture-photoshop/
>>>
>>> Does anyone have any ideas how to accomplish this?
>> If you’re doing something pixel-based:
>>
>> 1. Do as in that link you gave
>> 2. Save the result as PNG
>> 3. Use cairo_image_surface_create_from_png() to get a cairo surface
>> 4. Make a surface pattern from that
>> 5. Set the pattern’s "extend" to CAIRO_EXTEND_REPEAT
>> 6. Use the pattern as a source.
>>
>> http://cairographics.org/manual/cairo-PNG-Support.html
>> http://cairographics.org/manual/cairo-cairo-pattern-t.html
>> http://cairographics.org/manual/cairo-cairo-t.html
>>
>>
>> If you want vectors it’s gonna be more tricky: you’ll need to express
>> the effect you want in terms of paths, colors, gradients, etc.
> I was hoping that somebody knew a good way to produce the linen
> texture using Cairo calls instead of me having to import raw pixel
> data from an outside source.
>
> Does anyone know of a way to reproduce this kind of look at run-time?


Interesting problem.

The attached little example comes close.

compile with : gcc linepatterns_cairo.c `pkg-config cairo --cflags 
--libs` -o patterns

scrollwheel changes linewidth (makesthe result darker/lighter )
Hold MB1 to pause
MB3 while holding MB1 will produce two png's
MB2 switch between REPEAT/REFLECT

There are many values that influence the result and it might need
some more randomness somewhere...just experiment...

Ed.





-------------- next part --------------
A non-text attachment was scrubbed...
Name: Linepattern_with_cairo.png
Type: image/png
Size: 43352 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130802/6b887eb9/attachment-0001.png>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: linepatterns_cairo.c
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130802/6b887eb9/attachment-0001.c>


More information about the cairo mailing list