-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.jl
70 lines (64 loc) · 1.99 KB
/
sketch.jl
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Revise
using Plots
using Random
using Luxor
include("fns.jl")
include("Trail.jl")
include("Fields.jl")
W=H=600
cellSize=4 # integer
minVectorLength=.01; minStep=.5
mergeDistance=cellSize
darkmode=false
displayColor="black"
diagnosticMode=false
diagnosticPoints=Point[]
trails=[]
distanceWPower=1.5; distancePower=.5
function main()
darkmode ? displayColor="white" : displayColor="black"
SEED=rand(1:10000)
# SEED=2650
Random.seed!(SEED)
println("new run with seed: ",SEED)
@time begin
cells = [PointObject[] for _ in 1:(W ÷ cellSize + 2), _ in 1:(H ÷ cellSize + 2)]
fields=Field[]
fieldsAmounts = Dict(attLineField =>1,streamLineField => 0, attPointField => 0, dipoleStreamField => 0)
initializeFields!(fields,fieldsAmounts)
println.(fields)
trails=getSeeds(fields,computeVector)
# trails=getSeedsRnd(fields,50)
for (i, trail) in enumerate(trails)
# p = seeds[i]
followTrailBothWays!(trail,computeVector,fields,cells)
println("trail",i," length: ",length(trail.points))
end
end
@draw begin
darkmode ? background("black") : background("white")
for trail in trails
disp(trail)
end
if diagnosticMode #display seeds
sethue("red")
# for trail in trails
# circle(trail.origin, 2, :fill)
# end
for field in fields
dispField(field)
end
for point in diagnosticPoints
circle(point, 2, :stroke)
end
end
#display border
sethue(displayColor)
setline(3)
rect(-.99W/2,-.99H/2, .99W, .99H, :stroke)
Luxor.text(string(SEED), Point(-W/2-10,-H/2-10), halign=:left, valign=:bottom)
end W+50 H+50
# grid=range(-W/2,stop=W/2,length=100)
# quiver_plot(computeVector,fields,20,20)
end
main()