Better HN
topnewbestaskshowjobs
Log inSign up

davidim

50 karma · joined Dec 30, 2018 (7y ago) · 9 submissions

High-school student interested in computer science and neuroscience.

dmaydan2@gmail.com

Submissions

comment 7y ago · link · parent

What sort of drawing are you thinking? Dragging the mouse around on the screen or navigating with the arrows?

comment 7y ago · link · parent

Thanks a lot for the bug report! You're right - I was forgetting to clear the canvas on render. So I added ctx.clearRect(0, 0, WIDTH, HEIGHT); to the start of the render method.

comment 7y ago · link · parent

Recursive division may be elegant, but it seems that may also have its disadvantages.

comment 7y ago · link · parent

Thanks so much for the compliment. This is probably a bi-product of the maze generation algorithm I used. Essentially, at every step, the algorithm bisects the maze horizontally or vertically - then, it chooses a random cell along this bisection to leave open (that way the 2 resulting regions are still connected). Then, the same algorithm is performed on the 2 new regions. Recursion continues until it no longer makes sense to continue bisecting.

Wikipedia has an article on maze generation that explains the algorithm - https://en.m.wikipedia.org/wiki/Maze_generation_algorithm

comment 7y ago · link · parent

Thanks for checking it out! I am wondering how big is the number you are putting in? If the number is really high, it's probably causing a stack overflow. I would limit the size, but each browser has its own recursion limits so that would be quite a pain. In retrospect, I probably should not have used a recursive algorithm for this task :).

6.

Show HN: Solve and generate mazes with JavaScript on HTML Canvas(github.com ↗)

96 points · by davidim · 7y ago · 30 comments

comment 7y ago · link · parent

Thanks for checking it out. I like the idea of making the hand move between seconds - I was actually thinking about doing something like that when originally making the clock - then I got too lazy and told myself that real clocks don’t do that so I don’t have to worry about implementing it :). Now it’s too late! I haven’t looked at the code for 2 days, and there are no comments! :)

I’m not sure what you mean with that last suggestion - I’m pretty sure you’re joking, but I still have no idea what you’re talking about.

8.

Show HN: An analog clock on html canvas(dmaydan.github.io ↗)

6 points · by davidim · 7y ago · 3 comments