Skip to content

Instantly share code, notes, and snippets.

View PrimaryFeather's full-sized avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@PrimaryFeather
PrimaryFeather / GodRayPlane.as
Last active January 15, 2021 08:52
A Starling DisplayObject that displays animated god-rays / sunbeams within a specific area.
package starling.extensions
{
import flash.display.BitmapData;
import starling.animation.IAnimatable;
import starling.display.Quad;
import starling.textures.Texture;
import starling.utils.MathUtil;
/** A quad that efficiently renders a 2D light ray effect on its surface.
@PrimaryFeather
PrimaryFeather / StyledBitmapFont.as
Last active November 21, 2017 04:34
A BitmapFont extension that allows text to be colored by encasing it in tags like {style color=#123456}this{/style}.
package starling.extensions
{
import starling.display.Image;
import starling.display.MeshBatch;
import starling.text.BitmapCharLocation;
import starling.text.BitmapFont;
import starling.text.TextFormat;
import starling.text.TextOptions;
import starling.textures.Texture;
@PrimaryFeather
PrimaryFeather / PixelMaskDisplayObject.as
Last active October 4, 2017 09:52
New Version of "PixelMaskDisplayObject" that works with Starling 2.
package starling.extensions.pixelmask
{
import flash.display3D.Context3DBlendFactor;
import starling.core.Starling;
import starling.display.BlendMode;
import starling.display.DisplayObject;
import starling.display.DisplayObjectContainer;
import starling.display.Image;
import starling.events.Event;
@PrimaryFeather
PrimaryFeather / TestDeviceScaleFactors.as
Last active February 16, 2019 03:46
This code tests the logic used to come up with the stage size and content scale factor on typical devices.
package
{
import flash.display.Sprite;
public class TestDeviceScaleFactors extends Sprite
{
public function TestDeviceScaleFactors()
{
var testSettings:Array = [
{ name: "iPhone 3GS", dpi: 163, resX: 320, resY: 480 },
@PrimaryFeather
PrimaryFeather / MultiTextureStyle.as
Last active October 4, 2020 10:03
A "MeshStyle" for Starling that allows batching of multiple textures in one draw call.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / ColorOffsetStyle.as
Last active February 16, 2018 08:18
A MeshStyle for Starling 2 that allows to add an offset to each color channel of a mesh, as described in the Starling manual.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / ColorOffsetFilter.as
Last active April 6, 2017 01:26
The revised ColorOffsetFilter of the tutorial from the Starling manual; now with fixed PMA handling.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / ColorOffsetFilter.as
Last active December 15, 2016 17:34
Basic implementation of the ColorOffsetFilter described in the Starling manual.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / TextureMaskStyle.as
Last active November 6, 2023 10:40
A MeshStyle for Starling 2 that discards texels with an alpha value below a certain threshold. This makes it perfect for arbitrarily shaped stencil masks.
// =================================================================================================
//
// Starling Framework
// Copyright 2011-2016 Gamua. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / convert_members.rb
Created December 5, 2015 11:51
A small Ruby script that modifies source code so that variables in the form "mName" are changed to "_name"
#!/usr/bin/ruby
if ARGV.count < 1
puts "Usage: #{script_name} source_path"
puts " (e.g. ../src/starling/)"
exit
end
search_path = ARGV[0]