Skip to content

Instantly share code, notes, and snippets.

@davelab6
Forked from adrientetar/FuzzWindow.py
Created January 4, 2016 22:30
Show Gist options
  • Save davelab6/bb582a691b46b5441d33 to your computer and use it in GitHub Desktop.
Save davelab6/bb582a691b46b5441d33 to your computer and use it in GitHub Desktop.
Little defconQt scripting examples
from PyQt5.QtWidgets import QDialog, QPushButton, QVBoxLayout
import random
class FuzzDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
layout = QVBoxLayout(self)
fuzzBox = QPushButton("Fuzz", self)
fuzzBox.clicked.connect(self.glyphFuzzer)
layout.addWidget(fuzzBox)
self.setLayout(layout)
def glyphFuzzer(self):
glyph = CurrentGlyph()
if glyph is not None and len(glyph):
glyph.prepareUndo()
for contour in glyph:
for point in contour:
point.x += random.randrange(-4, 5)
point.y += random.randrange(-4, 5)
glyph.dirty = True
window = FuzzDialog()
window.show()
import random
font = CurrentFont()
for glyph in font:
glyph.prepareUndo()
color = ",".join(str(random.random()) for _ in range(4))
glyph.lib["public.markColor"] = color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment