ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
#include<stdio.h>#include<math.h>voidworley_noise(){constintS=1024;// image SizeconstintN=128;// Number of pointsconstintK=2;// color value sKalestaticintx[N],y[N];// points positionsinti,j,k;for(i=0;i<N;++i){x[i]=rand()%S;y[i]=rand()%S;}FILE*fo=fopen("c:\\temp\\worley.pnm","wb");fprintf(fo,"P5\n#Created by Shqn\n%d %d\n255\n",S,S);for(j=0;j<S;++j)for(i=0;i<S;++i){// for each pixel...intmind=S;for(k=0;k<N;++k){// compute min distanceintdx=i-x[k];intdy=j-y[k];intd=(int)sqrt((double)(dx*dx+dy*dy));if(mind>d)mind=d;}mind*=K;// scale and clipunsignedcharb=mind<255?mind:255;fwrite(&b,1,1,fo);}fclose(fo);}
New code : c program
// Worley noise: example of worley noise with euclidean distance function by Rocchini#include<stdio.h>#include<stdlib.h> // rand#include<time.h>#include<math.h>intmain(){constintS=1024;// image SizeconstintN=128;// Number of pointsconstintK=2;// color value sKaleintx[N],y[N];// points positionsinti,j,k;srand(time(NULL));// Initialization, should only be called once.for(i=0;i<N;++i){x[i]=rand()%S;y[i]=rand()%S;}FILE*fo=fopen("worley.pnm","wb");fprintf(fo,"P5\n %d %d\n255\n",S,S);for(j=0;j<S;++j)for(i=0;i<S;++i){// for each pixel...intmind=S;for(k=0;k<N;++k){// compute min distanceintdx=i-x[k];intdy=j-y[k];intd=(int)sqrt((double)(dx*dx+dy*dy));if(mind>d)mind=d;}mind*=K;// scale and clipunsignedcharb=mind<255?mind:255;fwrite(&b,1,1,fo);}fclose(fo);return0;}