├── doc ├── user.md ├── godot-flash-demo.gif ├── 8e68e59cf2e75b17a067c9f0eda1505a.png └── 8e68e59cf2e75b17a067c9f0eda1505a.png.import ├── .gitignore ├── .gitattributes ├── addons └── flash_animation │ ├── shaders │ ├── filter │ │ ├── color_transform.gdshaderinc │ │ ├── glow.gdshaderinc │ │ ├── color_matrix.gdshaderinc │ │ ├── blur_y.gdshader │ │ └── blur_x.gdshader │ └── blend │ │ ├── subtract.gdshader │ │ ├── add.gdshader │ │ ├── erase.gdshader │ │ ├── alpha.gdshader │ │ ├── screen.gdshader │ │ ├── invert.gdshader │ │ ├── darken.gdshader │ │ ├── difference.gdshader │ │ ├── multiply.gdshader │ │ ├── lighten.gdshader │ │ ├── hardlight.gdshader │ │ ├── overlay.gdshader │ │ └── normal.gdshader │ ├── plugin.cfg │ ├── plugin.gd │ ├── MovieClip.gd │ ├── flash-file-format-svg.svg.import │ ├── flash-file-format-svg.svg │ └── FlashAnimation.gd ├── README.md ├── MIT-LICENSE └── APACHE-LICENSE /doc/user.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | /* 3 | 4 | !/doc 5 | !/addons/flash_animation -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /doc/godot-flash-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aojiaoxiaolinlin/godot_flash_animation/HEAD/doc/godot-flash-demo.gif -------------------------------------------------------------------------------- /addons/flash_animation/shaders/filter/color_transform.gdshaderinc: -------------------------------------------------------------------------------- 1 | uniform vec4 mult_color = vec4(1, 1, 1, 1); 2 | uniform vec4 add_color = vec4(0, 0, 0, 0); -------------------------------------------------------------------------------- /doc/8e68e59cf2e75b17a067c9f0eda1505a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aojiaoxiaolinlin/godot_flash_animation/HEAD/doc/8e68e59cf2e75b17a067c9f0eda1505a.png -------------------------------------------------------------------------------- /addons/flash_animation/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="FlashAnimation" 4 | description="实现flash动画资源的利用。" 5 | author="傲娇小霖霖" 6 | version="2.0" 7 | script="plugin.gd" 8 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/filter/glow.gdshaderinc: -------------------------------------------------------------------------------- 1 | group_uniforms Glow; 2 | uniform vec4 glow_color; 3 | uniform float glow_strength; 4 | uniform int glow_inner; 5 | uniform int glow_knockout; 6 | uniform int glow_composite_source; 7 | uniform sampler2D blurred; 8 | -------------------------------------------------------------------------------- /addons/flash_animation/plugin.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends EditorPlugin 3 | 4 | 5 | func _enter_tree() -> void: 6 | # Initialization of the plugin goes here. 7 | add_custom_type("FlashAnimation","Node2d",preload("res://addons/flash_animation/FlashAnimation.gd"),preload("res://addons/flash_animation/flash-file-format-svg.svg")) 8 | 9 | 10 | func _exit_tree() -> void: 11 | # Clean-up of the plugin goes here. 12 | remove_custom_type("FlashAnimation") 13 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/subtract.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | render_mode blend_sub; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | void fragment() { 12 | // Called for every pixel the material is visible on. 13 | } 14 | 15 | //void light() { 16 | // Called for every pixel for every light affecting the CanvasItem. 17 | // Uncomment to replace the default light processing function with this one. 18 | //} 19 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/add.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | render_mode blend_add; 3 | #include "res://addons/flash_animation/shaders/filter/color_transform.gdshaderinc" 4 | 5 | uniform mat4 world_matrix; 6 | 7 | void vertex() { 8 | // Called for every vertex the material is visible on. 9 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 10 | } 11 | 12 | void fragment() { 13 | // Called for every pixel the material is visible on. 14 | COLOR = COLOR * mult_color + add_color; 15 | } 16 | 17 | //void light() { 18 | // Called for every pixel for every light affecting the CanvasItem. 19 | // Uncomment to replace the default light processing function with this one. 20 | //} 21 | -------------------------------------------------------------------------------- /addons/flash_animation/MovieClip.gd: -------------------------------------------------------------------------------- 1 | class_name MovieClip 2 | 3 | var current_frame: int 4 | var total_frames: int 5 | var container: Array 6 | 7 | var timelines: Dictionary 8 | var depth_frame: Dictionary 9 | 10 | func _init(_total_frames: int, _timelines: Dictionary) -> void: 11 | total_frames = _total_frames 12 | timelines = _timelines 13 | current_frame = 0 14 | for depth in timelines.keys(): 15 | # 填入{depth: [index, durating]} 16 | depth_frame[depth] = {"index": 0, "duration": 1} 17 | 18 | var shape_transform: Dictionary 19 | 20 | 21 | enum NextFrame { 22 | Next, 23 | First, 24 | } 25 | 26 | func _deterimine_current_frame() -> NextFrame: 27 | if current_frame < total_frames: 28 | return NextFrame.Next 29 | elif total_frames > 1: 30 | return NextFrame.First 31 | else: 32 | return NextFrame.Next 33 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/erase.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | void fragment() { 12 | // Called for every pixel the material is visible on. 13 | vec4 dst = texture(screen_texture, SCREEN_UV); 14 | vec4 src = texture(TEXTURE, UV); 15 | if (src.a > 0.0) { 16 | COLOR = vec4(dst.rgb * (1.0 - src.a), (1.0 - src.a) * dst.a); 17 | } else { 18 | COLOR = dst; 19 | } 20 | } 21 | 22 | //void light() { 23 | // Called for every pixel for every light affecting the CanvasItem. 24 | // Uncomment to replace the default light processing function with this one. 25 | //} 26 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/alpha.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | return max(src, dst); 13 | } 14 | 15 | void fragment() { 16 | // Called for every pixel the material is visible on. 17 | vec4 dst = texture(screen_texture, SCREEN_UV); 18 | vec4 src = texture(TEXTURE,UV); 19 | if (src.a > 0.0) { 20 | COLOR = vec4(dst.rgb * src.a, src.a * dst.a); 21 | } else { 22 | COLOR = dst; 23 | } 24 | } 25 | 26 | //void light() { 27 | // Called for every pixel for every light affecting the CanvasItem. 28 | // Uncomment to replace the default light processing function with this one. 29 | //} 30 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/screen.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | return 1.0 - (1.0 - dst) * (1.0 - src); 13 | } 14 | 15 | void fragment() { 16 | // Called for every pixel the material is visible on. 17 | vec4 dst = texture(screen_texture, SCREEN_UV); 18 | vec4 src = texture(TEXTURE, UV); 19 | if (src.a > 0.0) { 20 | COLOR.rgb = blend_func(src.rgb, dst.rgb); 21 | } else { 22 | COLOR = dst; 23 | } 24 | } 25 | 26 | //void light() { 27 | // Called for every pixel for every light affecting the CanvasItem. 28 | // Uncomment to replace the default light processing function with this one. 29 | //} 30 | -------------------------------------------------------------------------------- /doc/8e68e59cf2e75b17a067c9f0eda1505a.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="CompressedTexture2D" 5 | uid="uid://82ph4pe2b2de" 6 | path="res://.godot/imported/8e68e59cf2e75b17a067c9f0eda1505a.png-2fd1c863a4cb897010f4540c481c320d.ctex" 7 | metadata={ 8 | "vram_texture": false 9 | } 10 | 11 | [deps] 12 | 13 | source_file="res://doc/8e68e59cf2e75b17a067c9f0eda1505a.png" 14 | dest_files=["res://.godot/imported/8e68e59cf2e75b17a067c9f0eda1505a.png-2fd1c863a4cb897010f4540c481c320d.ctex"] 15 | 16 | [params] 17 | 18 | compress/mode=0 19 | compress/high_quality=false 20 | compress/lossy_quality=0.7 21 | compress/hdr_compression=1 22 | compress/normal_map=0 23 | compress/channel_pack=0 24 | mipmaps/generate=false 25 | mipmaps/limit=-1 26 | roughness/mode=0 27 | roughness/src_normal="" 28 | process/fix_alpha_border=true 29 | process/premult_alpha=false 30 | process/normal_map_invert_y=false 31 | process/hdr_as_srgb=false 32 | process/hdr_clamp_exposure=false 33 | process/size_limit=0 34 | detect_3d/compress_to=1 35 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/invert.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | return 1.0 - dst; 13 | } 14 | 15 | void fragment() { 16 | // Called for every pixel the material is visible on. 17 | vec4 dst = texture(screen_texture, SCREEN_UV); 18 | vec4 src = texture(TEXTURE,UV); 19 | if (src.a > 0.0) { 20 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * (1.0 - dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 21 | } else { 22 | COLOR = dst; 23 | } 24 | } 25 | 26 | //void light() { 27 | // Called for every pixel for every light affecting the CanvasItem. 28 | // Uncomment to replace the default light processing function with this one. 29 | //} 30 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/darken.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | return min(src, dst); 13 | } 14 | 15 | void fragment() { 16 | // Called for every pixel the material is visible on. 17 | vec4 dst = texture(screen_texture, SCREEN_UV); 18 | vec4 src = texture(TEXTURE,UV); 19 | if (src.a > 0.0) { 20 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 21 | } else { 22 | COLOR = dst; 23 | } 24 | } 25 | 26 | //void light() { 27 | // Called for every pixel for every light affecting the CanvasItem. 28 | // Uncomment to replace the default light processing function with this one. 29 | //} 30 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/difference.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | return abs(dst - src); 13 | } 14 | 15 | void fragment() { 16 | // Called for every pixel the material is visible on. 17 | vec4 dst = texture(screen_texture, SCREEN_UV); 18 | vec4 src = texture(TEXTURE,UV); 19 | if (src.a > 0.0) { 20 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 21 | } else { 22 | COLOR = dst; 23 | } 24 | } 25 | 26 | //void light() { 27 | // Called for every pixel for every light affecting the CanvasItem. 28 | // Uncomment to replace the default light processing function with this one. 29 | //} 30 | -------------------------------------------------------------------------------- /addons/flash_animation/flash-file-format-svg.svg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="CompressedTexture2D" 5 | uid="uid://bex5lc7cq5r3i" 6 | path="res://.godot/imported/flash-file-format-svg.svg-fda1a6f77223cc91f117e70b3aece0d0.ctex" 7 | metadata={ 8 | "vram_texture": false 9 | } 10 | 11 | [deps] 12 | 13 | source_file="res://addons/flash_animation/flash-file-format-svg.svg" 14 | dest_files=["res://.godot/imported/flash-file-format-svg.svg-fda1a6f77223cc91f117e70b3aece0d0.ctex"] 15 | 16 | [params] 17 | 18 | compress/mode=0 19 | compress/high_quality=false 20 | compress/lossy_quality=0.7 21 | compress/hdr_compression=1 22 | compress/normal_map=0 23 | compress/channel_pack=0 24 | mipmaps/generate=false 25 | mipmaps/limit=-1 26 | roughness/mode=0 27 | roughness/src_normal="" 28 | process/fix_alpha_border=true 29 | process/premult_alpha=false 30 | process/normal_map_invert_y=false 31 | process/hdr_as_srgb=false 32 | process/hdr_clamp_exposure=false 33 | process/size_limit=0 34 | detect_3d/compress_to=1 35 | svg/scale=1.0 36 | editor/scale_with_editor_scale=false 37 | editor/convert_colors_with_editor_theme=false 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Godot Flash Animation 2 | 3 | The plugin can bring Flash animations into Godot. 4 | 5 | ## Feature 6 | 7 | - [x] Support for importing Flash animations and Blend Render. 8 | - [x] Multi Animation. (Require follow certain rules, refer to the conversion tool.) 9 | - [ ] Filter Render. 10 | 11 | ### Filter render 12 | 13 | - [x] Color Filter. 14 | - [x] Blur Filter. 15 | - [ ] Glow Filter. 16 | 17 | ## Demo 18 | 19 | ![demo](./doc/godot-flash-demo.gif) 20 | 21 | ## Usage 22 | 23 | 1. Download the Flash conversion tool from the following link: 24 | [Swf Tool](https://github.com/aojiaoxiaolinlin/swf_animation) 25 | 26 | 2. Use a packing tool that can save file names. I have only tested with **Texture Packer**. 27 | 28 | 3. After importing both this plugin and the packing tool plugin, enable the plugins. Then, create a new **SwfAnimation** node, and attach the generated `*.json` animation file resource to the node's **Animation Data** property. 29 | 30 | ## License 31 | 32 | This code is licensed under dual MIT / Apache-2.0 but with no attribution necessary. All contributions must agree to this licensing. 33 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/multiply.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | vec3 blend_func(vec3 src, vec3 dst) { 11 | return src * dst; 12 | } 13 | void fragment() { 14 | // Called for every pixel the material is visible on. 15 | vec4 dst = texture(screen_texture, SCREEN_UV); 16 | vec4 src = texture(TEXTURE, UV); 17 | if (src.a > 0.0) { 18 | if (dst.a > 0.0) { 19 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 20 | } else { 21 | COLOR = src; 22 | } 23 | } else { 24 | COLOR = dst; 25 | } 26 | } 27 | 28 | //void light() { 29 | // Called for every pixel for every light affecting the CanvasItem. 30 | // Uncomment to replace the default light processing function with this one. 31 | //} 32 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 傲娇小霖霖 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/filter/color_matrix.gdshaderinc: -------------------------------------------------------------------------------- 1 | group_uniforms ColorMatrix; 2 | uniform float r_to_r; 3 | uniform float g_to_r; 4 | uniform float b_to_r; 5 | uniform float a_to_r; 6 | uniform float r_extra; 7 | 8 | uniform float r_to_g; 9 | uniform float g_to_g; 10 | uniform float b_to_g; 11 | uniform float a_to_g; 12 | uniform float g_extra; 13 | 14 | uniform float r_to_b; 15 | uniform float g_to_b; 16 | uniform float b_to_b; 17 | uniform float a_to_b; 18 | uniform float b_extra; 19 | 20 | uniform float r_to_a; 21 | uniform float g_to_a; 22 | uniform float b_to_a; 23 | uniform float a_to_a; 24 | uniform float a_extra; 25 | 26 | vec4 color_filter(vec4 src){ 27 | return vec4( 28 | clamp((r_to_r * src.r / src.a) + (g_to_r * src.g / src.a) + (b_to_r * src.b / src.a) + (a_to_r * src.a) + (r_extra / 255.0), 0.0, 1.0), 29 | clamp((r_to_g * src.r / src.a) + (g_to_g * src.g / src.a) + (b_to_g * src.b / src.a) + (a_to_g * src.a) + (g_extra / 255.0), 0.0, 1.0), 30 | clamp((r_to_b * src.r / src.a) + (g_to_b * src.g / src.a) + (b_to_b * src.b / src.a) + (a_to_b * src.a) + (b_extra / 255.0), 0.0, 1.0), 31 | clamp((r_to_a * src.r / src.a) + (g_to_a * src.g / src.a) + (b_to_a * src.b / src.a) + (a_to_a * src.a) + (a_extra / 255.0), 0.0, 1.0) 32 | ); 33 | } -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/lighten.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | #include "res://addons/flash_animation/shaders/filter/color_transform.gdshaderinc" 3 | 4 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 5 | uniform mat4 world_matrix; 6 | 7 | void vertex() { 8 | // Called for every vertex the material is visible on. 9 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 10 | } 11 | 12 | vec3 blend_func(vec3 src, vec3 dst) { 13 | return max(src, dst); 14 | } 15 | 16 | void fragment() { 17 | // Called for every pixel the material is visible on. 18 | vec4 dst = texture(screen_texture, SCREEN_UV); 19 | vec4 src = texture(TEXTURE, UV); 20 | if (src.a > 0.0) { 21 | //vec4 res = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 22 | vec4 res = max(dst,src); 23 | if (res.a > 0.0){ 24 | //res = vec4(res.rgb / res.a, res.a); 25 | res = res * mult_color + add_color; 26 | COLOR.a = COLOR.a * mult_color.a + add_color.a; 27 | } 28 | COLOR.rgb = res.rgb; 29 | } else { 30 | COLOR = dst; 31 | } 32 | } 33 | 34 | //void light() { 35 | // Called for every pixel for every light affecting the CanvasItem. 36 | // Uncomment to replace the default light processing function with this one. 37 | //} 38 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/hardlight.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | vec3 blend_result = src; 13 | if (src.r <= 0.5) { blend_result.r = (2.0 * src.r * dst.r); } else { blend_result.r = (1.0 - 2.0 * (1.0 - dst.r) * (1.0 - src.r)); } 14 | if (src.g <= 0.5) { blend_result.g = (2.0 * src.g * dst.g); } else { blend_result.g = (1.0 - 2.0 * (1.0 - dst.g) * (1.0 - src.g)); } 15 | if (src.b <= 0.5) { blend_result.b = (2.0 * src.b * dst.b); } else { blend_result.b = (1.0 - 2.0 * (1.0 - dst.b) * (1.0 - src.b)); } 16 | return blend_result; 17 | } 18 | 19 | void fragment() { 20 | // Called for every pixel the material is visible on. 21 | vec4 dst = texture(screen_texture, SCREEN_UV); 22 | vec4 src = texture(TEXTURE,UV); 23 | if (src.a > 0.0) { 24 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 25 | } else { 26 | COLOR = dst; 27 | } 28 | } 29 | 30 | //void light() { 31 | // Called for every pixel for every light affecting the CanvasItem. 32 | // Uncomment to replace the default light processing function with this one. 33 | //} 34 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/overlay.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 3 | 4 | uniform mat4 world_matrix; 5 | 6 | void vertex() { 7 | // Called for every vertex the material is visible on. 8 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 9 | } 10 | 11 | vec3 blend_func(vec3 src, vec3 dst) { 12 | vec3 blend_result = src; 13 | if (dst.r <= 0.5) { blend_result.r = (2.0 * src.r * dst.r); } else { blend_result.r = (1.0 - 2.0 * (1.0 - dst.r) * (1.0 - src.r)); } 14 | if (dst.g <= 0.5) { blend_result.g = (2.0 * src.g * dst.g); } else { blend_result.g = (1.0 - 2.0 * (1.0 - dst.g) * (1.0 - src.g)); } 15 | if (dst.b <= 0.5) { blend_result.b = (2.0 * src.b * dst.b); } else { blend_result.b = (1.0 - 2.0 * (1.0 - dst.b) * (1.0 - src.b)); } 16 | return blend_result; 17 | } 18 | 19 | void fragment() { 20 | // Called for every pixel the material is visible on. 21 | vec4 dst = texture(screen_texture, SCREEN_UV); 22 | vec4 src = texture(TEXTURE,UV); 23 | if (src.a > 0.0) { 24 | COLOR = vec4(src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a) + src.a * dst.a * blend_func(src.rgb / src.a, dst.rgb / dst.a), src.a + dst.a * (1.0 - src.a)); 25 | } else { 26 | COLOR = dst; 27 | } 28 | } 29 | 30 | //void light() { 31 | // Called for every pixel for every light affecting the CanvasItem. 32 | // Uncomment to replace the default light processing function with this one. 33 | //} 34 | -------------------------------------------------------------------------------- /addons/flash_animation/shaders/filter/blur_y.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | 3 | uniform int num_pass: hint_range(1, 255) = 2; 4 | uniform float blur_y: hint_range(0.0, 255.0) = 5.0; 5 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 6 | 7 | void fragment() { 8 | vec4 res = vec4(0.0); 9 | for (int j = 0; j < num_pass; j++) { 10 | ivec2 size = textureSize(screen_texture, 0); 11 | float strength = blur_y; 12 | float full_size = strength < 255.0 ? strength : 255.0; 13 | if (full_size < 1.0){ 14 | COLOR = texture(screen_texture, SCREEN_UV); 15 | }else { 16 | float radius = (full_size - 1.0) / 2.0; 17 | float m = ceil(radius) - 1.0; 18 | float alpha = floor(((radius - m) * 255.0)) / 255.0; 19 | float last_offset = 1.0 / ((1.0 / alpha) + 1.0); 20 | float last_weight = alpha + 1.0; 21 | 22 | //vec2 direction = horizontal ? vec2(1.0 / float(size.x), 0.0) : vec2(0.0, 1.0 / float(size.y)); 23 | vec2 direction = vec2(0.0, 1.0 / float(size.y)); 24 | vec2 uv = SCREEN_UV-direction * m; 25 | // 先采样第一个像素 26 | vec4 total = texture(screen_texture, uv - direction) * alpha; 27 | 28 | vec4 center = vec4(0.0); 29 | for (float k = 0.5; k < m * 2.0; k += 2.0) { 30 | center += texture(screen_texture, uv + direction * k); 31 | } 32 | total += center * 2.0; 33 | 34 | // 最后一个像素对的采样,使用偏移 35 | vec2 last_location = uv + direction * (m * 2.0 + last_offset); 36 | total += texture(screen_texture, last_location) * last_weight; 37 | 38 | // 归一化模糊结果 39 | vec4 result = total / full_size; 40 | // 将结果输出,模拟固定点精度 41 | COLOR = floor(result * 255.0) / 255.0; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /addons/flash_animation/shaders/filter/blur_x.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | 3 | uniform int num_pass: hint_range(1, 255) = 2; 4 | uniform float blur_x: hint_range(0.0, 255.0) = 5.0; 5 | uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; 6 | 7 | void fragment() { 8 | vec4 res = vec4(0.0); 9 | for (int j = 0; j < num_pass; j++) { 10 | ivec2 size = textureSize(screen_texture, 0); 11 | float strength = blur_x; 12 | float full_size = strength < 255.0 ? strength : 255.0; 13 | if (full_size < 1.0){ 14 | COLOR = texture(screen_texture, SCREEN_UV); 15 | } else { 16 | float radius = (full_size - 1.0) / 2.0; 17 | float m = ceil(radius) - 1.0; 18 | float alpha = floor(((radius - m) * 255.0)) / 255.0; 19 | float last_offset = 1.0 / ((1.0 / alpha) + 1.0); 20 | float last_weight = alpha + 1.0; 21 | 22 | //vec2 direction = horizontal ? vec2(1.0 / float(size.x), 0.0) : vec2(0.0, 1.0 / float(size.y)); 23 | vec2 direction = vec2(1.0 / float(size.x), 0.0); 24 | vec2 uv = SCREEN_UV-direction * m; 25 | // 先采样第一个像素 26 | vec4 total = texture(screen_texture, uv - direction) * alpha; 27 | 28 | vec4 center = vec4(0.0); 29 | for (float k = 0.5; k < m * 2.0; k += 2.0) { 30 | center += texture(screen_texture, uv + direction * k); 31 | } 32 | total += center * 2.0; 33 | 34 | // 最后一个像素对的采样,使用偏移 35 | vec2 last_location = uv + direction * (m * 2.0 + last_offset); 36 | total += texture(screen_texture, last_location) * last_weight; 37 | 38 | // 归一化模糊结果 39 | vec4 result = total / full_size; 40 | // 将结果输出,模拟固定点精度 41 | COLOR = floor(result * 255.0) / 255.0; 42 | } 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /addons/flash_animation/shaders/blend/normal.gdshader: -------------------------------------------------------------------------------- 1 | shader_type canvas_item; 2 | 3 | #include "res://addons/flash_animation/shaders/filter/color_matrix.gdshaderinc" 4 | #include "res://addons/flash_animation/shaders/filter/glow.gdshaderinc" 5 | #include "res://addons/flash_animation/shaders/filter/color_transform.gdshaderinc" 6 | 7 | uniform int filter_mode = 1; 8 | uniform mat4 world_matrix; 9 | 10 | void vertex() { 11 | // Called for every vertex the material is visible on. 12 | VERTEX = (world_matrix * vec4(VERTEX,0.0,1.0)).xy; 13 | } 14 | 15 | void fragment() { 16 | if ((filter_mode & 2) != 0) { 17 | bool inner = glow_inner > 0; 18 | bool knockout = glow_knockout > 0; 19 | bool composite_source = glow_composite_source > 0; 20 | float blur = texture(blurred, UV).a; 21 | vec4 dest = texture(TEXTURE, UV); 22 | 23 | vec4 result = vec4(glow_color.r, glow_color.g, glow_color.b, 1.0); 24 | if (inner) { 25 | float alpha = glow_color.a * clamp((1.0 - blur) * glow_strength, 0.0, 1.0); 26 | if (knockout) { 27 | result = result * alpha * dest.a; 28 | }else if (composite_source) { 29 | result = result * alpha * dest.a + dest * (1.0 - alpha); 30 | } else { 31 | result = result * alpha * dest.a; 32 | } 33 | } else { 34 | float alpha = glow_color.a * clamp(blur * glow_strength, 0.0, 1.0); 35 | if (knockout) { 36 | result = result * alpha * (1.0 - dest.a); 37 | }else if (composite_source) { 38 | result = result * alpha * (1.0 - dest.a) + dest; 39 | }else { 40 | result = result * alpha; 41 | } 42 | } 43 | //COLOR = result; 44 | } 45 | if ((filter_mode & 8) !=0 ) { 46 | vec4 src = texture(TEXTURE, UV); 47 | COLOR = color_filter(src); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /addons/flash_animation/flash-file-format-svg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /addons/flash_animation/FlashAnimation.gd: -------------------------------------------------------------------------------- 1 | # 添加@tool可以在编辑器中运行 2 | @tool 3 | extends Node2D 4 | 5 | class_name FlashAnimatiion 6 | 7 | signal play_end 8 | 9 | # Flash动画文件名 10 | var file_name: String 11 | # 用于展示的动画 12 | var animations: Dictionary 13 | # 所有用于展示的动画的名字 14 | var animation_names:Array 15 | # 所有子动画 16 | var base_animations: Dictionary 17 | var frame_rate: float 18 | # 图形定位偏移变换 19 | var shape_offset: Dictionary 20 | var shape_texture: Dictionary 21 | 22 | # 当前运行的MC实例 23 | var current_movie_clip: MovieClip 24 | 25 | # 所有子MC动画实例 26 | var movie_clip_pool: Dictionary 27 | # 保存已经生成的子节点, 28 | var node_cache: Dictionary 29 | # 记录当前帧可视节点 30 | var visiable_node: Array 31 | 32 | # JSON格式的动画数据 33 | @export var animation_data: JSON: 34 | set(data): 35 | if data == null: 36 | for i in get_child_count(): 37 | get_child(i).queue_free() 38 | node_cache.clear() 39 | animation_data = data 40 | if animation_data != null: 41 | parse_json() 42 | notify_property_list_changed() 43 | 44 | 45 | @export var preview: bool 46 | @export var use_root_transform: bool 47 | 48 | func _get_property_list() -> Array[Dictionary]: 49 | var properties: Array[Dictionary] = [] 50 | if animation_data == null: 51 | return properties 52 | 53 | if animation_names.size() > 0: 54 | properties.append({ 55 | "name": "swf_current_animation", 56 | "type": TYPE_INT, 57 | "hint": PROPERTY_HINT_ENUM, 58 | "hint_string": ",".join(animation_names), 59 | }) 60 | 61 | return properties 62 | 63 | var internal_data: Dictionary = {} 64 | func _set(property: StringName, value: Variant) -> bool: 65 | if property.begins_with("swf_"): 66 | internal_data[property] = value 67 | if property == "swf_current_animation" && animation_names.size() > 0: 68 | current_movie_clip = MovieClip.new(animations[animation_names[value]].total_frames, animations[animation_names[value]]["timelines"]) 69 | return true 70 | return false 71 | 72 | func _get(property: StringName) -> Variant: 73 | if(property.begins_with("swf_current")): 74 | return internal_data.get_or_add(property, 0) 75 | return null 76 | 77 | 78 | # Called when the node enters the scene tree for the first time. 79 | func _ready() -> void: 80 | if animation_data != null: 81 | parse_json() 82 | 83 | var elapsed_time: float = 0 84 | var current_frame: int = 0 85 | var total_frames: int = 0 86 | # Called every frame. 'delta' is the elapsed time since the previous frame. 87 | func _process(delta: float) -> void: 88 | pass 89 | if !preview: 90 | return 91 | if animations == null || current_movie_clip == null: 92 | return 93 | # 总帧数 94 | total_frames = current_movie_clip["total_frames"] 95 | ## 按照帧率播放 96 | elapsed_time += delta 97 | if elapsed_time >= 1.0 / frame_rate: 98 | elapsed_time -= 1.0 / frame_rate 99 | current_frame += 1 100 | if current_frame >= total_frames: 101 | current_frame = 0 102 | play_end.emit() 103 | visiable_node.clear() 104 | run_frame(current_movie_clip, "Normal") 105 | for child in node_cache.values(): 106 | # 全部隐藏 107 | if child is CanvasItem: 108 | child.visible = false 109 | var i = 0; 110 | for node_name in visiable_node: 111 | # 设置当前帧可视 112 | node_cache[node_name].visible = true 113 | # 设置z_index,重新排序 114 | node_cache[node_name].z_index = i 115 | i += 1 116 | 117 | 118 | func parse_json(): 119 | file_name = animation_data.data["name"] 120 | frame_rate = animation_data.data["frame_rate"] 121 | base_animations = animation_data.data["base_animations"] 122 | shape_offset = animation_data.data["shape_transform"] 123 | animations = animation_data.data["animations"] 124 | 125 | for id in shape_offset: 126 | var path = "res://%s.sprites/%s.tres" % [file_name, str(id)] 127 | shape_texture[id] = load(path) 128 | 129 | animation_names = animations.keys() 130 | for child in base_animations: 131 | var movie_clip = MovieClip.new(base_animations[child].total_frames, base_animations[child].timelines) 132 | movie_clip_pool[child] = movie_clip 133 | 134 | 135 | 136 | func run_frame(movie_clip: MovieClip, blend_mode: String, filters: Array = [], parent_transform: Transform3D = Transform3D.IDENTITY, parent_mult_color: Vector4 = Vector4(1, 1, 1, 1), parent_add_color: Vector4 = Vector4(0, 0, 0, 0), parent_depth: String = "0") -> void: 137 | match movie_clip._deterimine_current_frame(): 138 | MovieClip.NextFrame.Next: 139 | movie_clip.current_frame += 1 140 | MovieClip.NextFrame.First: 141 | movie_clip.current_frame = 1 142 | for key in movie_clip.depth_frame: 143 | movie_clip.depth_frame[key].index = 0 144 | movie_clip.depth_frame[key].duration = 1 145 | 146 | for depth in movie_clip.timelines: 147 | var frames: Array = movie_clip.timelines[depth] 148 | var depth_frame = movie_clip.depth_frame[depth] 149 | # 表示该时间轴已经用完 150 | if depth_frame.index >= frames.size(): 151 | continue 152 | var frame = frames[depth_frame.index] 153 | if frame.place_frame > movie_clip.current_frame || (frame.place_frame + depth_frame.duration) > movie_clip.current_frame: 154 | continue 155 | if depth_frame.duration < movie_clip.total_frames: 156 | depth_frame.duration += 1 157 | if depth_frame.duration > frame.duration: 158 | depth_frame.index += 1 159 | depth_frame.duration = 1 160 | 161 | var matrix = frame.transform.matrix 162 | var current_transform: Transform3D 163 | 164 | # 不应用根动画的位置 165 | if ((current_movie_clip == movie_clip) && !use_root_transform): 166 | current_transform = parent_transform * Transform3D(Vector3(matrix.a, matrix.b, 0), Vector3(matrix.c, matrix.d, 0), Vector3(0, 0, 1), Vector3(0, 0, 0)) 167 | else: 168 | current_transform = parent_transform * Transform3D(Vector3(matrix.a, matrix.b, 0), Vector3(matrix.c, matrix.d, 0), Vector3(0, 0, 1), Vector3(matrix.tx, matrix.ty, 0)) 169 | var color_transform = frame.transform.color_transform 170 | var mult_color = Vector4(color_transform.mult_color[0], color_transform.mult_color[1], color_transform.mult_color[2], color_transform.mult_color[3]) 171 | var current_add_color = Vector4(color_transform.add_color[0], color_transform.add_color[1], color_transform.add_color[2], color_transform.add_color[3]) + mult_color * parent_add_color 172 | var current_mult_color = parent_mult_color * mult_color 173 | 174 | var child_clip = movie_clip_pool.get(str(frame.id)) 175 | var current_depth_layer = parent_depth + depth 176 | # 如果子动画存在,则递归调用 177 | if child_clip != null: 178 | run_frame(child_clip, frame.blend_mode, frame.filters, current_transform, current_mult_color, current_add_color) 179 | else: 180 | # 加载纹理资源 181 | var shader_material = ShaderMaterial.new() 182 | # 设置混合着色器 183 | shader_material.shader = get_blend_mode(blend_mode) 184 | # 用于抵消shape定义的偏移 185 | var shape_translate = shape_offset[str(frame.id)] 186 | if shape_translate == null: 187 | continue 188 | # 设置动画变换 189 | shader_material.set_shader_parameter("world_matrix", current_transform.translated_local(Vector3(shape_translate[0], shape_translate[1], 0))) 190 | shader_material.set_shader_parameter("mult_color", current_mult_color) 191 | shader_material.set_shader_parameter("add_color", current_add_color) 192 | 193 | # 设置滤镜 194 | var filter_mode = 0; # 1:无滤镜 2:发光滤镜 4: 模糊滤镜 8:颜色滤镜 195 | # 跳过目前未处理标签(DefineMorphShape) 196 | var texture: Texture2D = shape_texture.get(str(frame.id)) 197 | if texture == null: 198 | return 199 | 200 | var is_processed: bool = false 201 | 202 | # 为了性能是否考虑缓存滤镜渲染结果 203 | for filter: Dictionary in filters: 204 | # TODO: 没做的滤镜都是能力有限。不会做 205 | # 颜色滤镜 206 | var color_matrix_filter = filter.get("ColorMatrixFilter") 207 | if color_matrix_filter != null: 208 | filter_mode = filter_mode + 1 << 3 209 | set_color_matrix(shader_material, color_matrix_filter.matrix) 210 | 211 | if !is_processed: 212 | visiable_node.append(current_depth_layer + "-" + str(frame.id)) 213 | 214 | shader_material.set_shader_parameter("filter_mode", filter_mode) 215 | var res_sprite 216 | if node_cache.get(current_depth_layer + "-" + str(frame.id)) != null: 217 | res_sprite = node_cache.get(current_depth_layer + "-" + str(frame.id)) 218 | res_sprite.material = shader_material 219 | else: 220 | res_sprite = Sprite2D.new() 221 | node_cache[current_depth_layer + "-" + str(frame.id)] = res_sprite 222 | res_sprite.texture = texture 223 | node_cache[current_depth_layer + "-" + str(frame.id)] = res_sprite 224 | add_child(res_sprite) 225 | res_sprite.material = shader_material 226 | 227 | 228 | func get_blend_mode(blend_mode: String) -> Shader: 229 | if blend_mode == "Add": 230 | return preload("res://addons/flash_animation/shaders/blend/add.gdshader") 231 | elif blend_mode == "Lighten": 232 | return preload("res://addons/flash_animation/shaders/blend/lighten.gdshader") 233 | elif blend_mode == "Multiplay": 234 | return preload("res://addons/flash_animation/shaders/blend/multiply.gdshader") 235 | elif blend_mode == "Darken": 236 | return preload("res://addons/flash_animation/shaders/blend/darken.gdshader") 237 | elif blend_mode == "Overlay": 238 | return preload("res://addons/flash_animation/shaders/blend/overlay.gdshader") 239 | elif blend_mode == "HardLight": 240 | return preload("res://addons/flash_animation/shaders/blend/hardlight.gdshader") 241 | elif blend_mode == "Difference": 242 | return preload("res://addons/flash_animation/shaders/blend/difference.gdshader") 243 | elif blend_mode == "Alpha": 244 | return preload("res://addons/flash_animation/shaders/blend/alpha.gdshader") 245 | elif blend_mode == "Invert": 246 | return preload("res://addons/flash_animation/shaders/blend/invert.gdshader") 247 | elif blend_mode == "Erase": 248 | return preload("res://addons/flash_animation/shaders/blend/erase.gdshader") 249 | elif blend_mode == "Subtract": 250 | return preload("res://addons/flash_animation/shaders/blend/subtract.gdshader") 251 | elif blend_mode == "Screen": 252 | return preload("res://addons/flash_animation/shaders/blend/screen.gdshader") 253 | else: 254 | return preload("res://addons/flash_animation/shaders/blend/normal.gdshader") 255 | 256 | func set_color_matrix(shader_material: ShaderMaterial, matrix: Array): 257 | shader_material.set_shader_parameter("r_to_r", matrix[0]) 258 | shader_material.set_shader_parameter("g_to_r", matrix[1]) 259 | shader_material.set_shader_parameter("b_to_r", matrix[2]) 260 | shader_material.set_shader_parameter("a_to_r", matrix[3]) 261 | shader_material.set_shader_parameter("r_extra", matrix[4]) 262 | shader_material.set_shader_parameter("r_to_g", matrix[5]) 263 | shader_material.set_shader_parameter("g_to_g", matrix[6]) 264 | shader_material.set_shader_parameter("b_to_g", matrix[7]) 265 | shader_material.set_shader_parameter("a_to_g", matrix[8]) 266 | shader_material.set_shader_parameter("g_extra", matrix[9]) 267 | shader_material.set_shader_parameter("r_to_b", matrix[10]) 268 | shader_material.set_shader_parameter("g_to_b", matrix[11]) 269 | shader_material.set_shader_parameter("b_to_b", matrix[12]) 270 | shader_material.set_shader_parameter("a_to_b", matrix[13]) 271 | shader_material.set_shader_parameter("b_extra", matrix[14]) 272 | shader_material.set_shader_parameter("r_to_a", matrix[15]) 273 | shader_material.set_shader_parameter("g_to_a", matrix[16]) 274 | shader_material.set_shader_parameter("b_to_a", matrix[17]) 275 | shader_material.set_shader_parameter("a_to_a", matrix[18]) 276 | shader_material.set_shader_parameter("a_extra", matrix[19]) 277 | 278 | -------------------------------------------------------------------------------- /APACHE-LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------