{"action":"created","issue":{"url":"https://api.github.com/repos/processing/p5.js/issues/875","labels_url":"https://api.github.com/repos/processing/p5.js/issues/875/labels{/name}","comments_url":"https://api.github.com/repos/processing/p5.js/issues/875/comments","events_url":"https://api.github.com/repos/processing/p5.js/issues/875/events","html_url":"https://github.com/processing/p5.js/pull/875","id":103737535,"number":875,"title":"Code improvements of the Perlin noise generator.","user":{"login":"mgold","id":1191970,"avatar_url":"https://avatars.githubusercontent.com/u/1191970?v=3","gravatar_id":"","url":"https://api.github.com/users/mgold","html_url":"https://github.com/mgold","followers_url":"https://api.github.com/users/mgold/followers","following_url":"https://api.github.com/users/mgold/following{/other_user}","gists_url":"https://api.github.com/users/mgold/gists{/gist_id}","starred_url":"https://api.github.com/users/mgold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgold/subscriptions","organizations_url":"https://api.github.com/users/mgold/orgs","repos_url":"https://api.github.com/users/mgold/repos","events_url":"https://api.github.com/users/mgold/events{/privacy}","received_events_url":"https://api.github.com/users/mgold/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-28T15:17:30Z","updated_at":"2015-08-28T20:30:30Z","closed_at":"2015-08-28T20:30:25Z","pull_request":{"url":"https://api.github.com/repos/processing/p5.js/pulls/875","html_url":"https://github.com/processing/p5.js/pull/875","diff_url":"https://github.com/processing/p5.js/pull/875.diff","patch_url":"https://github.com/processing/p5.js/pull/875.patch"},"body":"When the top of the file lists a chain of ports and adaptations three projects deep, there's bound to be some cruft that accumulates.\r\n\r\n* Replace the cosine lookup table with Math.cos. This is simpler and does not affect the output or performance.\r\n* Rename `noise_fsc` to `scaled_cosine`, and move it out of `noise` so it's not constantly redefined.\r\n* Remove comments referencing the toxi bug tracker, from which this code was derived\r\n* Remove a few comments asking if something was ok - I either fixed it or agree it's ok\r\n\r\nRegarding the removal of the cosine lookup table, this seems to have been ported from [toxi](https://toxiclibs.googlecode.com/svn/trunk/toxiclibs/src.core/toxi/math/noise/PerlinNoise.java) without much thought. Lookup tables aren't necessarily an optimization in JS, especially because of the memory overhead ([SO thread](http://stackoverflow.com/questions/9082040/optimization-using-a-lookup-table)). It also had a half-dozen constants, some of them poorly named. I was able to replace all of this without affecting either to output of the generator or performance on this test sketch:\r\n\r\n```js\r\nsideLen = 400;\r\nnoiseScale = 0.02;\r\n\r\nfunction setup() {\r\n  createCanvas(sideLen, sideLen)\r\n  noFill();\r\n  noLoop();\r\n  noiseSeed(42);\r\n}\r\n\r\n\r\nfunction draw() {\r\n  for (i = 0; i < sideLen; i++){\r\n    for (j = 0; j < sideLen; j++){\r\n      stroke(noise(i*noiseScale, j*noiseScale)*255);\r\n      point(i,j);\r\n    }\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/processing/p5.js/issues/comments/135881323","html_url":"https://github.com/processing/p5.js/pull/875#issuecomment-135881323","issue_url":"https://api.github.com/repos/processing/p5.js/issues/875","id":135881323,"user":{"login":"lmccart","id":191056,"avatar_url":"https://avatars.githubusercontent.com/u/191056?v=3","gravatar_id":"","url":"https://api.github.com/users/lmccart","html_url":"https://github.com/lmccart","followers_url":"https://api.github.com/users/lmccart/followers","following_url":"https://api.github.com/users/lmccart/following{/other_user}","gists_url":"https://api.github.com/users/lmccart/gists{/gist_id}","starred_url":"https://api.github.com/users/lmccart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmccart/subscriptions","organizations_url":"https://api.github.com/users/lmccart/orgs","repos_url":"https://api.github.com/users/lmccart/repos","events_url":"https://api.github.com/users/lmccart/events{/privacy}","received_events_url":"https://api.github.com/users/lmccart/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T20:30:30Z","updated_at":"2015-08-28T20:30:30Z","body":"beautiful, thank you!"}}