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
Texture2D[] layers; | |
Texture2D compiledTexture = new Texture2D(layers[0].width, layers[0].height); | |
foreach(Texture2D layer in layers){ | |
Color[] baseColors = compiledTexture.GetPixels(); | |
Color[] layerColors = layer.GetPixels(); | |
for(int p = 0; p < baseColors.Length; p++){ |
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
/*********************************************** | |
* Copyright ? Far-Flung Creations Ltd. | |
* Author: Marius George | |
* Date: 25 October 2017 | |
* Email: [email protected] | |
* DISCLAIMER: THE SOURCE CODE IN THIS FILE IS PROVIDED ?AS IS? AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
* INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
* IN NO EVENT SHALL FAR-FLUNG CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | |
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD |
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
/// | |
/// Simple pooling for Unity. | |
/// Author: Martin "quill18" Glaude ([email protected]) | |
/// Extended: Simon "Draugor" Wagner (https://www.twitter.com/Draugor_/) | |
/// Latest Version: https://gist.github.com/Draugor/00f2a47e5f649945fe4466dea7697024 | |
/// License: CC0 (http://creativecommons.org/publicdomain/zero/1.0/) | |
/// UPDATES: | |
/// 2020-07-09: - Fixed a Bug with already inactive members getting Despawned again. thx AndySum (see: https://gist.github.com/Draugor/00f2a47e5f649945fe4466dea7697024#gistcomment-2642441) | |
/// 2020-06-30: - made the "parent" parameter avaible in the public API to spawn GameObjects as children | |
/// 2018-01-04: - Added Extension Method for Despawn on GameObjects |
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
// Configure the Scene View | |
self.sceneView.backgroundColor = .darkGrayColor() | |
// Create the scene | |
let scene = SCNScene() | |
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
using UnityEngine; | |
using System.Collections; | |
namespace Gist { | |
public static class LensShift { | |
public static void Frustum(this Camera cam, out float left, out float right, out float bottom, out float top, out float near, out float far) { | |
near = cam.nearClipPlane; | |
far = cam.farClipPlane; |
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
/* | |
* When developing the UI system we came across a bunch of things we were not happy | |
* with with regards to how certain events and calls could be sent in a loosely coupled | |
* way. We had this requirement because with a UI you tend to implement widgets that receive | |
* certain events, but you don't really want to have lots of glue code to manage them | |
* and keep track of them. The eventing interfaces we developed helped with this. One of | |
* the interesting things, is that they are not justfor the UI system! You can use this as | |
* a type-safe, fast, and simple alternative to SendMessage (never use SendMessage!). | |
* So how does it all work? |
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
var LayerBlur = cc.Layer.extend({ | |
ctor: function (blurRadius, maskColor) { | |
this._super(); | |
// create shader program | |
var program = cc.GLProgram.create(res.blur_vsh, res.blur_fsh); | |
program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); | |
program.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); | |
program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); | |
program.link(); |
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
--- Strings & Numbers --- | |
<String> := <Char> | <Char> <String> | |
<Char> := <Alpha> | <Digit> | <SpecialChar> | |
<Alpha> := "A..Z" | "a..z" | |
<SpecialChar> := "." | "," | ";" | ":" | "'" | " " | "#" | "$" | "?" | |
<Number> := <NumberPart> | <Sign> <NumberPart> | |
<NumberPart> := <IntPart> | <IntPart> "." <DecimalPart> | |
<IntPart> := "0" | <NZDigit> | <NZDigit> <DecimalPart> |
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
static UIImage *imageWithSize(CGSize size) { | |
static CGFloat const kThickness = 20; | |
static CGFloat const kLineWidth = 1; | |
static CGFloat const kShadowWidth = 8; | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0); { | |
CGContextRef gc = UIGraphicsGetCurrentContext(); | |
CGContextAddArc(gc, size.width / 2, size.height / 2, | |
(size.width - kThickness - kLineWidth) / 2, | |
-M_PI / 4, -3 * M_PI / 4, YES); |
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
kernel vec4 coreImageKernel(__color startColor, __color endColor) | |
{ | |
vec2 point = destCoord(); | |
float angle = atan(point.y, point.x) + radians(180.0); | |
//Start from the upper middle, not the left middle | |
angle += radians(90.0); | |
angle = mod(angle, radians(360.0)); | |
float fraction = angle / radians(360.0); |
NewerOlder