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
@tool | |
class_name ScreenshotViewportTool extends Node | |
@export var screenshot: bool: | |
set(__): | |
screenshot_viewport() | |
func screenshot_viewport(transparent_background: bool = false, hide_debug_colors: bool = false) -> void: | |
var time_string: String = Time.get_datetime_string_from_system().replace(":", "-").replace("T", "-") | |
var scene_file_name: String = self.get_owner().scene_file_path.get_file().get_basename() |
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
func screenshot_viewport(transparent_background: bool = false) -> void: | |
var time_string: String = Time.get_datetime_string_from_system().replace(":", "-").replace("T", "-") | |
var path := "res://screenshot-" + time_string + '-' + str(randi() % 8999 + 1000) + ".png" | |
var viewport := get_viewport() | |
if transparent_background: | |
viewport.transparent_bg = true; | |
await RenderingServer.frame_post_draw | |
var error: Error = viewport.get_texture().get_image().save_png(path) |
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
extends Label | |
func _process(_delta: float) -> void: | |
text = format_number(Engine.get_frames_per_second()) + " FPS" | |
func format_number(number: Variant, thousand_separator: String = ",") -> String: | |
var number_str: String = str(number) | |
var start_index: int = number_str.find(".") | |
if start_index == -1: |
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
func format_number(number: Variant, thousand_separator: String = ",") -> String: | |
var number_str: String = str(number) | |
var start_index: int = number_str.find(".") | |
if start_index == -1: | |
start_index = number_str.length() | |
for i in range(start_index - 3, 0, -3): | |
number_str = number_str.insert(i, thousand_separator) | |
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
shader_type canvas_item; | |
uniform sampler2D noise_texture: repeat_enable, filter_nearest; | |
uniform vec2 speed = vec2(0.01, 0.01); | |
uniform float sparsity: hint_range(0.0, 5.0) = 1.0; | |
uniform float alpha: hint_range(0.0, 1.0) = 0.5; | |
uniform float edge_falloff: hint_range(0.0, 1.0) = 0.0; | |
uniform float edge_falloff_sensitivity: hint_range(1.0, 20.0) = 1.0; | |
void fragment() { |
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
@tool | |
extends Node2D | |
@export var radius = 50.0: | |
set(value): | |
radius = value | |
queue_redraw() | |
@export var start_angle_deg = 0.0: | |
set(value): |
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
@tool | |
class_name Circle2D extends Polygon2D | |
@export_range(0.0, 360.0, 0.001, "or_greater", "or_less") var start_degree: float = 0.0: | |
set(value): | |
start_degree = _wrap_degree(value) | |
queue_update() | |
@export_range(0.0, 360.0, 0.001, "or_greater", "or_less") var end_degree: float = 360.0: | |
set(value): |
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
class_name ColorUtil extends Object | |
static func parse_html(rgba_or_preset: String, ignore_alpha: bool = false, default_color: Variant = null) -> Color: | |
var color: Variant = PRESET.get(rgba_or_preset.to_upper()) | |
if color == null and Color.html_is_valid(rgba_or_preset): | |
color = Color.html(rgba_or_preset) | |
if color == null: | |
return default_color |
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
func eval(code: String) -> Error: | |
var script := GDScript.new() | |
script.source_code = "static func _static_init(): pass; " + code.strip_edges().replace("\n", ";") | |
return script.reload() |
NewerOlder