Here is my little implementation of Knn boundary visualizer. I did this just to get a feel of Processing.js.
- The number of neighbours k is adjustable using --/++ buttons.
- Clicking anywhere in the canvas will produce a new point.
- The class to which the produced points belong can be selected with the red/blue rectangles at the top.
I found the process of composing the code to be pleasant. This is perhaps partially because of the similarity to Java which I am already familiar. One thing worth mentioning though is that, TBOMK, without an external library, Processing.js does not support any UI component (i.e., button, combo box). Everything above was achieved by drawing, which is a bit painful if you have many buttons; as you need to manually specify the coordinates to draw. This will pose an even more serious problem if the effect of a text field is desired. The only thing provided is the facility to capture keys. Then, you are on your own for the rest. Apparently it takes a lot of patience to write code to simulate the blinking cursor of a text field. Optimistically I am pretty sure someday there will be a library for UI components in Processing.js.
Download: Source code