Skip to content

Instantly share code, notes, and snippets.

// Canvas setup
const image = new Image();
image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAIAASURBVHja7L13uGZXdR6+yt6nfe32e6c3jQqjggqIjui44AIO2BhsB9e4h8SxY/8c24kdl+DYsXEct8SVZrDBIIrpICQhCfU2Gmn63F6+fsree63fH9+9g4pRQxiIs5957jNz595zzrf3e/Ze611rvQtVFf4lDlUVAEBEAFIFBQiqAAoA+MU5QQBFQB397aFXAEVAQITRryGiIiLA6M/mz4AiIJ79xr+Ygf/SgCUiAKCAXhVVCZFRkRCAnoKrqwdRARBVAAJEQWJC/mp/6n/+8S8CWAqgqiqKAABK/PCFHji/tNZeGxb9wi2t9ta6vXavPyj9QG1ZBe/8aJZG25IxJrIUMaVpNplFs007M9lqpXa8nk2OtVoxPxShAUQDECggIhL+C9m7vq6BtfnkAqMDaPNEGv0TtsAECEwPWevV3nB+pXPL6dUTSxuHT66eWusud6rVzqDnisoDCAIYAAvIoAoI8EUwKICOcLp5QwiADlAtazMxU43adDPaPTVxzq7JfTONQ7u37Z5uTDdrD769hKAAQET4kOvC6ABVANz8IPD1fIB+/QFLzy6AymjVHSiDEqiKCBinSOojZsDNBa28u+f0yu3HFm48fOaOU50H5gfL3WGpHkSBI4giMBasZUMEhEQAhICqAuA2kbR157PWEhJs4ZglqIpI8BoEXAUuh6AAEFmarCUHttcP7Rq78tzdl+ydPXfHVD2Jtj6JBq8KgExIgiCoDIqKqhgQ+OvaMvv6AxZAAEUAUgQBQABSpwoCLALWwOhdF5V7Tq9ce++Za+44fuexpaPrebuXg0kgjiGJ2d
@ryannining
ryannining / tes1copt.html
Created November 20, 2019 13:22
testing for true constant jerk linear motion
<head>
</head>
<html>
<body>
<table cellpadding=5>
<tr><td width=auto>
<table style="font-size:9pt;font-family:arial" id=t0 width=100%>
<tr><td>Prev acc</td><td><input id=iprevac type=input value=0 size=2>-1 0 1</td></tr>
<tr><td>Next acc</td><td><input id=inextac type=input value=0 size=2>-1 0 1</td></tr>
@ryannining
ryannining / carving.html
Created March 26, 2019 16:36
Implementation of V Carving on javascript
<body>
<canvas id=mycanv width=800 height=600></canvas>
<textarea id=gcode cols=200 rows=100>
</textarea>
<script>
function $(id) {
return document.getElementById(id);
}
sqrt=Math.sqrt;
sqr=function(x){return x*x;}
@ryannining
ryannining / processoffset.html
Created January 12, 2019 01:34
try convert processoffset.py to javascript
<body>
<canvas id=canvas1 width=70 height=70>
</canvas>
<script>
/*
Copyright (C) 2008 Aaron Spike, aaron@ekips.org
Copyright (C) 2013 Sebastian Wüst, sebi@timewaster.de
Copyright (C) 2016 Alexander Pruss
This program is free software; you can redistribute it and/or modify
@ryannining
ryannining / calculation.ino
Last active February 15, 2018 15:23
Measure ramping calculation (arduino)
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#define ramplen(oo,v0,v1,a ,stepmm) oo=(v1*v1-v0*v0)* stepmm/(2*a);
#define stepmm 50
uint16_t int_inv_sqrt(uint16_t a) {
/// 16bits inverse (much faster than doing a full 32bits inverse)
/// the 0xFFFFU instead of 0x10000UL hack allows using 16bits and 8bits