float rand(float n){return fract(sin(n) * 43758.5453123);}
float noise(float p){
float fl = floor(p);
float fc = fract(p);
return mix(rand(fl), rand(fl + 1.0), fc);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function StringProcessor(value) { | |
| return { | |
| value: value, | |
| reverse: function () { | |
| return StringProcessor(this.value.split('').reverse('').join('')); | |
| }, | |
| allCaps: function () { | |
| return StringProcessor(this.value.toUpperCase()); | |
| }, | |
| spaceBetweenChars: function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from "react"; | |
| function useForm({ initialValue, name }) { | |
| const [value, setValue] = useState(initialValue); | |
| return { | |
| [`${name}`]: { | |
| value, | |
| onChange: (e) => setValue(e.target.value) | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vec3 palette(float t) { | |
| vec3 a = vec3(0.938, 0.328, 0.718); | |
| vec3 b = vec3(0.659, 0.438, 0.328); | |
| vec3 c = vec3(0.388, 0.388, 0.296); | |
| vec3 d = vec3(2.538, 2.478, 0.168); | |
| return a + b * cos(6.28318*(c*t*d)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // deeply nested object about a person that we are going to flatten | |
| const person = { | |
| name: 'John', | |
| age: 30, | |
| address: { | |
| street: '123 Main St', | |
| city: 'New York', | |
| state: 'NY', | |
| zip: 10001, | |
| country: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function shuffle(elements) { | |
| allElements = (function(){ | |
| let returnArray = [] | |
| let lengthOf = elements.length | |
| while (lengthOf--) { | |
| returnArray[returnArray.length] = elements[lengthOf] | |
| } |