-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgenerate-random-walk.py
More file actions
executable file
·50 lines (37 loc) · 1.12 KB
/
generate-random-walk.py
File metadata and controls
executable file
·50 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# ------------------------------------------------------------------
# Copyright (C) 2013 Michael Aschauer
# ------------------------------------------------------------------
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.s
# ------------------------------------------------------------------
import stitchcode
import numpy
import math
maxstep = 30
maxx = 800
maxy = 600
if __name__ == "__main__":
emb = stitchcode.Embroidery()
(x,y) = (0,0)
for i in range(0,4000):
sx = numpy.random.normal(0,1) * maxstep
sy = numpy.random.normal(0,1) * maxstep
if (x + sx < 0):
sx *= -1
if (x + sx > maxx):
sx *= -1
x += sx
if (y + sy < 0):
sy *= -1
if (y + sy > maxy):
sy *= -1
y += sy
print x,y, "/", sx,sy
emb.addStitch(stitchcode.Point(x,y))
emb.scale(1)
emb.translate_to_origin()
emb.save_as_exp("random-walk.exp")
emb.save_as_png("random-walk.png",False)