UNPKG

dragonbones-runtime

Version:

the tools to build dragonbones file for diffrent framework

136 lines (126 loc) 6.08 kB
////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the Egret nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL EGRET AND 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) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// namespace egret { //混合模式在Web端只有部分被支持,在 Native 中全部都支持。 //目前所有平台的浏览器都支持的有:Layer,Alpha,Normal,Add,ERASE。 //IOS中的所有浏览器以及Android内的部分浏览器还支持:Multiply,Screen,Lighten,Darken,Difference,Overlay,HardLight。 //仅在 Native 端支持的有:Subtract,Invert。 /** * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode * property of the DisplayObject class. * @see egret.DisplayObject#blendMode * @version Egret 2.4 * @platform Web,Native * @includeExample egret/display/BlendMode.ts * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 * @language en_US */ /** * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 * @see egret.DisplayObject#blendMode * @version Egret 2.4 * @platform Web,Native * @includeExample egret/display/BlendMode.ts * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 * @language zh_CN */ export class BlendMode { /** * The display object appears in front of the background. Pixel values of the display object override the pixel * values of the background. Where the display object is transparent, the background is visible. * @version Egret 2.4 * @platform Web,Native * @language en_US */ /** * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 * @version Egret 2.4 * @platform Web,Native * @language zh_CN */ public static NORMAL:string = "normal"; /** * Adds the values of the constituent colors of the display object to the colors of its background, applying a * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.<br/> * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). * @version Egret 2.4 * @platform Web,Native * @language en_US */ /** * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。<br/> * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 * @version Egret 2.4 * @platform Web,Native * @language zh_CN */ public static ADD:string = "add"; /** * Erases the background based on the alpha value of the display object. * @version Egret 2.4 * @platform Web,Native * @language en_US */ /** * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 * @version Egret 2.4 * @platform Web,Native * @language zh_CN */ public static ERASE:string = "erase"; } } namespace egret.sys { let blendModeString = ["normal", "add", "erase"]; let blendModeNumber = {}; let length = blendModeString.length; for (let i = 0; i < length; i++) { let str = blendModeString[i]; blendModeNumber[str] = i; } /** * @private * 转换 blendMode 字符串为数字。 */ export function blendModeToNumber(blendMode:string):number { let num = blendModeNumber[blendMode]; return num === undefined ? 0 : num; } /** * @private * 转换数字为 blendMode 字符串。 */ export function numberToBlendMode(blendMode:number):string { let str = blendModeString[blendMode]; return str === undefined ? "normal" : str; } }