Accept float x,y values

This commit is contained in:
kygoh
2021-06-03 00:23:38 +00:00
committed by Sébastien Corbin
parent a740767a06
commit e92132349c
2 changed files with 14 additions and 2 deletions

View File

@@ -23,8 +23,8 @@ def draw_signature(data, as_file=False):
raise ValueError raise ValueError
# Compute box # Compute box
width = max(chain(*[d['x'] for d in drawing])) + 10 width = int(round(max(chain(*[d['x'] for d in drawing])))) + 10
height = max(chain(*[d['y'] for d in drawing])) + 10 height = int(round(max(chain(*[d['y'] for d in drawing])))) + 10
# Draw image # Draw image
im = Image.new("RGBA", (width*AA, height*AA)) im = Image.new("RGBA", (width*AA, height*AA))

View File

@@ -0,0 +1,12 @@
import json
from django.test import SimpleTestCase
from jsignature.templatetags.jsignature_filters import signature_base64
FAULTY_SIGNATURE = [{"x": [120.00675156801722, 116.11464070635179, 114.16858527551909], "y": [83.0316983821957, 76.54484694608666, 224.44505968937275]}, {"x": [161.52260075911508, 165.4147116207805, 173.84761848772226, 184.2265807854967, 201.0923945193802], "y": [84.97775381302841, 79.78827266414118, 72.00405094081033, 62.922458930257676, 56.43560749414864]}]
DUMMY_STR_VALUE = json.dumps(FAULTY_SIGNATURE)
class TemplateFilterFailedTest(SimpleTestCase):
def test_throw_error(self):
output = signature_base64(DUMMY_STR_VALUE)