-
-
Save davelab6/bb582a691b46b5441d33 to your computer and use it in GitHub Desktop.
Little defconQt scripting examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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