9 |
# OFFS2 |
# OFFS2 |
10 |
# OFFS3 |
# OFFS3 |
11 |
|
|
12 |
|
import java |
13 |
|
from math import exp |
14 |
|
|
15 |
isNV2X = 0 |
isNV2X = 0 |
16 |
|
|
17 |
ptextures = {} |
ptextures = {} |
28 |
def getName(self): |
def getName(self): |
29 |
return self.name |
return self.name |
30 |
|
|
|
def mt(i): |
|
|
name, args = i |
|
|
return NamedTexture(name, args) |
|
|
|
|
31 |
tres = 128 |
tres = 128 |
32 |
|
|
33 |
ptextures["RGB2"] = [ |
ptextures["RGB2"] = [ |
34 |
mt(i) for i in [ |
apply(NamedTexture, i) for i in [ |
35 |
# ("rgbn", [512, 512, 0, 3, "RGB", "RGB", |
("rgbw1", [tres, tres, 0, 3, "RGB", "RGB", |
36 |
# "noise", ["type", "turbulence", "freq", "40", "scale", "-3", "bias", "2"]]), |
"fnoise", ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]]), |
|
# ("rgbw", [tres, tres, 0, 3, "RGB", "RGB", |
|
|
# "fnoise", ["scale", "2","bias",".5"]]), |
|
|
|
|
37 |
("rgbw2", [tres, tres, 0, 3, "RGB", "RGB", |
("rgbw2", [tres, tres, 0, 3, "RGB", "RGB", |
38 |
"fnoise", ["scale", ".5", "freq", "1", "df", "2", "bias", "0.5"]]), |
"fnoise", ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5", "seed", "1412"]]), |
39 |
|
|
40 |
|
("turb", [tres, tres, 0, 3, "RGB", "RGB", |
41 |
|
"fnoise", ["turb", "1", "scale", ".3", "freq", "1", "freq2", "100", "df", "2", "bias", "0"]]), |
42 |
|
|
43 |
("pyramid", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]]), |
("pyramid", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]]), |
44 |
("checkerboard", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "1"]]), |
("checkerboard", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "1"]]), |
49 |
def getPaperTexture(type, gen): |
def getPaperTexture(type, gen): |
50 |
return selectRandom(ptextures[type], gen) |
return selectRandom(ptextures[type], gen) |
51 |
|
|
52 |
|
|
53 |
|
class Textures: |
54 |
|
def __init__(self, seed): |
55 |
|
rnd = self.rnd = java.util.Random(seed) |
56 |
|
|
57 |
|
hyper = rnd.nextGaussian()*5 |
58 |
|
|
59 |
|
self.probs = {} |
60 |
|
|
61 |
|
for type in ptextures.keys(): |
62 |
|
self.probs[type] = [] |
63 |
|
sum = 0 |
64 |
|
|
65 |
|
for tex in ptextures[type]: |
66 |
|
prob = exp(rnd.nextGaussian() * hyper) |
67 |
|
|
68 |
|
self.probs[type].append(prob) |
69 |
|
sum += prob |
70 |
|
|
71 |
|
self.probs[type] = [ prob / sum for prob in self.probs[type] ] |
72 |
|
|
73 |
|
#print self.probs[type] |
74 |
|
|
75 |
|
|
76 |
|
def getPaperTexture(self, type, gen): |
77 |
|
index = 0 |
78 |
|
|
79 |
|
t = self.rnd.nextDouble() |
80 |
|
|
81 |
|
for p in self.probs[type]: |
82 |
|
t -= p |
83 |
|
if t < 0: |
84 |
|
#print ptextures[type][index].getName() |
85 |
|
return ptextures[type][index] |
86 |
|
index += 1 |
87 |
|
|
88 |
|
print "Warning: null probability event occured" |
89 |
|
return ptextures[type][-1] |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
if 0: |
if 0: |
94 |
rgbTextures = [ |
rgbTextures = [ |
95 |
#("debug", [512, 512, 0, 3, |
#("debug", [512, 512, 0, 3, |