reformat code with black
This commit is contained in:
+24
-24
@@ -1,31 +1,31 @@
|
||||
# coding=UTF-8
|
||||
|
||||
CANVAS = {
|
||||
'max_long_side': 500,
|
||||
'min_long_side': 20,
|
||||
'max_short_side': 150,
|
||||
'min_short_side': 20
|
||||
"max_long_side": 500,
|
||||
"min_long_side": 20,
|
||||
"max_short_side": 150,
|
||||
"min_short_side": 20,
|
||||
}
|
||||
|
||||
CANVAS_FRAME = {
|
||||
'max_long_side': 150,
|
||||
'min_long_side': 40,
|
||||
'max_short_side': 150,
|
||||
'min_short_side': 40,
|
||||
"max_long_side": 150,
|
||||
"min_long_side": 40,
|
||||
"max_short_side": 150,
|
||||
"min_short_side": 40,
|
||||
}
|
||||
|
||||
|
||||
def calculate_canvas_frame_limits(width, height):
|
||||
if width > height:
|
||||
width = min(width, CANVAS_FRAME.get('max_long_side'))
|
||||
width = max(width, CANVAS_FRAME.get('min_long_side'))
|
||||
height = min(height, CANVAS_FRAME.get('max_short_side'))
|
||||
height = max(height, CANVAS_FRAME.get('min_short_side'))
|
||||
width = min(width, CANVAS_FRAME.get("max_long_side"))
|
||||
width = max(width, CANVAS_FRAME.get("min_long_side"))
|
||||
height = min(height, CANVAS_FRAME.get("max_short_side"))
|
||||
height = max(height, CANVAS_FRAME.get("min_short_side"))
|
||||
else:
|
||||
height = min(height, CANVAS_FRAME.get('max_long_side'))
|
||||
height = max(height, CANVAS_FRAME.get('min_long_side'))
|
||||
width = min(width, CANVAS_FRAME.get('max_short_side'))
|
||||
width = max(width, CANVAS_FRAME.get('min_short_side'))
|
||||
height = min(height, CANVAS_FRAME.get("max_long_side"))
|
||||
height = max(height, CANVAS_FRAME.get("min_long_side"))
|
||||
width = min(width, CANVAS_FRAME.get("max_short_side"))
|
||||
width = max(width, CANVAS_FRAME.get("min_short_side"))
|
||||
|
||||
# round to nearest 10
|
||||
width = round(width, -1)
|
||||
@@ -39,14 +39,14 @@ def calculate_canvas_limits(width, height, framed=False):
|
||||
return calculate_canvas_frame_limits(width, height)
|
||||
|
||||
if width > height:
|
||||
width = min(width, CANVAS.get('max_long_side'))
|
||||
width = max(width, CANVAS.get('min_long_side'))
|
||||
height = min(height, CANVAS.get('max_short_side'))
|
||||
height = max(height, CANVAS.get('min_short_side'))
|
||||
width = min(width, CANVAS.get("max_long_side"))
|
||||
width = max(width, CANVAS.get("min_long_side"))
|
||||
height = min(height, CANVAS.get("max_short_side"))
|
||||
height = max(height, CANVAS.get("min_short_side"))
|
||||
else:
|
||||
height = min(height, CANVAS.get('max_long_side'))
|
||||
height = max(height, CANVAS.get('min_long_side'))
|
||||
width = min(width, CANVAS.get('max_short_side'))
|
||||
width = max(width, CANVAS.get('min_short_side'))
|
||||
height = min(height, CANVAS.get("max_long_side"))
|
||||
height = max(height, CANVAS.get("min_long_side"))
|
||||
width = min(width, CANVAS.get("max_short_side"))
|
||||
width = max(width, CANVAS.get("min_short_side"))
|
||||
|
||||
return width, height
|
||||
|
||||
Reference in New Issue
Block a user