Skip to content

Instantly share code, notes, and snippets.

View Chadtech's full-sized avatar

Chadtech Chadtech

  • SuperFocus.ai
  • Pennsylvania
View GitHub Profile
@Chadtech
Chadtech / Good_Flood_Fill_in_coffeescript.coffee
Last active August 29, 2015 14:06
This a flood fill on the canvas element that works fairly well written in coffeescript
floodFill = (canvas, context, colorToChangeTo, xPosition, yPosition) ->
# The argument context is the context of the argument canvas.
# ColorToChangeTo is a three element array of color values 0<=.<255
# xPosition and yPosition are the coordates that the fill is initiated
# ( where the user clicks in my case )
###
In my code, colors are given as (R,G,B), but the pixels in the canvas have an alpha channel, so I need
to add an alpha value of 255. In my code I found that if floodFill is used quickly in succession,
colorToChangeTo, could retain the pushed 255, and become a RGB pixel with several 255s after it.
*,
*:before,
*:after {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@font-face {
font-family: CtCommandPrompt;
@Chadtech
Chadtech / cppPartner.coffee
Created December 31, 2014 02:29
Executing compiled C++ from Yhavascript (AKA Javascript, AKA coffeescript executable)
# cppPrac.cpp is :
###
include <iostream>
int main (int argumentCount, char * arguments[]){
std::cout << "argument Count is " << argumentCount << "\n";
std::cout << "argument 0 is " << arguments[0] << "\n";
std::cout << "argument 1 is " << arguments[1] << "\n";
gulp = require 'gulp'
concat = require 'gulp-concat'
stylus = require 'gulp-stylus'
jade = require 'gulp-jade'
reload = require 'gulp-livereload'
awatch = require 'gulp-autowatch'
source = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
coffeeify = require 'coffeeify'
browserify = require 'browserify'
Nt = require './build/Release/NtCpp'
{buildFile} = require '../reallyOldNt/noitech'
buildFile 'pointerTest1.wav', [Nt.sineGenerate 466.667, 88200]
if options.flowControl or options.flowcontrol
fc = options.flowControl or options.flowcontrol
if typeof fc is "boolean"
options.rtscts = true
else
fc.forEach (flowControl) ->
fcup = flowControl.toUpperCase()
idx = FLOWCONTROLS.indexOf(fcup)
if idx < 0
err = new Error("Invalid \"flowControl\": " + fcup + ". Valid options: " + FLOWCONTROLS.join(", "))
authenticated = authentication user
homePage() unless authenticated
switch user.role
when 'Admin'
AdminPage user, authenticated
when 'Mod'
ModPage user, authenticated
else
###########
# PROCESS 0
###########
A = [ '0', '1', '2', '3' ]
B = [ '4', '5', '6', '7' ]
C = [ '8', '9', 'a', 'b' ]
D = [ 'c', 'd', 'e', 'f' ]
chunks = [ A, B, C, D ]
_ = require 'lodash'
A = [ '0', '1', '2', '3' ]
B = [ '4', '5', '6', '7' ]
C = [ '8', '9', 'a', 'b' ]
D = [ 'c', 'd', 'e', 'f' ]
hueg = 12
huegIndex = 0