-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpie.groovy
More file actions
69 lines (57 loc) · 1.39 KB
/
Copy pathpie.groovy
File metadata and controls
69 lines (57 loc) · 1.39 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
HEIGHT=30.0; WIDTH = 60.0
def radius = 15
def xOffset = 0
def yOffset = 0
list = args[0].split(',').toList()*.toInteger()
sum = list.sum()
list = list.collect{it/sum*2*Math.PI}
println "LIST LIST LIST $list"
for(int i = HEIGHT; i > 0; i--) {
for(int j = 0 ;j < WIDTH*2; j++) {
adj = ((j/2)-xOffset-WIDTH/2)
opp = (i-yOffset-HEIGHT/2)
A2 = adj*adj
B2 = opp*opp
if(A2+B2 < radius*radius && A2+B2>= 20) printSlice(adj,opp,list) else print ' '
}
println(' ')
}
def printSlice(def i, def j, def list) {
// println("$i $j")
def pi = Math.PI
def quad = 0
def angRef = 1
if( i<=0 && j >= 0 ) {
quad = pi/2
angRef=-1
} else if( i<=0 && j <=0 ) {
quad = pi
angRef=1
} else if( i>=0 && j<=0 ) {
angRef = -1
quad = 3/2*pi
}
double rad = Math.atan(Math.pow(Math.abs(j+0.001)/Math.abs(i+0.001),angRef))
index = getIndex(list, rad+quad)
// print index
if(index % 2 == 1) print('😃') else { print '🦄' }
// plotMe = (rad)+quad < 3/2*pi + pi/3
// print "|"
// print rad.round(1)
// if(plotMe) print(',') else { print '•' }
//◦•
// print '••'
}
def getIndex(def list, def angle) {
// println ""
// println "$angle ANGEL ANGLE NAGLE NAGKE"
// println ""
for(int i=0; i < list.size(); i++ ) {
angle = angle - list[i]
// println "$i $list"
if(angle <= 0 ) {
return i;
}
}
return list.size()
}