Older Newer
Fri, 20 Dec 2019 02:38:43 . . . . SyneRyder [Add short explanation of code example]


Changes by last author:

Added:
= Writing DEMO on an image =

This code example shows how to render a small watermark with the word "DEMO" randomly across on an image when the user clicks the OK button. You can use this code for public demo versions of your Photoshop plug-ins, so the customer can try out your plug-in before buying it.

<code>

%ffp

ForEveryTile:

{

int i, j, offset, demo, xstart, step;

if (ctl(CTL_OK))

{

if (Y>X) step=(X)/8; else step=(Y)/8;

if (step<200) step=200; //Avoid too many "DEMO" on small images

if (step>400) step=400; //Set maximum "DEMO" distance

for (z=0; z<Z; z++)

{

xstart=0;

for (y=step/2; y<Y; y+=step)

{

if (xstart>0) xstart=0; else xstart=step/2;

for (x=xstart; x<X; x+=step)

{

//Set background for text

for (j=-5; j<=10; j++)

for (i=-5; i<=30; i++)

pset(x+i,y+j,z,blend(pget(x+i,y+j,z),255,z,0,70)); //blend with image

//Set "DEMO" Text

//D

offset=0;

pset(x+offset,y+0,z,0);

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

//E

offset=7;

pset(x+offset,y+0,z,0);

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+4,z,0);

//M

offset=14;

pset(x+offset,y+0,z,0);

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+1,z,0);

offset=16;

pset(x+offset,y+2,z,0);

offset+=1;

pset(x+offset,y+1,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

pset(x+offset,y+4,z,0);

//0

offset=21;

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+0,z,0);

pset(x+offset,y+4,z,0);

offset+=1;

pset(x+offset,y+1,z,0);

pset(x+offset,y+2,z,0);

pset(x+offset,y+3,z,0);

}//x

}//y

}//z

}//if OK Button

return true;

}

</code>