diff options
Diffstat (limited to 'ricky/pbgradient')
| -rw-r--r-- | ricky/pbgradient/__init__.py | 15 | ||||
| -rw-r--r-- | ricky/pbgradient/params.py | 166 | ||||
| -rw-r--r-- | ricky/pbgradient/probabilities.json | 120 | ||||
| -rw-r--r-- | ricky/pbgradient/probabilities.py | 102 |
4 files changed, 403 insertions, 0 deletions
diff --git a/ricky/pbgradient/__init__.py b/ricky/pbgradient/__init__.py new file mode 100644 index 0000000..96b15a5 --- /dev/null +++ b/ricky/pbgradient/__init__.py @@ -0,0 +1,15 @@ +"""class for the imgradient api handler""" +from ricky.pb import Pb +from ricky.pbgradient.params import Params +from ricky.config import IMGRADIENT_URL + + +class PbGradient(Pb): + def __init__(self): + super(PbGradient, self).__init__() + self.url = IMGRADIENT_URL + + def params_init(self): + new_params = Params() + new_params.api = self + return new_params diff --git a/ricky/pbgradient/params.py b/ricky/pbgradient/params.py new file mode 100644 index 0000000..48e25f5 --- /dev/null +++ b/ricky/pbgradient/params.py @@ -0,0 +1,166 @@ +from ricky.params import Params as _Params +from ricky.param.username import Username +from ricky.param.enum import Enum +from ricky.param.constrainednumber import ConstrainedNumber +from ricky.param.bool import Bool +from ricky.param.color import Color + + +_HALFTONE_OPTIONS = [ + "", + "checkeredfade", + "etchedtransition", + "bendaydots", + "smallerdots1", + "smallerdots2", + "flatstripes", +] + +_BEVEL_OPTIONS = [ + "", + "flatout", + "flatinner", + "evenlyframed", + "biginner", + "bigouter", + "dramaticflatout", + "dramaticflatinner", +] + +_FILETYPE_OPTIONS = [ + "png", + "jpg", + "gif", +] + +_GRADIENTTYPE_OPTIONS = [ + "canvas", + "gradient", + "radial", + "colorspace", + "plasmawash", + "gradientwash", + "mirrored", + "noise", +] + + +class Params(_Params): + def __init__(self): + super(Params, self).__init__( + Username(name="username", required=False), + ConstrainedNumber( + name="width", + required=True, + enforce_int=True, + min=10, + max=800 + ), + ConstrainedNumber( + name="height", + required=True, + enforce_int=True, + min=10, + max=800 + ), + Color(name="color1", required=True), + Color(name="color2", required=True), + Enum( + name="filetype", + required=False, + options=_FILETYPE_OPTIONS + ), + Enum( + name="gradienttype", + required=True, + options=_GRADIENTTYPE_OPTIONS + ), + Enum( + name="halftone", + required=False, + options=_HALFTONE_OPTIONS + ), + Enum( + name="bevel", + required=False, + options=_BEVEL_OPTIONS + ), + ConstrainedNumber( + name="stripenumber", + required=False, + enforce_int=True, + min=0, + max=400 + ), + ConstrainedNumber( + name="stripeintensity", + required=False, + enforce_int=True, + min=0, + max=5000 + ), + ConstrainedNumber( + name="blurriness", + required=False, + enforce_int=True, + min=0, + max=200 + ), + ConstrainedNumber( + name="contrast", + required=False, + enforce_int=True, + min=0, + max=200 + ), + ConstrainedNumber( + name="brightness", + required=False, + enforce_int=True, + min=0, + max=200 + ), + ConstrainedNumber( + name="saturation", + required=False, + enforce_int=True, + min=0, + max=200 + ), + ConstrainedNumber( + name="hue", + required=False, + enforce_int=True, + min=0, + max=200 + ), + ConstrainedNumber( + name="percentbeveled", + required=False, + enforce_int=True, + min=0, + max=100 + ), + ConstrainedNumber( + name="rotate", + required=False, + enforce_int=True, + min=0, + max=360 + ), + ConstrainedNumber( + name="tilt", + required=False, + enforce_int=True, + min=0, + max=360 + ), + Bool( + name="flop", + required=False, + ), + Bool( + name="flip", + required=False + ) + ) diff --git a/ricky/pbgradient/probabilities.json b/ricky/pbgradient/probabilities.json new file mode 100644 index 0000000..0c6c0df --- /dev/null +++ b/ricky/pbgradient/probabilities.json @@ -0,0 +1,120 @@ +{ + "width" : [ + {"value": 40, "weight": 10} + ], + "height" : [ + {"value": 400, "weight": 100} + ], + "color1" : [ + {"value": "", "weight": 0}, + {"value": "black", "weight": 1}, + {"value": "white", "weight": 2} + ], + "color2" : [ + {"value": "", "weight": 0}, + {"value": "black", "weight": 2}, + {"value": "white", "weight": 1} + ], + "stripes" : [ + {"value": "true", "weight": 3}, + {"value": "false", "weight": 1} + ], + "stripenumber" : [ + {"value": 3, "weight": 10}, + {"value": 10, "weight": 10}, + {"value": 20, "weight": 10}, + {"value": 100, "weight": 10}, + {"value": 40, "weight": 10}, + {"value": 1, "weight": 50}, + {"value": 2, "weight": 50}, + {"value": 2, "weight": 50} + ], + "stripeintensity" : [ + {"value": 1000, "weight": 10}, + {"value": 4, "weight": 10} + ], + "contrast" : [ + {"value": "", "weight": 0}, + {"value": "", "weight": 300} + ], + "brightness" : [ + {"value": "", "weight": 0}, + {"value": "", "weight": 300} + ], + "saturation" : [ + {"value": "", "weight": 0}, + {"value": "", "weight": 300} + ], + "hue" : [ + {"value": "", "weight": 0}, + {"value": "", "weight": 300} + ], + "halftone" : [ + {"value": "", "weight": 60}, + {"value": "checkeredfade", "weight": 10}, + {"value": "etchedtransition", "weight": 10}, + {"value": "bendaydots", "weight": 10}, + {"value": "smallerdots1", "weight": 10}, + {"value": "smallerdots2", "weight": 10}, + {"value": "flatstripes", "weight": 10} + ], + "bevel" : [ + {"value": "", "weight": 4}, + {"value": "flatout", "weight": 1}, + {"value": "flatinner", "weight": 0}, + {"value": "evenlyframed", "weight": 1}, + {"value": "biginner", "weight": 1}, + {"value": "bigouter", "weight": 1}, + {"value": "dramaticflatout", "weight": 1}, + {"value": "dramaticflatinner", "weight": 1} + ], + "blurriness" : [ + {"value": 30, "weight": 10}, + {"value": 10, "weight": 10}, + {"value": 5, "weight": 10}, + {"value": 20, "weight": 10}, + {"value": 25, "weight": 10}, + {"value": 7, "weight": 10}, + {"value": "", "weight": 1} + ], + "percentbeveled" : [ + {"value": 30, "weight": 10}, + {"value": 10, "weight": 10}, + {"value": 5, "weight": 10}, + {"value": 20, "weight": 10}, + {"value": 25, "weight": 10}, + {"value": 7, "weight": 10}, + {"value": "", "weight": 1} + ], + "rotate" : [ + {"value": 0, "weight": 200}, + {"value": 90, "weight": 2}, + {"value": 180, "weight": 2}, + {"value": 270, "weight": 2} + ], + "tilt" : [ + {"value": 0, "weight": 200}, + {"value": 90, "weight": 2}, + {"value": 180, "weight": 2}, + {"value": 270, "weight": 2} + ], + "flop_probabilities : flip" : [ + {"value": "", "weight": 1}, + {"value": "true", "weight": 1} + ], + "filetype" : [ + {"value": "png", "weight": 10}, + {"value": "jpg", "weight": 2}, + {"value": "gif", "weight": 2} + ], + "gradienttype" : [ + {"value": "canvas", "weight": 1}, + {"value": "gradient", "weight": 5}, + {"value": "radial", "weight": 1}, + {"value": "colorspace", "weight": 1}, + {"value": "plasmawash", "weight": 2}, + {"value": "gradientwash", "weight": 1}, + {"value": "mirrored", "weight": 0}, + {"value": "noise", "weight": 1} + ] +} diff --git a/ricky/pbgradient/probabilities.py b/ricky/pbgradient/probabilities.py new file mode 100644 index 0000000..d77739f --- /dev/null +++ b/ricky/pbgradient/probabilities.py @@ -0,0 +1,102 @@ +from ricky.param.probabilities import Probabilities + +width_probabilities = Probabilities.from_dict( + {"value": 40, "weight": 10}, +) +height_probabilities = Probabilities.from_dict( + {"value": 400, "weight": 100}, +) +color1_probabilities = Probabilities.from_dict( + {"value": "", "weight": 0}, +# {"value": "black", "weight": 1}, +# {"value": "white", "weight": 2}, +) +color2_probabilities = Probabilities.from_dict( + {"value": "", "weight": 0}, +# {"value": "black", "weight": 2}, +# {"value": "white", "weight": 1}, +) +stripes_probabilities = Probabilities.from_dict( + {"value": "true", "weight": 3}, + {"value": "false", "weight": 1}, +) +stripenumber_probabilities = Probabilities.from_dict( + {"value": 3, "weight": 10}, + {"value": 10, "weight": 10}, + {"value": 20, "weight": 10}, + {"value": 100, "weight": 10}, + {"value": 40, "weight": 10}, +# {"value": 1, "weight": 50}, +# {"value": 2, "weight": 50}, +# {"value": 2, "weight": 50}, + +) +stripeintensity_probabilities = Probabilities.from_dict( + {"value": 1000, "weight": 10}, + {"value": 4, "weight": 10}, +) +# contrast_probabilities = \ +brightness_probabilities = \ + saturation_probabilities = \ + hue_probabilities = \ + Probabilities.from_dict( + {"value": "", "weight": 0}, +# {"value": "", "weight": 300}, +) +halftone_probabilities = Probabilities.from_dict( + {"value": "", "weight": 60}, + {"value": "checkeredfade", "weight": 10}, + {"value": "etchedtransition", "weight": 10}, + {"value": "bendaydots", "weight": 10}, + {"value": "smallerdots1", "weight": 10}, + {"value": "smallerdots2", "weight": 10}, + {"value": "flatstripes", "weight": 10}, +) +bevel_probabilities = Probabilities.from_dict( + {"value": "", "weight": 4}, + {"value": "flatout", "weight": 1}, + {"value": "flatinner", "weight": 0}, + {"value": "evenlyframed", "weight": 1}, +# {"value": "biginner", "weight": 1}, + {"value": "bigouter", "weight": 1}, + {"value": "dramaticflatout", "weight": 1}, +# {"value": "dramaticflatinner", "weight": 1}, +) + +blurriness_probabilities = \ + percentbeveled_probabilities = Probabilities.from_dict( + {"value": 30, "weight": 10}, + {"value": 10, "weight": 10}, + {"value": 5, "weight": 10}, + {"value": 20, "weight": 10}, + {"value": 25, "weight": 10}, + {"value": 7, "weight": 10}, + {"value": "", "weight": 1}, +) +rotate_probabilities = \ + tilt_probabilities = Probabilities.from_dict( + {"value": 0, "weight": 200}, + {"value": 90, "weight": 2}, + {"value": 180, "weight": 2}, + {"value": 270, "weight": 2}, +) +flop_probabilities = flip_probabilities = Probabilities.from_dict( + {"value": "", "weight": 1}, + {"value": "true", "weight": 1}, +) + +filetype_probabilities = Probabilities.from_dict( + {"value": "png", "weight": 10}, + {"value": "jpg", "weight": 2}, + {"value": "gif", "weight": 2}, +) +gradienttype_probabilities = Probabilities.from_dict( + {"value": "canvas", "weight": 1}, + {"value": "gradient", "weight": 5}, + {"value": "radial", "weight": 1}, + {"value": "colorspace", "weight": 1}, + {"value": "plasmawash", "weight": 2}, + {"value": "gradientwash", "weight": 1}, + {"value": "mirrored", "weight": 0}, + {"value": "noise", "weight": 1}, +) |
