add p5js matheart

This commit is contained in:
horhik 2022-04-18 19:34:51 +03:00
parent d4509ca7d8
commit f9507f9fc2
6 changed files with 3940 additions and 0 deletions

23
matheart/.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

20
matheart/index.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0px;
margin: 0px;
}
</style>
</head>
<body>
<button class='reset' >Next</button>
<script src="p5.min.js"></script>
<script src="main.js"></script>
</body>
</html>

81
matheart/main.js Normal file
View file

@ -0,0 +1,81 @@
let resetButton = document.querySelector('.reset');
let play =true
let wiw
let wih
function setup() {
wiw = innerWidth
wih = innerHeight - 200
createCanvas(wiw, wih);
}
let count = 360;
let pi = Math.PI
let step = 1;
let ang = 0
let nums = []
let multiplier = 2;
let centerx = window.innerWidth/2;
let centery = (window.innerHeight - 200)/2
let R = centery/1.2;
let length = pi * R
for (let i = 1; i <= count; i++){
ang += pi / (count / multiplier / 2)
let numx = centerx + (Math.sin(ang) * R)
let numy = centery + (Math.cos(ang) * R)
let num = i;
nums.push({num, x: numx, y:numy})
}
resetButton.addEventListener('click', () => {
count += 20 ;
pi = Math.PI
step = 1;
ang = 0
nums = []
multiplier += 1;
centerx = window.innerWidth/2;
centery = (window.innerHeight - 200)/2
R = centery/1.2;
length = pi * R
for (let i = 1; i <= count; i++){
ang += pi / (count / multiplier / 2)
let numx = centerx + (Math.sin(ang) * R)
let numy = centery + (Math.cos(ang) * R)
let num = i;
nums.push({num, x: numx, y:numy})
}
console.log(nums.length)
})
function draw() {
if (play) {
background('#eee')
fill('#eded33')
ellipse(centerx, centery, R*2);
fill('#35ff3d')
nums.forEach(num => {
ellipse(num.x,num.y, 5);
let next = num.num * multiplier > count ? num.num * multiplier - (~~(num.num * multiplier / count) * count) : num.num * multiplier;
try{
let n = next - 1 < 0 ? 0 : next -1;
let nx = nums[n].x
let ny = nums[n].y
let x = num.x
let y = num.y
line (nx, ny, x, y)
}
catch (e) {
console.error(e)
play = false
console.log(next)
console.log(nums.length)
}
});
}
}

3
matheart/p5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

56
matheart/p5.min.js.save Normal file
View file

@ -0,0 +1,56 @@
:/*! p5.js v1.0.0 February 29, 2020 */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof
!define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof
!self?self:this).p5=e()}}(function(){return function o(a,s,l){function u(t,e){if(!s[t]){if(!a[t]){var r="function"==typeof require&&require;if(!e&&r)return
!r(t,!0);if(h)return h(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var
!n=s[t]={exports:{}};a[t][0].call(n.exports,function(e){return u(a[t][1][e]||e)},n,n.exports,o,a,s,l)}return s[t].exports}for(var h="function"==typeof
!require&&require,e=0;e<l.length;e++)u(l[e]);return u}({1:[function(e,t,r){t.exports=function(e){if(Array.isArray(e))return
!e}},{}],2:[function(e,t,r){t.exports=function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return
!r}}},{}],3:[function(e,t,r){t.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return
!e}},{}],4:[function(e,t,r){t.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},{}],5:[function(e,t,r){function
!i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in
!i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}t.exports=function(e,t,r){return
!t&&i(e.prototype,t),r&&i(e,r),e}},{}],6:[function(e,t,r){t.exports=function(e,t,r){return t in
!e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},{}],7:[function(e,t,r){function i(e){return
!t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}t.exports=i},{}],8:[function(e,t,r){var
!i=e("./setPrototypeOf");t.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a
!function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}},{"./setPrototypeOf":15}],9:[function(e,t,r){t.exports=function(e){if(Symbol.iterator
!in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},{}],10:[function(e,t,r){t.exports=function(e,t){var
!r=[],i=!0,n=!1,o=void 0;try{for(var
!a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);i=!0);}catch(e){n=!0,o=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw
!o}}return r}},{}],11:[function(e,t,r){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable
!instance")}},{}],12:[function(e,t,r){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},{}],13:[function(e,t,r){var
!n=e("./defineProperty");t.exports=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},i=Object.keys(r);"function"==typeof
!Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(r).filter(function(e){return
!Object.getOwnPropertyDescriptor(r,e).enumerable}))),i.forEach(function(e){n(t,e,r[e])})}return t}},{"./defineProperty":6}],14:[function(e,t,r){var
!i=e("../helpers/typeof"),n=e("./assertThisInitialized");t.exports=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof
!t?n(e):t}},{"../helpers/typeof":18,"./assertThisInitialized":3}],15:[function(e,r,t){function i(e,t){return r.exports=i=Object.setPrototypeOf||function(e,t){return
!e.__proto__=t,e},i(e,t)}r.exports=i},{}],16:[function(e,t,r){var
!i=e("./arrayWithHoles"),n=e("./iterableToArrayLimit"),o=e("./nonIterableRest");t.exports=function(e,t){return
!i(e)||n(e,t)||o()}},{"./arrayWithHoles":1,"./iterableToArrayLimit":10,"./nonIterableRest":11}],17:[function(e,t,r){var
!i=e("./arrayWithoutHoles"),n=e("./iterableToArray"),o=e("./nonIterableSpread");t.exports=function(e){return
!i(e)||n(e)||o()}},{"./arrayWithoutHoles":2,"./iterableToArray":9,"./nonIterableSpread":12}],18:[function(e,t,r){function i(e){return(i="function"==typeof
!Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof
!Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e){return"function"==typeof
!Symbol&&"symbol"===i(Symbol.iterator)?t.exports=n=function(e){return i(e)}:t.exports=n=function(e){return e&&"function"==typeof
!Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":i(e)},n(e)}t.exports=n},{}],19:[function(e,t,r){"use strict";r.byteLength=function(e){var
!t=c(e),r=t[0],i=t[1];return 3*(r+i)/4-i},r.toByteArray=function(e){var t,r,i=c(e),n=i[0],o=i[1],a=new h(function(e,t){return
!3*(e+t)/4-t}(n,o)),s=0,l=0<o?n-4:n;for(r=0;r<l;r+=4)t=u[e.charCodeAt(r)]<<18|u[e.charCodeAt(r+1)]<<12|u[e.charCodeAt(r+2)]<<6|u[e.charCodeAt(r+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===o&&(t=u[e.charCodeAt(r)]<<2|u[e.charCodeAt(r+1)]>>4,a[s++]=255&t);1===o&&(t=u[e.charCodeAt(r)]<<10|u[e.charCodeAt(r+1)]<<4|u[e.charCodeAt(r+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return
!a},r.fromByteArray=function(e){for(var
!t,r=e.length,i=r%3,n=[],o=0,a=r-i;o<a;o+=16383)n.push(l(e,o,a<o+16383?a:o+16383));1==i?(t=e[r-1],n.push(s[t>>2]+s[t<<4&63]+"==")):2==i&&(t=(e[r-2]<<8)+e[r-1],n.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return
!n.join("")};for(var s=[],u=[],h="undefined"!=typeof
!Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=i.length;n<o;++n)s[n]=i[n],u[i.charCodeAt(n)]=n;function
!c(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function
!l(e,t,r){for(var i,n,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(s[(n=i)>>18&63]+s[n>>12&63]+s[n>>6&63]+s[63&n]);return
!o.join("")}u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63},{}],20:[function(e,t,r){},{}],21:[function(N,e,F){(function(c){"use strict";var
!i=N("base64-js"),o=N("ieee754"),e="function"==typeof Symbol&&"function"==typeof
!Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;F.Buffer=c,F.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},F.INSPECT_MAX_BYTES=50;var
!r=2147483647;function a(e){if(r<e)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return
!Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"!=typeof e)return n(e,t,r);if("string"==typeof t)throw new TypeError('The "string" argument must
!be of type string. Received type number');return l(e)}function n(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof
!t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|f(e,t),i=a(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return
!i}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like
!Object. Received type "+typeof e);if(A(e,ArrayBuffer)||e&&A(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is
!outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===t&&void 0===r?new
!Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r);return Object.setPrototypeOf(i,c.prototype),i}(e,t,r);if("number"==typeof e)throw new

3757
matheart/p5.min.js.save.1 Normal file

File diff suppressed because one or more lines are too long