pike.git / src / modules / Image / layers.c

version» Context lines:

pike.git/src/modules/Image/layers.c:1:   /*   **! module Image   **! note - **! $Id: layers.c,v 1.74 2001/09/24 11:35:00 grubba Exp $ + **! $Id: layers.c,v 1.75 2001/10/26 20:33:00 nilsson Exp $   **! class Layer   **! see also: layers   **!      **!   **!   **! appendix Image.Layer modes   **!   **! <dl compact>   **! <dt><i>The variables in the expression:</i></dt>
pike.git/src/modules/Image/layers.c:24:   **! <execute>   **! import Image;   **!   **! void write_image(string desc,   **! string filename,   **! Image img,   **! string longdesc)   **! {   **! longdesc = replace(longdesc, ([ "&lt;":"&amp;lt;", "&gt;":"&amp;gt;", "&amp;":"&amp;amp;" ]));   **! write(begin_tag("tr")); - **! write(mktag("td",(["align":"right","valign":"center"]), + **! write(mktag("td",(["align":"left","colspan":"2"]),   **! mktag("b",0,desc))); - **! write(mktag("td",(["align":"right"]),illustration_jpeg(img,(["dpi":150.0])))); + **! write(end_tag()); + **! write(begin_tag("tr")); + **! write(mktag("td",(["align":"right"]),illustration_jpeg(img,(["dpi":150.0,"quality":90]))));   **! write(mktag("td",(["align":"left","valign":"center"]),longdesc));   ** (replace(longdesc,({",",";",")"}),   ** ({",<wbr>",";<wbr>",")<wbr>"}))/   ** "<wbr>")/1*({mktag("wbr")}) ) );   **! write(end_tag()+"\n");   **! }   **!   **! int main()   **! {   **! object ltrans=Layer((["image":   **! Image(32,32,160,160,160)->   **! box(0,0,15,15,96,96,96)->   **! box(16,16,31,31,96,96,96)->scale(0.5),   **! "tiled":1,   **! "mode":"normal"]));   **!   **! object circle=load(fix_image_path("circle50.pnm"));   **! object image_test=load(fix_image_path("image_ill.pnm")); - **! object ryoki=load_layer(fix_image_path("ryoki_carrot.png")); +    **!   **! object lc1=   **! Layer((["image":circle->clear(255,0,0),   **! "alpha":circle,   **! "xoffset":5,   **! "yoffset":5]));   **!   **! object lc2=   **! Layer((["image":circle->clear(0,0,255),   **! "alpha":circle,   **! "xoffset":25,   **! "yoffset":25]));   **! object lc2b=   **! Layer((["image":circle,   **! "alpha":circle*({0,0,255}),   **! "xoffset":25,   **! "yoffset":25]));   **! - **! object lr1= - **! Layer((["image":circle->test(63)->scale(1.25), - **! "alpha":circle->scale(1.25), - **! "xoffset":10, - **! "yoffset":5])); - **! object lr2= - **! Layer((["image":ryoki->image(), - **! "alpha":ryoki->alpha(), - **! "xoffset":5, - **! "yoffset":20])); - **! +    **! object li1=   **! Layer((["image":image_test->scale(80,0),   **! "mode":"normal",   **! "xoffset":0,   **! "yoffset":0]));   **!   **! object li2=   **! lay(   **! ({   **! (["image":circle->clear(255,0,0),"alpha":circle,
pike.git/src/modules/Image/layers.c:146:   **! }));   **!   **! object lca1;   **!   **! object a=   **! lay( ({ lca1=lay(({Layer((["fill":"white"])),   **! lc1}),0,0,80,80),   **! lay(({lc1}),0,0,80,80)->set_offset(80,0),   **! lay(({li1}),0,0,80,80)->set_offset(160,0),   **! lay(({li1}),0,0,80,80)->set_offset(240,0), - **! lay(({lr1}),0,0,80,80)->set_offset(320,0), - **! lzo0->set_offset(400,0)}), - **! 0,0,560,80); + **! lzo0->set_offset(320,0)}), + **! 0,0,480,80);   **!   **! object b=   **! lay( ({ lay(({lc2}),0,0,80,80),   **! lay(({lc2b}),0,0,80,80)->set_offset(80,0),   **! lay(({li2}),0,0,80,80)->set_offset(160,0),   **! lay(({li2b}),0,0,80,80)->set_offset(240,0), - **! lay(({lr2}),0,0,80,80)->set_offset(320,0), - **! lzo1->set_offset(400,0)}), - **! 0,0,560,80); + **! lzo1->set_offset(320,0)}), + **! 0,0,480,80);   **!   ** xv(a); xv(b);   **!   **! write(begin_tag("table",(["cellspacing":"0","cellpadding":"1"])));   **! - **! // write_image("top layer image","bi",b->image()); - **! // write_image("top layer alpha","ba",b->alpha()); - **! - **! // write_image("bottom layer image","ai",a->image()); - **! // write_image("bottom layer alpha","aa",b->alpha()); - **! +    **! write_image("top layer","b",lay(({ltrans,b}))->image(),   **! "");   **! write_image("bottom layer","a",lay(({ltrans,a}))->image(),   **! "");   **! - **! write(mktag("tr",0,mktag("td",0,"\240"))); - **! +    **! foreach (Array.transpose(({Layer()->available_modes(),   **! Layer()->descriptions()})),   **! [string mode,string desc])   **! {   **! if ((&lt;"add","equal","replace","replace_hsv","darken",   **! "dissolve","screen","logic_equal">)[mode])   **! write(mktag("tr",0,mktag("td",0,"\240")));   **! - **! ({lc2,lc2b,li2,li2b,lr2,lzo1})->set_mode(mode); + **! ({lc2,lc2b,li2,li2b,lzo1})->set_mode(mode);   **!   **! object r=   **! lay( ({ lay(({lca1,lc2}),0,0,80,80),   **! lay(({lc1,lc2b}),0,0,80,80)->set_offset(80,0),   **! lay(({li1,li2}),0,0,80,80)->set_offset(160,0),   **! lay(({li1,li2b}),0,0,80,80)->set_offset(240,0), - **! lay(({lr1,lr2}),0,0,80,80)->set_offset(320,0), - **! lay(({lzo0,lzo1}),400,0,160,80) }), - **! 0,0,560,80); + **! lay(({lzo0,lzo1}),320,0,160,80) }), + **! 0,0,480,80);   ** xv(r);   **!   **! write_image(mode,mode,lay(({ltrans,r}))->image(),desc);   **! }   **!   **! write(end_tag());   **! return 0;   **! }   **!   **! </execute>   */      #include "global.h"      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.74 2001/09/24 11:35:00 grubba Exp $"); + RCSID("$Id: layers.c,v 1.75 2001/10/26 20:33:00 nilsson Exp $");      #include "image_machine.h"      #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "array.h"