summaryrefslogtreecommitdiff
path: root/Pb_Api/ImGrid
diff options
context:
space:
mode:
Diffstat (limited to 'Pb_Api/ImGrid')
-rw-r--r--Pb_Api/ImGrid/Params.py111
-rw-r--r--Pb_Api/ImGrid/__init__.py13
-rwxr-xr-xPb_Api/ImGrid/options.py64
3 files changed, 0 insertions, 188 deletions
diff --git a/Pb_Api/ImGrid/Params.py b/Pb_Api/ImGrid/Params.py
deleted file mode 100644
index c469b6a..0000000
--- a/Pb_Api/ImGrid/Params.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import re, random
-from Pb_Api.Params import Pb_Api_Params
-from Pb_Api.Param import Pb_Api_Param
-from Pb_Api.Param.Option import Pb_Api_Param_Option
-from Pb_Api.Param.Options import Pb_Api_Param_Options
-from Pb_Api.Param.Username import Pb_Api_Param_Username
-from Pb_Api.Param.Image_Url import Pb_Api_Param_Image_Url
-from Pb_Api.Param.MultiSelect import Pb_Api_Param_MultiSelect
-from Pb_Api.Param.NumberRange import Pb_Api_Param_NumberRange
-from Pb_Api.Param.Color import Pb_Api_Param_Color
-
-from Pb_Api.ImGrid.options import *
-
-class Param_Zoom(Pb_Api_Param_NumberRange):
- def __init__(self, **kwargs):
- super(Param_Zoom, self).__init__(**kwargs)
- self.exclusion_range = kwargs['exclusion_range']
- def test_value(self):
- return not ((self.value > self.exclusion_range[0]) and (self.value < self.exclusion_range[1]))
- def randomize(self):
- weights_total = sum(map(lambda x: x["weight"], self.options())) + 10
- choice = random.randint(0, weights_total)
- position = 0
- for elem in self.options():
- position += elem["weight"]
- if position >= choice:
- self.value = elem["value"]
- return
- max_tries = 10000
- while(max_tries):
- self.value = round(random.uniform(self.range_max, self.range_min), 2)
- if self.test_value: return
- max_tries -= 1;
- raise ValueError
-
- @property
- def value(self):
- return super(Pb_Api_Param_MultiSelect, self).get_value()
- @value.setter
- def value(self, value):
- self._value = value
- if not self._value is None:
- self.is_ready = 1
- self.set_by_user = 1
-
-class Param_Opacity(Pb_Api_Param_NumberRange):
- def __init__(self, **kwargs):
- super(Param_Opacity, self).__init__(**kwargs)
- def randomize(self):
- weights_total = sum(map(lambda x: x["weight"], self.options()) + self.range_max - self.range_min)
- choice = random.randint(0, weights_total)
- position = 0
- for elem in self.options():
- position += elem["weight"]
- if position >= choice:
- self.value = elem["value"]
- return
- self.value = round(random.uniform(self.range_min,range_max), 2),
-
-class ImGrid_Params(Pb_Api_Params):
- def __init__(self):
- self.params = [
- Pb_Api_Param_Username(name="username", required=0),
- Pb_Api_Param_Image_Url(name="bgimage", required=0),
- Pb_Api_Param_Image_Url(name="imageinstead", required=0),
- Pb_Api_Param_Image_Url(name="planebgimage", required=0),
- Pb_Api_Param_MultiSelect(name="format", required=0, options=format_options),
- Pb_Api_Param_MultiSelect(name="transition", required=1, options=transition_options),
- Pb_Api_Param_Color(name="skycolor", required=0, options=skycolor_colors),
- Pb_Api_Param_Color(name="planebgcolor", required=0, options=planebgcolor_colors),
- Pb_Api_Param_Color(name="bgcolor", required=0, options=bgcolor_colors),
- Pb_Api_Param_Color(name="linecolor", required=0, options=linecolor_colors),
- Pb_Api_Param_NumberRange(name="swing", required=0, options=swing_options, min=-170, max=170),
- Pb_Api_Param_NumberRange(name="tilt", required=0, options=tilt_options, min=-170, max=170),
- Pb_Api_Param_NumberRange(name="roll", required=0, options=roll_options, min=-170, max=170),
- Pb_Api_Param_NumberRange(name="width", required=0, options=width_options, min=100, max=800),
- Pb_Api_Param_NumberRange(name="height", required=0, options=height_options, min=100, max=800),
- Pb_Api_Param_NumberRange(name="linethickness", required=0, options=linethickness_options, min=1, max=30),
- Pb_Api_Param_NumberRange(name="opacity", required=0, options=opacity_options, min=0, max=1),
- Pb_Api_Param_NumberRange(name="spacing", required=0, options=spacing_options, min=2, max=100),
- Pb_Api_Param_MultiSelect(name="vlines", required=0, options=vlines_options),
- Pb_Api_Param_MultiSelect(name="hlines", required=0, options=hlines_options),
- Pb_Api_Param_MultiSelect(name="trim", required=0, options=trim_options),
- Pb_Api_Param_MultiSelect(name="shadow", required=0, options=shadow_options),
- Param_Zoom(name="zoom", required=0, options=zoom_options, min=-12, max=12, exclusion_range=[-1.1, 1.1]),
- ]
- def test_values(self):
- p = self.params
- return not any([
- (self.param('spacing').value > self.param('width').value),
- (self.param('spacing').value > self.param('height').value),
- (self.param('linethickness').value > self.param('width').value),
- (self.param('linethickness').value > self.param('height').value),
- ])
- def randomize(self):
- p = self.params
- for el in p:
- if el in ['spacing', 'linethickness']:
- continue
- if el.set_by_user:
- continue
- el.randomize()
- for name in ['spacing', 'linethickness']:
- max_tries = 10000
- while(max_tries):
- self.param(name).randomize()
- if self.test_values():
- return
- max_tries -= 1
- raise ValueError
-
diff --git a/Pb_Api/ImGrid/__init__.py b/Pb_Api/ImGrid/__init__.py
deleted file mode 100644
index 553c04c..0000000
--- a/Pb_Api/ImGrid/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python2.7
-from Pb_Api import Pb_Api
-from Pb_Api.ImGrid.Params import ImGrid_Params
-from config import IMGRID_URL
-
-class Pb_Api_ImGrid(Pb_Api):
- def __init__(self):
- self.url = IMGRID_URL
- def params_init(self):
- new_params = ImGrid_Params()
- #new_params = self.get_from_server()
- new_params.api = self
- return new_params
diff --git a/Pb_Api/ImGrid/options.py b/Pb_Api/ImGrid/options.py
deleted file mode 100755
index 387a489..0000000
--- a/Pb_Api/ImGrid/options.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from Pb_Api.Param.Options import Pb_Api_Param_Options
-format_options = Pb_Api_Param_Options.from_dict(
- { 'weight': 20, 'value': 'png' },
- { 'weight': 0, 'value': 'gif' },
- { 'weight': 0, 'value': 'jpg' },
-)
-transition_options = Pb_Api_Param_Options.from_dict(
- { "value" : "background", "weight": 1 },
- { "value" : "dither", "weight": 1 },
- { "value" : "random", "weight": 1 },
- { "value" : "tile", "weight": 1 },
- { "value" : "edge", "weight": 1 },
-)
-skycolor_colors = \
- bgcolor_colors = planebgcolor_colors = Pb_Api_Param_Options.from_dict(
- { "value" : "white", "weight" : 1 },
- { "value" : "silver", "weight" : 1 },
- { "value" : None, "weight" : 10 },
-)
-
-linecolor_colors = Pb_Api_Param_Options.from_dict(
- { "value" : "black", "weight" : 1 },
- { "value" : "white", "weight" : 1 },
- { "value" : "silver", "weight" : 1 },
-)
-swing_options = tilt_options = roll_options = Pb_Api_Param_Options.from_dict(
- {"value": "", "weight": 2},
- {"value": 30, "weight": 1},
- {"value": -30, "weight": 1},
-)
-width_options = height_options = Pb_Api_Param_Options.from_dict(
- { "value" : 400, "weight" : 1 },
- { "value" : 600, "weight" : 1 },
-)
-linethickness_options = Pb_Api_Param_Options.from_dict(
- {"value":1, "weight": 2},
- {"value":2, "weight": 1},
-)
-opacity_options = Pb_Api_Param_Options.from_dict(
- {"value":1, "weight": 2},
- {"value":0.5, "weight": 1},
-)
-spacing_options = Pb_Api_Param_Options.from_dict(
- {"value":10, "weight": 1},
- {"value":15, "weight": 1},
-)
-vlines_options = hlines_options = Pb_Api_Param_Options.from_dict(
- {"value":"", "weight": 2},
- {"value":"true", "weight": 1},
-)
-shadow_options = Pb_Api_Param_Options.from_dict(
- {"value":"", "weight": 1},
- {"value":"true", "weight": 1},
-)
-zoom_options = Pb_Api_Param_Options.from_dict(
- {"value": 0, "weight": 3},
- {"value": 1.2, "weight": 1},
- {"value": -1.2, "weight": 1},
-)
-trim_options = Pb_Api_Param_Options.from_dict(
- {"value":"", "weight": 1},
- {"value":"true", "weight": 1},
-)
-