Skip to content

Commit

Permalink
extracts range function to utils file.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianoratamero committed Feb 1, 2019
1 parent 1a5d3b8 commit 56ceff2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
23 changes: 23 additions & 0 deletions p5js/utils.js
@@ -0,0 +1,23 @@

function range(start, stop, step) {
if (typeof stop == 'undefined') {
// one param defined
stop = start;
start = 0;
}

if (typeof step == 'undefined') {
step = 1;
}

if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
return [];
}

var result = [];
for (var i = start; step > 0 ? i < stop : i > stop; i += step) {
result.push(i);
}

return result;
};
1 change: 1 addition & 0 deletions s_0003/index.html
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>s_0003 - para(chill)axing</title>
<style> body {padding: 0; margin: 0; overflow: hidden;} </style>
<script src="../p5js/utils.js"></script>
<script src="../p5js/p5.min.js"></script>
<script src="../p5js/addons/p5.dom.min.js"></script>
<script src="../p5js/1000.js"></script>
Expand Down
23 changes: 0 additions & 23 deletions s_0003/sketch.js
Expand Up @@ -10,29 +10,6 @@ var HEIGHT = window.innerHeight;
var FRAME_RATE = 60;
var DURATION = getRandomInt(15, 30);

function range(start, stop, step) {
if (typeof stop == 'undefined') {
// one param defined
stop = start;
start = 0;
}

if (typeof step == 'undefined') {
step = 1;
}

if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
return [];
}

var result = [];
for (var i = start; step > 0 ? i < stop : i > stop; i += step) {
result.push(i);
}

return result;
};

function setup() {
BG_COLOR = color(27, 27, 27, 200)
COLOR_1 = color(COLOR_PALETTE[0])
Expand Down

0 comments on commit 56ceff2

Please sign in to comment.