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
function make_board(size) | |
local board = { size = size } | |
setmetatable(board, { __tostring = board_tostring }) | |
for n = 0, size * size - 1 do | |
board[n] = 0 | |
end | |
return board |
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
- (CGImageRef)createMaskFromAlphaChannel:(UIImage *)image | |
{ | |
size_t width = image.size.width; | |
size_t height = image.size.height; | |
NSMutableData *data = [NSMutableData dataWithLength:width*height]; | |
CGContextRef context = CGBitmapContextCreate( | |
[data mutableBytes], width, height, 8, width, NULL, kCGImageAlphaOnly); |
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); |
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
--- 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
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
/* | |
* 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
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
// 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
/// | |
/// 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 |
OlderNewer