Skip to content

Commit 07b23e6

Browse files
Merge pull request #4 from AEFGP/1.12
Compiteratior 1.12.1
2 parents 1cc73bc + 3463ab6 commit 07b23e6

File tree

2 files changed

+64
-12
lines changed

2 files changed

+64
-12
lines changed

compiterator/readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
[Visit Wiki](https://github.com/AEFGP/AEFGP.github.io/wiki/Compiterator:-The-Chaos-Game)
44

5-
Compiterator Version 1.12
5+
Compiterator Version 1.12.1
6+
Open index.HTML in Chromium based browsers, this script seems to have really bad performance on other browsers.
7+
8+
The name 'Compiterator' (for "Complex Iterator") is based on the fact the program uses iterations of complex functions. It is meant to be a geometric live interactive way to generate fractals, it is in some sense a mathematical toy.
69

710
## Controls
811

@@ -29,6 +32,7 @@ Compiterator Version 1.12
2932
* `V`: Randomise render vectors
3033
* `O`: Randomise iteration options
3134
* `P`: Randomise attractor nodes / points
35+
* `I`: Randomise number of layers and numbers of points
3236
* `shift`: Toggle toggling of N and M to their broken functions in prior versions
3337
* `~`: Cycle mouse-selector mode
3438
* `W`: Move mouse-selector point up
@@ -116,6 +120,8 @@ The position of all the attractor nodes can be randomly set using `P`
116120
The other settings pertaining to the shape of the fractal can be randomly set using `O`
117121
Colour settings can be randomly set using `C`
118122
The location, size and rotation of the render can randomly set using `V`
123+
To randomise the actual number of layers and points for each layer use `I`
124+
The iteration mode is not randomised by any of these settings.
119125

120126
## Background Information
121127
The chaos game involves choosing points in a probabilistic algorithm and iterating the movement by some other algorithm to the chosen point of a tracked point.

compiterator/sketch.js

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function setup() {
3434
G.ITCAP = 20000 //Number of iterations until regen
3535
G.NORENS= 3 //Number of points that are not rendered after each regen
3636

37+
G.IRML = 4 //Max number of layers in the I randomiser
38+
G.IRMN = 6 //Max number of nodes in any layer in the I randomiser
39+
G.IRMIN = 1 //Minimum number of excess (>1) nodes across all layers in the I randomiser
3740

3841
G.RADI = 10 //Size of attractor nodes
3942
G.DR = 0.25 //Size of iterated point stamps
@@ -87,16 +90,55 @@ function windowResized() {
8790
G.y = height/2
8891
}
8992

93+
function iran(){
94+
enodes=G.IRMIN
95+
layers=floor(random(G.IRML)+1)
96+
let attrs=[]
97+
for (let i=layers-1;i>=0;i--){
98+
let _set=[]
99+
let nodes=floor(random(G.IRMIN,G.IRMN)+1)
100+
if (nodes>1&&enodes>0){
101+
enodes-nodes+1
102+
if (enodes<0){
103+
enodes=0
104+
}
105+
}
106+
if (i==0){
107+
nodes+=enodes
108+
}
109+
for (let j=0;j<nodes;j++){
110+
let node=p5.Vector.random2D()
111+
node.setMag(random(G.RSPAN))
112+
_set.push(node)
113+
}
114+
attrs.push(_set)
115+
}
116+
G.attrs=attrs
117+
if (G.seti>=G.attrs.length){
118+
G.seti=G.attrs.length-1
119+
G.set=G.attrs[G.seti]
120+
}
121+
if (G.addr>=G.attrs.length){
122+
G.addr=G.attrs.length-1
123+
}
124+
if (G.excn>=G.set.length+2){
125+
G.excn=G.set.length+1
126+
}
127+
if (G.excl>=G.attrs.length+2){
128+
G.excl=G.attrs.length+1
129+
}
130+
}
131+
90132
function oran(){
91133
//Randomise options
92134
G.t=p5.Vector.random2D()
93135
G.t.setMag(random(G.RSPAN))
94136
G.shift=round(random())
95-
G.errl=round(random())
96-
G.errn=round(random())
97-
G.excn=floor(random(G.set.length))
98-
G.excl=floor(random(G.attrs.length))
99-
G.mode=floor(random(G.MMODE))
137+
G.errl=round(random(1+(1-G.shift)*G.attrs.length))
138+
G.errn=round(random(1+(1-G.shift)*G.set.length))
139+
G.excn=floor(random(G.set.length+2))
140+
G.excl=floor(random(G.attrs.length+2))
141+
//G.mode=floor(random(G.MMODE))
100142
}
101143

102144
function pran(){
@@ -215,8 +257,8 @@ function itMP(){
215257
}
216258

217259
function itPF(){
218-
n=G.set.length
219260
c=G.polyCs[G.seti]
261+
n=c.length
220262
zp=zPows(n)
221263
z=createVector(0,0)
222264
for (i=0;i<n;i++){
@@ -225,9 +267,9 @@ function itPF(){
225267
}
226268

227269
function itPN(){
228-
n=G.set.length
229270
c=G.polyCs[G.seti]
230271
d=G.dpolyCs[G.seti]
272+
n=c.length
231273
zp=zPows(n)
232274
pc=createVector(0,0)
233275
for (i=0;i<n;i++){
@@ -243,8 +285,8 @@ function itPN(){
243285
}
244286

245287
function itPFB(){
246-
n=G.set.length
247288
c=G.polyCs[G.seti]
289+
n=c.length
248290
zp=zPowsB(n)
249291
z=createVector(0,0)
250292
for (i=0;i<n;i++){
@@ -253,9 +295,9 @@ function itPFB(){
253295
}
254296

255297
function itPNB(){
256-
n=G.set.length
257298
c=G.polyCs[G.seti]
258299
d=G.dpolyCs[G.seti]
300+
n=c.length
259301
zp=zPowsB(n)
260302
pc=createVector(0,0)
261303
for (i=0;i<n;i++){
@@ -271,8 +313,8 @@ function itPNB(){
271313
}
272314

273315
function itPFBB(){
274-
n=G.set.length
275316
c=G.polyCs[G.seti]
317+
n=c.length
276318
zp=zPowsBB(n)
277319
cx=c[0].x
278320
cy=c[0].y
@@ -459,7 +501,7 @@ function dPolyC(pc){
459501
function zPows(n){
460502
z=G.pnt // cmul(G.t,G.pnt)
461503
zp=[G.t]
462-
for (i=1;i<n;i++){
504+
for (let i=1;i<n;i++){
463505
zp.push(cmul(zp[i-1],z))
464506
}
465507
return zp
@@ -940,6 +982,10 @@ function keyPressed() {
940982
//h
941983
shuffleNodes()
942984
}
985+
if (keyCode==73){
986+
//i
987+
iran()
988+
}
943989
if (keyCode==75){
944990
//k
945991
shuffleLayers()

0 commit comments

Comments
 (0)