Euler golf #1

Merged
Simponic merged 5 commits from euler-golf into main 2023-02-24 17:02:20 -05:00
3 changed files with 20 additions and 4 deletions
Showing only changes of commit 078a5c38b4 - Show all commits

View File

@ -2,7 +2,7 @@ const DEFAULTS = {
max_rows: 80,
max_cols: 80,
min_gap: 40,
angle_multiplier: 0.0005,
angle_multiplier: 10e-4,
};
const CANVAS = document.getElementById("canvas");
@ -137,7 +137,7 @@ const handle_input = (state, dt) => {
const render = ({ width, height, ctx, rows, cols } = state) => {
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = "rgba(255, 255, 255, 0)";
ctx.fillStyle = "rgba(0, 0, 0, 0)";
ctx.fillRect(0, 0, width, height);
const grid_spec = calculate_grid_spec(state);
@ -156,11 +156,25 @@ const render = ({ width, height, ctx, rows, cols } = state) => {
complex_to_grid(cx.add(new cx(angle_re, angle_im), prev), rows, cols),
]);
ctx.line(
grid_to_canvas(complex_to_grid(curr, rows, cols), grid_spec),
grid_to_canvas(
complex_to_grid(
move(prev, curr, new cx(0, state.angle.im < 0 ? -1 : 1)),
rows,
cols
),
grid_spec
),
6,
"#aaa"
);
ctx.cartesian_grid(rows, cols, grid_spec, (x, y) => {
if (x == Math.floor(cols / 2) && y == Math.floor(rows / 2)) {
return {
radius: 7,
color: "#0000ff",
color: "#2f9c94",
};
} else {
return {

View File

@ -1,5 +1,6 @@
class JSONSet {
items = new Set();
constructor(initial) {
if (Array.isArray(initial)) {
initial.map((x) => this.apply_set_function("add", x));
@ -11,6 +12,7 @@ class JSONSet {
(f_name) => (this[f_name] = (x) => this.apply_set_function(f_name, x))
);
}
apply_set_function(f_name, x) {
return this.items[f_name](JSON.stringify(x));
}

View File

@ -1,4 +1,4 @@
const DEPTH = 21;
const DEPTH = 22;
const DIRECTION = {
0: new cx(0, 1),