Skip to content

Instantly share code, notes, and snippets.

@peterooch
Created August 16, 2021 11:27
Show Gist options
  • Save peterooch/0aafff20dce4e6e61a792355438c29d3 to your computer and use it in GitHub Desktop.
Save peterooch/0aafff20dce4e6e61a792355438c29d3 to your computer and use it in GitHub Desktop.
import re
src = open("keyboard.c", "r")
dst = open("keyboard2.c", "w")
SCALE = 0.80
def sub(m: re.Match):
x = int(int(m.group(1)) * SCALE)
y = int(int(m.group(2)) * SCALE)
cx = int(int(m.group(3)) * SCALE)
cy = int(int(m.group(4)) * SCALE)
return f', {x}, {y}, {cx}, {cy},'
for line in src.readlines():
dst.write(re.sub(", (\d+), (\d+), (\d+), (\d+),", sub, line))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment