Skip to content

Instantly share code, notes, and snippets.

View hdachev's full-sized avatar

Hristo Dachev hdachev

View GitHub Profile
@hdachev
hdachev / OpenType.ts
Created July 20, 2024 11:37 — forked from smhanov/OpenType.ts
Here is my implementation of a TrueType font reader in Typescript. You can read a font directly from an ArrayBuffer, and then call drawText() to draw it. See my article http://stevehanov.ca/blog/index.php?id=143. The second file, OpenType.ts is the same thing but it handles more TrueType files. It is also more coplex
// To see this run, you first stub out these imports. Then put the file in a Uint8Array.
// let slice = new Slice(array);
// let font = new OTFFont(slice);
// Then you can call methods like font.drawText(canvasContext, )
//
//
import { ICanvasContext } from "./ICanvasContext"
import { log as Log } from "./log"
const log = Log.create("OPENTYPE");
//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@hdachev
hdachev / pbr.glsl
Created September 25, 2016 11:55 — forked from galek/pbr.glsl
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@hdachev
hdachev / fakebrowse.html
Created July 31, 2012 15:24
silly example of fakeredis in the browser
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var exported = window, module = {}, exports;
function require ( path )
{