This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Take an input movie file, | |
# blend a thumbnail to the beginning | |
# normalize loudness and fade in audio | |
# fade out at end | |
# encode for youtube/sharing | |
# Generate a test video: | |
# ffmpeg -f lavfi -i testsrc -f lavfi -i aevalsrc="sin(100*t*2*PI*t)" -vf "drawtext=box=1:fontsize=70:text='%{pts\:flt}':x=(w-text_w)/2:y=(h-text_h)/2" -t 10 out.avi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
# This script is a wrapper over ffmpeg with well-tuned defaults and filters # | |
# to get the best out of your input devices # | |
# # | |
# Screen capture to file will prompt to trim, master and encode audio # | |
# # | |
# TODO: camera source / v4l2 sink still not implemented # | |
# # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Place a widget anywhere in x,y pixel space | |
use druid::widget::prelude::*; | |
use druid::{Data, Point, WidgetPod}; | |
pub struct Place<T> { | |
children: Vec<ChildWidget<T>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use druid::{widget::Controller, Data, Env, Event, EventCtx, Selector, UpdateCtx, Widget}; | |
/// Bypass the `AppDelegate` entirely by appending the return from this function as a | |
/// `Controller` wrapping whatever you wish to perform a desired action when there is a change in the data | |
/// | |
/// # Example | |
/// | |
/// ``` | |
///TextBox::new() | |
/// .lens(AppData::foo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#===========================================================================================# | |
# Miniquad WASM/Web Builder # | |
# # | |
# Put this script at the base of your cargo project and run it to quickly build and test # | |
# your miniquad project in a WASM/Web environment. # | |
# # | |
# It creates and pulls in all the necessary files into a directory called 'www/' leaving # | |
# the originals intact. Just delete the www folder to undo its effect. # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cheaper smoothstep | |
// https://forum.unity.com/threads/how-expensive-is-smooth-step-in-shaders-for-mobile.501809/ | |
float cheapstep(float a, float b, float x) { | |
// remap the value | |
float remap = x * (1.0 / (b - a)) - (a / (b - a)); | |
// clamp it to 0 and 1, as smoothstep would | |
return clamp(0., 1., remap); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adds a cinematic sheen by overlaying a glossy radial gradient to every pixel | |
float gloss(vec2 uv) { | |
uv = abs(uv - 0.5); | |
float length2 = dot(uv,uv); | |
return exp(-length2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A function to know how much of a HTML element has been scrolled onto your viewport. | |
// Note: This should no longer be used, prefer: IntersectionObserver. | |
// https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver | |
const clamp = (val, min, max) => Math.min(Math.max(min, val), max); | |
getPercentVisible(element) { | |
const rect = element.getBoundingClientRect(); | |
// If not even partially visible, return early | |
if (rect.top >= window.innerHeight || rect.bottom <= 0) return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// THEATRE CURTAIN PRELOADER | |
// by: Arif Driessen | |
// about: this code produces a fast loading, auto revealing theatre-curtain preloader. | |
// usage: put this code inside <script> tags INSIDE and at the top of <body> | |
function createCurtainCSS(NUMFOLDS) { | |
// draw a preloading Curtain! | |
const parabola = val => Math.pow(4.0 * val * (1.0 - val), 1.0); | |
let curtainCSS = 'background-image: '; | |
// fade to top | |
curtainCSS += 'linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%), '; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Clamp val between min and max | |
const clamp = (val, min, max) => Math.min(Math.max(min, val), max); | |
// Supply a value and a range, return val normalized to 0 and 1 | |
const normalize = (val, min, max) => (val - min) / (max - min); | |
// Shaping Functions /////////////////////////////////////// | |
// Parabola val between 0 and 1. | |
// Original function by Iñigo Quiles |