25 begin |
25 begin |
26 lerp:= a + (t * (b - a) shr 12) |
26 lerp:= a + (t * (b - a) shr 12) |
27 end; |
27 end; |
28 |
28 |
29 |
29 |
30 function grad(hash, x, y, z: LongInt) : LongInt; |
30 function grad(hash, x, y: LongInt) : LongInt; |
31 var h, v, u: LongInt; |
31 var h, v, u: LongInt; |
32 begin |
32 begin |
33 h:= hash and 15; |
33 h:= hash and 15; |
34 if h < 8 then u:= x else u:= y; |
34 if h < 8 then u:= x else u:= y; |
35 if h < 4 then v:= y else |
35 if h < 4 then v:= y else |
36 if (h = 12) or (h = 14) then v:= x else v:= z; |
36 if (h = 12) or (h = 14) then v:= x else v:= 0; |
37 |
37 |
38 if odd(h) then u:= -u; |
38 if (h and 1) <> 0 then u:= -u; |
39 if odd(h shr 1) then v:= -v; |
39 if (h and 2) <> 0 then v:= -v; |
40 |
40 |
41 grad:= u + v |
41 grad:= u + v |
42 end; |
42 end; |
43 |
43 |
44 |
44 |
45 function inoise(x, y, z: LongInt) : LongInt; |
45 function inoise(x, y: LongInt) : LongInt; |
46 const N = $10000; |
46 const N = $10000; |
47 var xx, yy, zz, u, v, w, A, AA, AB, B, BA, BB: LongInt; |
47 var xx, yy, u, v, A, AA, AB, B, BA, BB: LongInt; |
48 begin |
48 begin |
49 xx:= (x shr 16) and 255; |
49 xx:= (x shr 16) and 255; |
50 yy:= (y shr 16) and 255; |
50 yy:= (y shr 16) and 255; |
51 zz:= (z shr 16) and 255; |
|
52 |
51 |
53 x:= x and $FFFF; |
52 x:= x and $FFFF; |
54 y:= y and $FFFF; |
53 y:= y and $FFFF; |
55 z:= z and $FFFF; |
|
56 |
54 |
57 u:= fade(x); |
55 u:= fade(x); |
58 v:= fade(y); |
56 v:= fade(y); |
59 w:= fade(z); |
|
60 |
57 |
61 A:= p[xx ] + yy; AA:= p[A] + zz; AB:= p[A + 1] + zz; |
58 A:= p[xx ] + yy; AA:= p[A]; AB:= p[A + 1]; |
62 B:= p[xx + 1] + yy; BA:= p[B] + zz; BB:= p[B + 1] + zz; |
59 B:= p[xx + 1] + yy; BA:= p[B]; BB:= p[B + 1]; |
63 |
60 |
64 inoise:= |
61 inoise:= |
65 lerp(w, lerp(v, lerp(u, grad(p[AA ], x , y , z ), |
62 lerp(v, lerp(u, grad(p[AA ], x , y ), |
66 grad(p[BA ], x-N , y , z )), |
63 grad(p[BA ], x-N , y )), |
67 lerp(u, grad(p[AB ], x , y-N , z ), |
64 lerp(u, grad(p[AB ], x , y-N), |
68 grad(p[BB ], x-N , y-N , z ))), |
65 grad(p[BB ], x-N , y-N))); |
69 lerp(v, lerp(u, grad(p[AA+1], x , y , z-N ), |
|
70 grad(p[BA+1], x-N , y , z-N )), |
|
71 lerp(u, grad(p[AB+1], x , y-N , z-N ), |
|
72 grad(p[BB+1], x-N , y-N , z-N )))); |
|
73 end; |
66 end; |
74 |
67 |
75 function f(t: double): double; |
68 function f(t: double): double; |
76 begin |
69 begin |
77 f:= t * t * t * (t * (t * 6 - 15) + 10); |
70 f:= t * t * t * (t * (t * 6 - 15) + 10); |
113 begin |
106 begin |
114 di:= detail * field * y div height; |
107 di:= detail * field * y div height; |
115 for x:= 0 to pred(width) do |
108 for x:= 0 to pred(width) do |
116 begin |
109 begin |
117 dj:= detail * field * x div width; |
110 dj:= detail * field * x div width; |
118 r:= (abs(inoise(di, dj, detail*field)) + y*4) mod 65536 div 256; |
111 r:= (abs(inoise(di, dj)) + y*4) mod 65536 div 256; |
119 r:= r - max(0, abs(x - width div 2) - width * 45 div 100); // fade on edges |
112 r:= r - max(0, abs(x - width div 2) - width * 45 div 100); // fade on edges |
120 //r:= r - max(0, - abs(x - width div 2) + width * 2 div 100); // split vertically in the middle |
113 //r:= r - max(0, - abs(x - width div 2) + width * 2 div 100); // split vertically in the middle |
121 |
114 |
122 |
115 |
123 //r:= r + (trunc(1000 - sqrt(sqr(x - (width div 2)) * 4 + sqr(y - height * 5 div 4) * 22))) div 600 * 20; // ellipse |
116 //r:= r + (trunc(1000 - sqrt(sqr(x - (width div 2)) * 4 + sqr(y - height * 5 div 4) * 22))) div 600 * 20; // ellipse |