mirror of
https://github.com/bspeice/speice.io
synced 2024-12-23 00:58:09 -05:00
13 lines
364 B
TypeScript
13 lines
364 B
TypeScript
|
// hidden-start
|
||
|
import { Variation } from './variations'
|
||
|
// hidden-end
|
||
|
export const julia: Variation = (x, y) => {
|
||
|
const r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
||
|
const theta = Math.atan2(x, y);
|
||
|
const omega = Math.random() > 0.5 ? 0 : Math.PI;
|
||
|
|
||
|
return [
|
||
|
r * Math.cos(theta / 2 + omega),
|
||
|
r * Math.sin(theta / 2 + omega)
|
||
|
]
|
||
|
}
|