Instantly share code, notes, and snippets.

View SurfaceChannelRotate.cpp
void SurfaceChannelRotateApp::rotateChannel( const ci::Channel &channel, ci::Channel &destChannel )
{
const int32_t height = channel.getHeight();
const int32_t width = channel.getWidth();
// 90 deg
/*
for( int32_t y = 0; y < height; ++y ) {
auto ogPtr = channel.getData( ivec2( 0, y ) );
auto newPtr = destChannel.getData( ivec2( height - y - 1, 0 ) );
View .gitconfig
# ------------------ M E R G E -------------------------
[merge]
tool = meld
[mergetool "meld"]
cmd = \"C:\\Program Files (x86)\\Meld\\Meld.exe\" --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\" --label \"MERGE (REMOTE BASE MY)\"
trustExitCode = false
[mergetool]
# don't ask if we want to skip merge
View VectorIteration.cpp
void update()
{
// iterate through all objects in the vector
for( auto iter = mObjectVector.begin() ; iter != mObjectVector.end(); /*DO NOT INCREMENT HERE*/ )
{
if( (*iter)->isMarkedForRemoval() ){
// Remove if obsolete and iter will be the following object in vector
iter = mObjectVector.erase( iter );
} else {
// Update if still active
View LuminanceMapping-frag.glsl
// glsl fragment shader sample
// can be seen at https://www.shadertoy.com/view/MscGD2
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec3 color1 = vec3(90.0/255.0, 170.0/255.0, 251.0/255.0); // light color blue
vec3 color2 = vec3(5.0/255.0, 57.0/255.0, 109.0/255.0); // dark color blue
//vec3 color1 = vec3(247.0/255.0, 238.0/255.0, 87.0/255.0); // light color yellow
View AnimatedGif.cpp
#include "AnimatedGif.h"
using namespace ci;
using namespace ci::app;
using namespace std;
void AnimatedGif::init( ci::DataSourceRef filePath, int frameRate ){
if( filePath ){
load( filePath );
}
View offset
// originall from from http://cvmlrobotics.blogspot.com/2013/03/angularjs-get-element-offset-position.html
function bounds( elm ) {
try {return elm.offset();} catch(e) {}
var rawDom = elm[0];
var _x = 0;
var _y = 0;
var body = document.documentElement || document.body;
var scrollX = window.pageXOffset || body.scrollLeft;
View Mobile OS detection
// is android
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1;
// ios detection
var isIOS = false;
var iDevice = ['iPad', 'iPhone', 'iPod'];
for ( i = 0 ; i < iDevice.length ; i++ ) {
if( navigator.platform === iDevice[i] ){
View vendor prefix
// from http://davidwalsh.name/vendor-prefix
window.prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
return {
View TweenLiteFileSave.as
// import TweenLite for tweening and TimelineLite for keeping track of tweens
import com.greensock.TimelineLite;
import com.greensock.TweenLite;
// import filestream classes for saving images to disk (available only in AIR SDK)
import flash.filesystem.*;
// import PNGEncoder (available here https://github.com/mikechambers/as3corelib)
import com.adobe.images.PNGEncoder;
View CinderTimerEventLoop.cpp
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "cinder/Timeline.h"
#include "cinder/Rand.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class CinderEventLoopApp : public AppBasic {