summaryrefslogtreecommitdiff
path: root/lib/imgradient_params_defaults.py
blob: d0ba3acd81068d6c3470337c559293b5dc922906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/python2.7
import random
from config import USERNAME, TEST_URL
from lib.utils import Pb_Api_Params

#            "width", "height", 
#            "color1", "color2", 
#            "stripes",
#            "stripenumber", "stripeintensity", 
#            "blurriness", 
#            "contrast", 
#            "brightness", "saturation", "hue",
#            "halftone", 
#            "bevel", "percentbeveled",
#            "rotate", "flip", "flop", "tilt", 
#            "filetype",
#            "gradienttype", 
#            "username",

class ImGradientParams_FromDefaults(Pb_Api_Params):
    def __init__(self):
        self.weighted_width = [
            { "value" : 400, "weight" : 1 }, 
            { "value" : 600, "weight" : 1 }, 
        ]
        self.weighted_height = [
            { "value" : 400, "weight" : 1 }, 
            { "value" : 600, "weight" : 1 }, 
        ]
        self.weighted_colors = [
            { "value" : 
                "rgb({},{},{})".format(
                     random.randint(0,255),
                     random.randint(0,255),
                     random.randint(0,255),
                ),
                "weight" : 1 }, 
            { "value" : "black", "weight" : 1 }, 
            { "value" : "white", "weight" : 1 }, 
        ]
        self.weighted_stripes = [
            {"value":"true",  "weight": 1},
            {"value":"false",  "weight": 1},
        ]
        self.weighted_stripenumber = [
            {"value":1,  "weight": 1},
            {"value":2,  "weight": 1},
            {"value":random.randint(0,400),  "weight": 1},
        ]
        self.weighted_stripeintensity = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,2000),  "weight": 1},
        ]
        self.weighted_blurriness = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,20),   "weight": 1},
        ]
        self.weighted_contrast = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,20),   "weight": 1},
        ]
        self.weighted_brightness = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,200),  "weight": 1},
        ]
        self.weighted_saturation = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,200),  "weight": 1},
        ]
        self.weighted_hue = [
            {"value": "",  "weight": 3},
            {"value": random.randint(0,200),  "weight": 1},
        ]
        self.weighted_halftone = [
            { "value" : "checkeredfade", "weight": 1 },
            { "value" : "etchedtransition", "weight": 1 },
            { "value" : "bendaydots", "weight": 1 },
            { "value" : "smallerdots1", "weight": 1 },
            { "value" : "smallerdots2", "weight": 1 },
            { "value" : "flatstripes", "weight": 1 },
        ]
        self.weighted_bevel = [
            { "value" : "", "weight" : 4 }, 
            { "value" : "flatout", "weight" : 1 }, 
            { "value" : "flatinner", "weight" : 1 }, 
            { "value" : "evenlyframed", "weight" : 1 }, 
            { "value" : "biginner", "weight" : 1 }, 
            { "value" : "bigouter", "weight" : 1 }, 
            { "value" : "dramaticflatout", "weight" : 1 }, 
            { "value" : "dramaticflatinner", "weight" : 1 }, 
        ]
        self.weighted_percentbeveled = [
            { "value" : random.randint(0,99),  "weight": 1 },
            { "value" : "",  "weight": 4 },
        ]
        self.weighted_rotate = [
            {"value":"",    "weight": 9},
            {"value":90,   "weight": 2},
            {"value":180,  "weight": 2},
            {"value":270,  "weight": 2},
            {"value":random.randint(0,360),  "weight": 4},
        ]
        self.weighted_flop = [
            {"value":"",  "weight": 1},
            {"value":"true",   "weight": 1},
        ]
        self.weighted_flip = [
            {"value":"",  "weight": 1},
            {"value":"true",   "weight": 1},
        ]
        self.weighted_tilt = [
            {"value":"",    "weight": 9},
            {"value":90,   "weight": 2},
            {"value":180,  "weight": 2},
            {"value":270,  "weight": 2},
            {"value":random.randint(0,360),  "weight": 4},
        ]
        self.weighted_filetype = [
            {"value":"png",  "weight": 5},
            {"value":"jpg",  "weight": 2},
            {"value":"gif",  "weight": 2},
        ]
        self.weighted_gradienttype = [
            { "value" : "canvas", "weight" : 1 }, 
            { "value" : "gradient", "weight" : 3 }, 
            { "value" : "radial", "weight" : 1 }, 
            { "value" : "colorspace", "weight" : 1 }, 
            { "value" : "plasmawash", "weight" : 1 }, 
            { "value" : "gradientwash", "weight" : 1 }, 
            { "value" : "mirrored", "weight" : 1 }, 
            { "value" : "noise", "weight" : 1 }, 
        ]

#I just needed a place to encapsulate the params and the weights, and methods to access them. I guess I didn't really know the right answer
#as far as the structure, so I tried to just imagine something somewhat related to what you were talking about before.
#do I need separate classes for the two methods below?
#well lets dicusss this a bit more, so services each have own param set, they are sort of original from service itself, so i guess there should be a way to get
#"fresh" copy of parameters accepted by this service, instead of rewriting code each time. do you mean just a list of the keynames? yeah and thier values
#the keys don't have default values necessarily. they just each have a range of accepted values. Basically just html forms hmm sort of like
#writing a bot that fills in some forms on the internet, like a bot to brute force a credit card form or something, funny example, but I guess a good one
#each parameter has values that are within an accepted range, like First Name would need to come from a list of frist names, and CC number would need to bevel
#intelligible ints, the first four should correspond with a known bank, etc. you understand what I mean? yeah
ok so since all services are about same, just a bunch of parameters and known values we can make base class for parameteres. it would look like:


class ApiParams(object):
   def params():
   def randomize():
   def build():

class ImGradientParams(ApiParams):
   def __init__():
     self.params = {
       "width": # well here it's int i suppose, need somethig esle
       "gradienttype": [
         { "value "...}
       ]
     }
   
class ImGradientPb_Api():
   def params():
    return new ImGradientParams()
   def call(params):
    return image();


api = ImGradientPb_Api()
image_params = api.params()
image_params.gradient_type("mirror")
image_params.randomize()
image = api.call(image _params)
# something like this, yeah I think so...lol I tried to do something like this


    def from_random(self):
        return {
            "username" : USERNAME, 
            "width" : self._weighted_choice( self.weighted_width ),
            "height" : self._weighted_choice( self.weighted_height ),
            "color1" : self._weighted_choice( self.weighted_colors ),
            "color2" : self._weighted_choice( self.weighted_colors ),
            "stripenumber" : self._weighted_choice( self.weighted_stripenumber ),
            "stripeintensity" : self._weighted_choice( self.weighted_stripeintensity ),
            "blurriness" : self._weighted_choice( self.weighted_blurriness ),
            "contrast" : self._weighted_choice( self.weighted_contrast ),
            "brightness" : self._weighted_choice( self.weighted_brightness ),
            "saturation" : self._weighted_choice( self.weighted_saturation ),
            "hue" : self._weighted_choice( self.weighted_hue ),
            "halftone" : self._weighted_choice( self.weighted_halftone ),
            "bevel" : self._weighted_choice( self.weighted_bevel ),
            "percentbeveled" : self._weighted_choice( self.weighted_percentbeveled ),
            "rotate" : self._weighted_choice( self.weighted_rotate ),
            "flip" : self._weighted_choice( self.weighted_flip ),
            "flop" : self._weighted_choice( self.weighted_flop ),
            "tilt" : self._weighted_choice( self.weighted_tilt ),
            "filetype" : self._weighted_choice( self.weighted_filetype ),
            "gradienttype" : self._weighted_choice( self.weighted_gradienttype ),
        }
    def from_default(self):
        return {
            "url" : url,
            "username" : USERNAME, 
            "width" : self._default_choice( self.weighted_width ),
            "height" : self._default_choice( self.weighted_height ),
            "color1" : self._default_choice( self.weighted_colors ),
            "color2" : self._default_choice( self.weighted_colors ),
            "stripenumber" : self._default_choice( self.weighted_stripenumber ),
            "stripeintensity" : self._default_choice( self.weighted_stripeintensity ),
            "blurriness" : self._default_choice( self.weighted_blurriness ),
            "contrast" : self._default_choice( self.weighted_contrast ),
            "brightness" : self._default_choice( self.weighted_brightness ),
            "saturation" : self._default_choice( self.weighted_saturation ),
            "hue" : self._default_choice( self.weighted_hue ),
            "halftone" : self._default_choice( self.weighted_halftone ),
            "bevel" : self._default_choice( self.weighted_bevel ),
            "percentbeveled" : self._default_choice( self.weighted_percentbeveled ),
            "rotate" : self._default_choice( self.weighted_rotate ),
            "flip" : self._default_choice( self.weighted_flip ),
            "flop" : self._default_choice( self.weighted_flop ),
            "tilt" : self._default_choice( self.weighted_tilt ),
            "filetype" : self._default_choice( self.weighted_filetype ),
            "gradienttype" : self._default_choice( self.weighted_gradienttype ),
        }