Skip to content

Commit

Permalink
#51 convert to SVG workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbuckle committed Dec 28, 2021
1 parent a50a06b commit 8b84191
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions test_bindings.py
Expand Up @@ -34,17 +34,17 @@ def testPath(self):
self.assertEqual(configPathStr, expectedPathStr)

def testPathWithSuffix(self):
configPathStr = str(self.config.pathWithSuffix('.jpg'))
expectedPathStr = str(self.expectedConfigPath) + '.jpg'
configPathStr = str(self.config.pathWithSuffix('.svg'))
expectedPathStr = str(self.expectedConfigPath) + '.svg'
self.assertEqual(configPathStr, expectedPathStr)

def testSuffixMustStartWithDot(self):
with self.assertRaises(ValueError):
configPathStr = self.config.pathWithSuffix('jpg')
configPathStr = self.config.pathWithSuffix('svg')

def testPathWithNameAndSuffix(self):
configPathStr = str(self.config.pathWithNameAndSuffix('spam', '.jpg'))
expectedPathStr = str(self.expectedConfigPath) + '-spam.jpg'
configPathStr = str(self.config.pathWithNameAndSuffix('spam', '.svg'))
expectedPathStr = str(self.expectedConfigPath) + '-spam.svg'
self.assertEqual(configPathStr, expectedPathStr)

def testRefCardURL(self):
Expand Down
18 changes: 9 additions & 9 deletions www/scripts/bindings.py
Expand Up @@ -212,12 +212,12 @@ def writeUrlToDrawing(config, drawing, public):
# Create a keyboard image from the template plus bindings
def createKeyboardImage(physicalKeys, modifiers, source, imageDevices, biggestFontSize, displayGroups, runId, public):
config = Config(runId)
filePath = config.pathWithNameAndSuffix(source, '.jpg')
filePath = config.pathWithNameAndSuffix(source, '.svg')

# See if it already exists or if we need to recreate it
if filePath.exists():
return True
with Image(filename='../res/' + source + '.jpg') as sourceImg:
with Image(filename='../res/' + source + '.svg') as sourceImg:
with Drawing() as context:

# Defaults for the font
Expand Down Expand Up @@ -370,9 +370,9 @@ def createBlockImage(supportedDeviceKey, strokeColor='Red', fillColor='LightGree
templateName = supportedDevice['Template']
config = Config(templateName)
config.makeDir()
filePath = config.pathWithSuffix('.jpg')
filePath = config.pathWithSuffix('.svg')

with Image(filename='../res/' + supportedDevice['Template'] + '.jpg') as sourceImg:
with Image(filename='../res/' + supportedDevice['Template'] + '.svg') as sourceImg:
with Drawing() as context:
if not dryRun:
context.font = getFontPath('Regular', 'Normal')
Expand Down Expand Up @@ -420,12 +420,12 @@ def createHOTASImage(physicalKeys, modifiers, source, imageDevices, biggestFontS
name = source
else:
name = '%s-%s' % (source, deviceIndex)
filePath = config.pathWithNameAndSuffix(name, '.jpg')
filePath = config.pathWithNameAndSuffix(name, '.svg')

# See if it already exists or if we need to recreate it
if filePath.exists():
return True
with Image(filename='../res/' + source + '.jpg') as sourceImg:
with Image(filename='../res/' + source + '.svg') as sourceImg:
with Drawing() as context:

# Defaults for the font
Expand Down Expand Up @@ -825,11 +825,11 @@ def printRefCard(config, public, createdImages, deviceForBlockImage, errors):
device = createdImage
deviceIndex = 0
if deviceIndex == 0:
print('<img width="100%%" src="../configs/%s/%s-%s.jpg"/><br/>' % (runId[:2], runId, supportedDevices[device]['Template']))
print('<img width="100%%" src="../configs/%s/%s-%s.svg"/><br/>' % (runId[:2], runId, supportedDevices[device]['Template']))
else:
print('<img width="100%%" src="../configs/%s/%s-%s-%s.jpg"/><br/>' % (runId[:2], runId, supportedDevices[device]['Template'], deviceIndex))
print('<img width="100%%" src="../configs/%s/%s-%s-%s.svg"/><br/>' % (runId[:2], runId, supportedDevices[device]['Template'], deviceIndex))
if deviceForBlockImage is not None:
print('<img width="100%%" src="../configs/%s/%s.jpg"/><br/>' % (supportedDevices[deviceForBlockImage]['Template'][:2], supportedDevices[deviceForBlockImage]['Template']))
print('<img width="100%%" src="../configs/%s/%s.svg"/><br/>' % (supportedDevices[deviceForBlockImage]['Template'][:2], supportedDevices[deviceForBlockImage]['Template']))
if deviceForBlockImage is None and public is True:
linkURL = config.refcardURL()
bindsURL = config.bindsURL()
Expand Down

0 comments on commit 8b84191

Please sign in to comment.