Skip to content

Instantly share code, notes, and snippets.

View sbrl's full-sized avatar

Starbeamrainbowlabs sbrl

View GitHub Profile
@sbrl
sbrl / zoom.js
Last active December 20, 2015 20:30
An (almost perfect) zoom function that zooms into the mouse cursor pointer. Assumes that the canvas is full screen - adjusting for this shouldn't be too tough.
/*
* An (almost perfect) zoom function that zooms into the mouse cursor pointer.
* Assumes that the canvas is full screen - adjusting for this shouldn't be too
* tough.
*
* Attaches a zoom level update function to the mouse wheel event of
* the document. Calling this activates zooming via the mouse wheel.
*
* Assumes that it is part of a class of sorts.
*
@sbrl
sbrl / CSVWriter.cs
Last active January 30, 2018 23:10
[CSVWriter.cs] A simple, flexible CSV writer for C#. Modeled on the StreamWriter class. #microlibrary
/******************************************************************************
* CSVWriter
******************************************************************************
* Version 0.8
* Author: Starbeamrainbowlabs <feedback at starbeamrainbowlabs dot com>
*
* An easy way to generate CSV files. Please allow this comment to remain
* intact.
******************************************************************************
* Changelog
@sbrl
sbrl / renderer.js
Last active January 30, 2018 22:57
An ES6 template for a HTML5 canvas experiment. #template #html5-canvas
"use strict";
/**
* @template https://gist.github.com/sbrl/f8b584a383116b38da29
*/
class Renderer
{
constructor(canvas)
{
this.canvas = canvas;
@sbrl
sbrl / SmoothLine.js
Last active January 30, 2018 23:00
[SmoothLine.js] A class to aid the drawing of smooth lines. #es6 #module #microlibrary
"use strict";
/*******************************************************************************
**************************** ES6 Smooth Line Class ****************************
*******************************************************************************
* v0.1
*******************************************************************************
* A smooth line class built upon my earlier bezier curve and vector classes.
*
* Given a number of points (not all of which have to be specified at once),
* this class will add the appropriate lineTos to the given drawing context.
@sbrl
sbrl / Range.js
Last active January 30, 2018 22:58
[Range.js] A very simple range class. #es6 #module #microlibrary
/*******************************************************************************
******************************* ES6 Range Class *******************************
*******************************************************************************
* v0.2
*******************************************************************************
* A very simple range class.
*******************************************************************************
* https://gist.github.com/sbrl/a725e32f14a3e4b94810
* Author: Starbeamrainbowlabs <[email protected]>
*
@sbrl
sbrl / Shape.js
Last active January 30, 2018 22:59
Shape.js: A regular shape drawing class. #es6 #module #microlibrary
/*******************************************************************************
******************************* ES6 Shape Class *******************************
*******************************************************************************
* v0.1
*******************************************************************************
* A class that draws regular shapes of a given size with an arbitrary number of
* sides. Also supports rotation and translation (even after the shape has been
* created).
*
*
@sbrl
sbrl / Random.js
Last active January 30, 2018 22:57
A simple 3 formed bounded random number generator. #function #microlibrary #random
/**
* Bounded random number generator. Has 3 forms:
*
** Form 1 **
* @param {number} a The minimum value.
* @param {number} b The maximum value.
* @param {boolean} c Whether the resulting number should be a float. [optional]
* @return {number} A random number.
*
** Form 2 **
@sbrl
sbrl / AutoUpdateExampleHelper.cs
Last active June 19, 2025 08:54
A simple automatic update system, written in C# for a blog post.
using System;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Text;
using System.Security.Cryptography;
using System.Security.Permissions;
@sbrl
sbrl / Class.cpp
Last active March 2, 2016 10:28
A template C++ class.
#include <string>
#include <iostream>
#include "ClassName.h"
using namespace std;
ClassName::ClassName()
{
}
@sbrl
sbrl / ImageGenerator.cs
Last active January 30, 2018 23:09
An image generator that uses 3 functions to generate a PPM image. Useful for quick math image tests. #template
using System;
using System.IO;
public class Program
{
static string filename = "image.ppm";
static int width = 1024;
static int height = 1024;