diff --git a/index.html b/index.html index 281634b..8e9dce4 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,20 @@ - p5.js liberary + p5.js liberay -

p5.js liberary by me

-
- +
\ No newline at end of file diff --git a/liberay.html b/liberay.html new file mode 100644 index 0000000..2f4dac1 --- /dev/null +++ b/liberay.html @@ -0,0 +1,46 @@ + + + + + + Document + + + + + + diff --git a/loader.html b/loader.html index 7ca46ba..cc6fada 100644 --- a/loader.html +++ b/loader.html @@ -7,11 +7,25 @@ + \ No newline at end of file diff --git a/sketches/2images.js b/sketches/2images.js index dfe0f94..e75c3be 100644 --- a/sketches/2images.js +++ b/sketches/2images.js @@ -1,6 +1,6 @@ function preload() { - img1 = loadImage('assets/wallpaper/dear.png'); - img2 = loadImage('assets/wallpaper/elphantJap.jpg'); + img1 = loadImage('../assets/wallpaper/dear.png'); + img2 = loadImage('../assets/wallpaper/elphantJap.jpg'); } function setup() { diff --git a/sketches/AbstractAlgorithm.js b/sketches/AbstractAlgorithm.js index 3c5b5c4..8bff0c6 100644 --- a/sketches/AbstractAlgorithm.js +++ b/sketches/AbstractAlgorithm.js @@ -1,6 +1,6 @@ const circleMaxSize = 30; const circleMinSize = 5; -const maxcircleAmount = 1000; +let maxcircleAmount = 2; const circleCords = []; let maxTries = 100; let area = []; @@ -8,7 +8,10 @@ let moveToNextSpotVariable= []; let x, y, diameter, circleCordsConst, isCircleCollided, tries, insideTry = 0; function setup() { - createCanvas(500, 500); + createCanvas(windowWidth, windowHeight); + maxcircleAmount = maxTries = floor(width); + console.log(maxTries); + console.log(maxcircleAmount); background(255, 255, 255); //randomSeed(99); diff --git a/sketches/Cubes.js b/sketches/Cubes.js index 9c6de53..4f76969 100644 --- a/sketches/Cubes.js +++ b/sketches/Cubes.js @@ -4,7 +4,7 @@ var randomY = 0 var mouseIndex = 0 function setup() { - createCanvas(500, 500); + createCanvas(windowWidth, windowHeight); background(255, 255, 255) noFill(); for (i = 0; i < 30; i++) { diff --git a/sketches/L-System.js b/sketches/L-System.js new file mode 100644 index 0000000..453bcc7 --- /dev/null +++ b/sketches/L-System.js @@ -0,0 +1,184 @@ +let angle = 3.141592653589*1.5; +let angleDecrement = 1; +let stepSize = 10; +let widthIncrement = 1; +let currentWidth = 1; +let currentPosition = [501 / 2, 500]; +let fractalst = "FF+[+F-F-F]-[-F+F+F]"; +let stackList = []; +let lineLenghtScaleFactor = 1.5; +let swapPlusMinusState = false; +let turningAngleIncrement = 0.1; + +//FF+[+F-F-F]-[-F+F+F] fork + +function setup() { + console.log("setup"); + createCanvas(windowWidth, windowHeight); + background(255, 255, 255) + noFill(); + stroke(0, 0, 0); + strokeWeight(1); + currentPosition = [width / 2, height]; + generateFractal(); +} + +function generateFractal() { + for (let i = 0; i < fractalst.length; i++) { + let c = fractalst.charAt(i); + switch (c) { + case "F": + forward(); + break; + case "+": + plus(); + break; + case "-": + minus(); + break; + case "f": + forwardNoLine(); + break; + case "|": + reverseDirection(); + break; + case "#": + lineWidthIncrement(); + break; + case "!": + lineWidthDecrement(); + break; + case "[": + pushStack(i); + break; + case "]": + popStack(i); + break; + case ">": + lineWidthMultiply(); + break; + case "<": + lineWidthDivide(); + break; + case "&": + swapPlusMinus(); + break; + case "@": + drawDot(); + break; + case ")": + angleIncrement(); + break; + case "(": + angleDecrement(); + break; + default: + console.log("unrecognized character",c); + break; + } + } +} + +function minus() { + if (swapPlusMinusState) { + angle += angleDecrement; + return + } + angle -= angleDecrement; +} + +function plus() { + if (swapPlusMinusState) { + angle -= angleDecrement; + return + } + angle += angleDecrement; +} + +function lineWidthIncrement(){ + currentWidth + widthIncrement; + strokeWeight(currentWidth); +} + +function lineWidthDecrement(){ + currentWidth - widthIncrement; + strokeWeight(currentWidth); +} + +function forward() { + let x = currentPosition[0] + cos(angle) * stepSize; + let y = currentPosition[1] + sin(angle) * stepSize; + line(currentPosition[0], currentPosition[1], x, y); + currentPosition = [x, y]; +} + +function forwardNoLine(){ + let x = currentPosition[0] + cos(angle) * stepSize; + let y = currentPosition[1] + sin(angle) * stepSize; + currentPosition = [x, y]; +} + +function backward() { + let x = currentPosition[0] - cos(angle) * stepSize; + let y = currentPosition[1] - sin(angle) * stepSize; + line(currentPosition[0], currentPosition[1], x, y); + currentPosition = [x, y]; +} + +function reverseDirection(){ + angle - 3.14159265358979323; +} + +function pushStack(i){ + console.log(angle) + stackList.push([i,currentPosition[0],currentPosition[1],angle,currentWidth]); +} + +function popStack(i){ + stackToPop = stackList.length - 1; + console.log(stackList[stackToPop]) + currentPosition = [stackList[stackToPop][1],stackList[stackToPop][2]]; + angle = stackList[stackToPop][3]; + strokeWeight[stackList[stackToPop][4]] +} + +function lineWidthMultiply(){ + currentWidth * lineLenghtScaleFactor; + strokeWeight(currentWidth); +} + +function lineWidthDivide(){ + currentWidth / lineLenghtScaleFactor; + strokeWeight(currentWidth); +} + +function swapPlusMinus(){ + if (swapPlusMinusState) { + swapPlusMinusState = false; + return + } + swapPlusMinusState = true; +} + +function drawDot() { + let x = currentPosition[0]; + let y = currentPosition[1]; + strokeWeight(currentWidth); + point(x, y); +} + +function angleIncrement() { + angle += turningAngleIncrement; +} + +function angleDecrement() { + angle -= turningAngleIncrement; +} + +function draw() { + +} + +function mousePressed() { + +} \ No newline at end of file diff --git a/sketches/calmCircles.js b/sketches/calmCircles.js index 87698f5..a2fded0 100644 --- a/sketches/calmCircles.js +++ b/sketches/calmCircles.js @@ -1,5 +1,5 @@ function setup() { - createCanvas(500, 500); + createCanvas(windowWidth, windowHeight); } function draw() { @@ -7,7 +7,7 @@ function draw() { for (let i = 0; i <= width * sqrt(2); i += 10) { stroke(random(255), random(255), random(255)) - strokeWeight(2) + strokeWeight(width / 70) noFill() circle(width / 2 + random(0, 30), height / 2 + random(0, 30), i) diff --git a/sketches/labyrinth.js b/sketches/labyrinth.js index 1f56602..798edb2 100644 --- a/sketches/labyrinth.js +++ b/sketches/labyrinth.js @@ -14,7 +14,7 @@ var wallGrid = []; var rows, cols; function setup() { - createCanvas(500, 500); + createCanvas(windowWidth, windowHeight); rows = ceil(height / gridSize); cols = ceil(width / gridSize); diff --git a/sketches/sketchList.txt b/sketches/sketchList.txt index 74e96d3..7429f71 100644 --- a/sketches/sketchList.txt +++ b/sketches/sketchList.txt @@ -1,2 +1,2 @@ -2images.js, calmCircles.js, Cubes.js, image.js, imageNoice.js, labyrinth.js, -RecursiveCubes.js +2images.js, AbstractAlgorithm.js, calmCircles.js, Cubes.js, image.js, +imageNoice.js, labyrinth.js, L-System.js