UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

111 lines (96 loc) 3.77 kB
// Class: starling.display.BlendMode var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $import = require("./../../import_stub").default; function starling_core_Starling() {return require("./../../starling/core/Starling");} function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");} function openfl_errors_ArgumentError() {return $import(require("openfl/errors/ArgumentError"));} function haxe_ds_StringMap() {return require("./../../haxe/ds/StringMap");} // Constructor var BlendMode = function(name,sourceFactor,destinationFactor) { this.__name = name; this.__sourceFactor = sourceFactor; this.__destinationFactor = destinationFactor; } // Meta BlendMode.__name__ = ["starling","display","BlendMode"]; BlendMode.prototype = { activate: function() { (starling_core_Starling().default).get_current().get_context().setBlendFactors(this.__sourceFactor,this.__destinationFactor); }, toString: function() { return this.__name; }, get_sourceFactor: function() { return this.__sourceFactor; }, get_destinationFactor: function() { return this.__destinationFactor; }, get_name: function() { return this.__name; } }; BlendMode.prototype.__class__ = BlendMode.prototype.constructor = $hxClasses["starling.display.BlendMode"] = BlendMode; // Init Object.defineProperties(BlendMode.prototype,{ "sourceFactor" : { get : function () { return this.get_sourceFactor (); }}, "destinationFactor" : { get : function () { return this.get_destinationFactor (); }}, "name" : { get : function () { return this.get_name (); }}}); // Statics BlendMode.get = function(modeName) { if(BlendMode.sBlendModes == null) { BlendMode.registerDefaults(); } if(BlendMode.sBlendModes.exists(modeName)) { return BlendMode.sBlendModes.get(modeName); } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Blend mode not found: " + modeName)); } } BlendMode.getByFactors = function(srcFactor,dstFactor) { if(BlendMode.sBlendModes == null) { BlendMode.registerDefaults(); } var registeredBlendMode = BlendMode.sBlendModes.iterator(); while(registeredBlendMode.hasNext()) { var registeredBlendMode1 = registeredBlendMode.next(); if(registeredBlendMode1.get_sourceFactor() == srcFactor && registeredBlendMode1.get_destinationFactor() == dstFactor) { return registeredBlendMode1; } } return null; } BlendMode.register = function(name,srcFactor,dstFactor) { if(BlendMode.sBlendModes == null) { BlendMode.registerDefaults(); } var blendMode = new BlendMode(name,srcFactor,dstFactor); BlendMode.sBlendModes.set(name,blendMode); return blendMode; } BlendMode.registerDefaults = function() { if(BlendMode.sBlendModes != null) { return; } BlendMode.sBlendModes = new (haxe_ds_StringMap().default)(); BlendMode.register("none","one","zero"); BlendMode.register("normal","one","oneMinusSourceAlpha"); BlendMode.register("add","one","one"); BlendMode.register("multiply","destinationColor","oneMinusSourceAlpha"); BlendMode.register("screen","one","oneMinusSourceColor"); BlendMode.register("erase","zero","oneMinusSourceAlpha"); BlendMode.register("mask","zero","sourceAlpha"); BlendMode.register("below","oneMinusDestinationAlpha","destinationAlpha"); } BlendMode.AUTO = "auto" BlendMode.NONE = "none" BlendMode.NORMAL = "normal" BlendMode.ADD = "add" BlendMode.MULTIPLY = "multiply" BlendMode.SCREEN = "screen" BlendMode.ERASE = "erase" BlendMode.MASK = "mask" BlendMode.BELOW = "below" // Export exports.default = BlendMode;