Skip to content

Instantly share code, notes, and snippets.

View arcollector's full-sized avatar

Ruiz Martin arcollector

View GitHub Profile
@arcollector
arcollector / minified.html.output.php
Last active June 20, 2016 15:48
minified html output with php using ob_start
/**
* This snippet minified the html output of your php application, just paste this code
* at the top of your application's entry point
*
* NOTE: <script>, <style>, <pre> and <textarea> tags are not processed by this script, which is a good thing
*
* NOTE: you will need PHP_VERSION >= 5.3 to run this code
*
* NOTE: all the whitespace between tags will be deleted, affecting the visual presentation of your webpage,
* consider this example: <span>Hello, <span>Joe</span></span> -> it will be modified to this ->
@arcollector
arcollector / c.for.dos.with.watcom.sublime-build
Created June 19, 2013 01:23
Compile 16 bit executable with watcom
{
"cmd": [ "wcl", "/l=dos", "$file_name" ],
"working_dir": "${project_path:${folder}}",
"selector": "source.c"
}
@arcollector
arcollector / mandel.c
Created June 23, 2013 15:52
Mandelbrot set implementation in TURBO-C
/**
* Mandelbrot set implementation in TURBO-C
*
* To compile follow these steps:
* > tcc -ml mandel.c
* > tlink c0m mandel, mandel,, emu fp87 mathm graphics cm
* > mandel
*
* By Robert Lafore - 1989
* for the book Turbo C - Programming for the PC
@arcollector
arcollector / rotation.and.translatation.in.2d.space.in.js.html
Last active December 19, 2015 09:19
A simple translation/rotation algorithm in a 2d space
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Translation and rotation algorithm in a 2D space</title>
<style>
body {
background: peru;
font: 12px Tahoma, Ubuntu;
}
@arcollector
arcollector / scaling.bitmap.in.js.html
Last active December 19, 2015 10:59
2d scaling bitmap algorithm in js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scaling 2D bitmap</title>
<style>
body {
background: peru;
font: 12px Tahoma, Ubuntu;
}
function line( xa,ya, xb,yb ) {
dx = xb - xa;
dy = yb - ya;
if( dx < 0 ) {
cInc = -1;
} else {
cInc = 1;
}
if( dy < 0 ) {
@arcollector
arcollector / gist:37b481ca044092881e4c
Last active August 29, 2015 14:20
Integer DDA Line drawing in JS
function vLine( ya,yb, xa ) {
ya = Math.round( ya );
yb = Math.round( yb );
xa = Math.round( xa );
var y = ya < yb ? ya : yb,
i = Math.abs( ya - yb );
for( ; i >= 0; i-- ) {
console.log( 'plot', xa, y+i );
}
@arcollector
arcollector / gist:71be4048fc5a9e1980e5
Last active August 29, 2015 14:20
BMP file creation in js
function long2LittleEndian( val ) {
return new Uint8Array( [ val & 0x000000ff, (val & 0x0000ff00) >> 8, (val & 0x00ff0000) >> 16, (val & 0xff000000) >> 24 ] );
}
function bmp( width, height, canvas ) {
var extraBytes = width % 4,
canvaSize = height*(width*3 + extraBytes),
fileSize = 54 + canvaSize,
fz = long2LittleEndian( fileSize ),
w = long2LittleEndian( width ),
@arcollector
arcollector / gist:a7a1492689dee2e947ec
Last active November 21, 2023 01:34
Polygon scanline filling in JS
var polygonFilling = function( vertices ) {
// "global" variables
var verticesCount = vertices.length,
edgesEntered,
// table cols
yMax, yMin, xInt, invNegSlope;
// *************************
@arcollector
arcollector / gist:155a8c751f65c15872fb
Last active March 8, 2020 17:31
Seed scanline filling algorithm in JS
var download = function( arrayBuffer ) {
var $a = document.createElement( 'a' );
$a.setAttribute( 'download', +new Date() + '.bmp' );
$a.setAttribute( 'href', URL.createObjectURL( new Blob( [ arrayBuffer ], { type: 'application/octet-binary' } ) ) );
$a.style.display = 'none';
document.body.appendChild( $a );
$a.click();
document.body.removeChild( $a );
}