knob-steps.py 803 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. # SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. import os, numpy, sys
  5. from PIL import Image
  6. source = "knob.png"
  7. source_full_width = 8320
  8. source_size = 128
  9. source_png = Image.open(source)
  10. source_steps = int(source_full_width / source_size)
  11. steps_list = range(3, 18)
  12. for steps in steps_list:
  13. target_full_width = source_size * steps
  14. target_step_advance = ((source_steps-1) / (steps-1))
  15. target_png = Image.new("RGBA", (target_full_width, source_size), (0, 0, 0, 0))
  16. for step in range(steps):
  17. x = int(step * target_step_advance) * source_size
  18. target_png.paste(source_png.copy().crop((x, 0, x+source_size, source_size)), (step * source_size, 0))
  19. target_png.save("knob_steps_{}.png".format(steps))