Skip to content

Instantly share code, notes, and snippets.

View Flyer53's full-sized avatar

Stefan Sträßer Flyer53

View GitHub Profile
@Flyer53
Flyer53 / color-conversion-algorithms.js
Created December 15, 2015 15:56 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@Flyer53
Flyer53 / perceived-brightness.js
Last active December 11, 2015 18:43
Plugin for one-color https://github.com/One-com/one-color. Function calculates perceived brightness of a passed color.
function pB (algo) {
var algorithm = algo || 'rec2020';
var rgb = this.rgb();
if (algorithm === 'rec2020') {
// https://en.wikipedia.org/wiki/Rec._2020
return ( (rgb._red * 2627) + (rgb._green * 6780) + (rgb._blue * 593) ) / 10000;
@Flyer53
Flyer53 / getQuerystringValue.js
Created November 15, 2015 15:38
Get querystring parameter values
/*
By Chris Coyier
https://css-tricks.com/snippets/javascript/get-url-variables/
*/
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@Flyer53
Flyer53 / index.html
Last active December 18, 2019 09:32 — forked from insin/index.html
JavaScript function to export HTML table to MS Excel sheet
<!DOCTYPE html>
<html>
<head>
<title>tableToExcel Demo</title>
<script src="tableToExcel.js"></script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>