scannerlicker: learn: articles
Randomize Points Within a Radius – FontLab Script
April 16, 2014
By Fábio Duarte Martins.
Filed under: Scripts
Tags:

Here’s a small FontLab script that randomizes a point’s position within a circle around it. It was made to streamline the process of creating Randomly (see image above).

Here you go:

import math, random

def makeRandom (g,nid,_radius):

circleRandAngle = random.random() * math.pi *2
circleRandRad = random.random() * _radius

n = g[nid]
mX = int(math.cos(circleRandAngle) * circleRandRad)
mY = int(math.sin(circleRandAngle) * circleRandRad)

n.x += mX
n.y += mY

# Set the radius here
RADIUS = 15

g = fl.glyph
fl.SetUndo()
i = 0
while i < len(g.nodes):
n = g[i]
if n.selected:
makeRandom(g,i,RADIUS)
i += 1

fl.UpdateGlyph()
subscribe
The newsletter will keep you up-to-date with subscriber-only treats, blog posts, free content, events and releases. Oh, and there’s a book in the works.
No spam. No affiliate B.S. Only goodness.