Skip to content

Instantly share code, notes, and snippets.

View mauriciomassaia's full-sized avatar

Mauricio Massaia mauriciomassaia

View GitHub Profile
@mauriciomassaia
mauriciomassaia / wall-mapping.frag
Created January 30, 2020 21:39
PixiJS - Fragment to add a gap and also a mask in projection with 3 walls of 1920x1200 each.
// 3 walls using each a 1920x1200 projector in a row but wall1 and wall2 collided as per projector physical placement
// so need to have a gap, as wall2 only uses 1866px so from x: 1920 (end wall1) to x:1974 (beginning wall2) we need
// to shift all pixels by 54px
// Also discard all pixels that cover the pillar area where another projector will be used with a cone mapping to play
// content on loop.
precision mediump float;
// supplied by pixijs
varying vec2 vTextureCoord;
@mauriciomassaia
mauriciomassaia / .editorconfig
Created September 10, 2019 01:53
EditorConfig
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@mauriciomassaia
mauriciomassaia / convert-webm.sh
Created August 29, 2019 01:55
Convert mp4 to webm videos
#!/bin/bash
VIDEOS=/Users/mm/videos/exported/
find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "${0%%.mp4}.webm"' {} \;
exit;
@mauriciomassaia
mauriciomassaia / rename-exported.js
Created August 29, 2019 01:54
Move and Rename files exported from Adobe Media Encoder
const fs = require('fs')
const path = require('path')
const dir = path.join(__dirname, 'exported')
const files = fs.readdirSync(dir)
console.log(files)
files.forEach(file => {
const size = 512
const size2 = size / 2
const c = document.createElement('canvas')
c.width = size
c.height = size
document.body.appendChild(c)
const ctx = c.getContext('2d')
ctx.fillStyle = '#ff0000'
ctx.fillRect(0, 0, size, size)
@mauriciomassaia
mauriciomassaia / mm.sublime-theme
Created June 14, 2018 05:37
Sublime Theme / IBM Plex Font / 4k screen
[
{
"class": "sidebar_label",
"color": [131, 148, 150],
"font.bold": false,
"font.size": 16,
"font.face": "IBM Plex Mono"
},
{
"class": "sidebar_container",
@mauriciomassaia
mauriciomassaia / tween-color.js
Created April 19, 2018 03:42
GSAP + ColorPropsPlugin + Pixi.js
import { TweenMax } from 'gsap'
import 'gsap/ColorPropsPlugin'
const g = new Graphics()
g.beginFill(color, alpha)
g.drawRect(x, y, width, height)
g.endFill()
container.addChild(g)
TweenMax.to(g, 0.5, {colorProps: {tint: 0x00aaff, format: 'number'}})
@mauriciomassaia
mauriciomassaia / image-data-resize.js
Created March 20, 2018 07:15
ImageData resize on Canvas
export async function resizeImageData (imageData, width, height) {
const resizeWidth = width >> 0
const resizeHeight = height >> 0
const ibm = await window.createImageBitmap(imageData, 0, 0, imageData.width, imageData.height, {
resizeWidth, resizeHeight
})
const canvas = document.createElement('canvas')
canvas.width = resizeWidth
canvas.height = resizeHeight
const ctx = canvas.getContext('2d')
@mauriciomassaia
mauriciomassaia / pixi-app.js
Created August 2, 2017 08:49
Pixi Application es6
import { Application } from 'pixi.js'
const app = new Application({
width: window.innerWidth,
height: window.innerHeight,
resolution: window.devicePixelRatio || 1,
antialias: true
})
app.ticker.add(() => {
@mauriciomassaia
mauriciomassaia / colors.js
Last active September 24, 2019 06:50
Color convertion
/**
* @param {Array} arr - [140, 255, 1]
* @returns {Array} [0.5490196078, 1, 0.003921568627]
*/
export function normalizeArray (arr, value) {
return arr.map(v => v / value)
}
/**
* @param {Number} colorNum 0xff00ff