input (text/checkbox), form, button

This commit is contained in:
Face
2025-07-23 15:23:32 +03:00
parent 7a0b678fc2
commit a9ce6cb178
48 changed files with 1720 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
extends ScrollDamper
class_name CubicScrollDamper
## Friction, not physical.
## The higher the value, the more obvious the deceleration.
@export_range(0.001, 10000.0, 0.001, "or_greater", "hide_slider")
var friction := 4.0:
set(val):
friction = max(val, 0.001)
_factor = pow(10.0, friction) - 1.0
## Factor to use in formula
var _factor := 10000.0:
set(val): _factor = max(val, 0.000000000001)
func _calculate_velocity_by_time(time: float) -> float:
if time <= 0.0: return 0.0
return time*time*time * _factor
func _calculate_time_by_velocity(velocity: float) -> float:
return pow(abs(velocity) / _factor, 1.0/3.0)
func _calculate_offset_by_time(time: float) -> float:
time = max(time, 0.0)
return 1.0/4.0 * _factor * time*time*time*time
func _calculate_time_by_offset(offset: float) -> float:
return pow(abs(offset) * 4.0 / _factor, 1.0/4.0)

View File

@@ -0,0 +1 @@
uid://dlagxcnf11lr4

View File

@@ -0,0 +1,47 @@
extends ScrollDamper
class_name ExpoScrollDamper
## Friction, not physical.
## The higher the value, the more obvious the deceleration.
@export_range(0.001, 10000.0, 0.001, "or_greater", "hide_slider")
var friction := 4.0:
set(val):
friction = max(val, 0.001)
_factor = pow(10.0, friction)
## Factor to use in formula
var _factor := 10000.0:
set(val): _factor = max(val, 1.000000000001)
## Minumun velocity.
@export_range(0.001, 100000.0, 0.001, "or_greater", "hide_slider")
var minimum_velocity := 0.4:
set(val): minimum_velocity = max(val, 0.001)
func _calculate_velocity_by_time(time: float) -> float:
var minimum_time = _calculate_time_by_velocity(minimum_velocity)
if time <= minimum_time: return 0.0
return pow(_factor, time)
func _calculate_time_by_velocity(velocity: float) -> float:
return log(abs(velocity)) / log(_factor)
func _calculate_offset_by_time(time: float) -> float:
return pow(_factor, time) / log(_factor)
func _calculate_time_by_offset(offset: float) -> float:
return log(offset * log(_factor)) / log(_factor)
func _calculate_velocity_to_dest(from: float, to: float) -> float:
var dist = to - from
var min_time = _calculate_time_by_velocity(minimum_velocity)
var min_offset = _calculate_offset_by_time(min_time)
var time = _calculate_time_by_offset(abs(dist) + min_offset)
var vel = _calculate_velocity_by_time(time) * sign(dist)
return vel

View File

@@ -0,0 +1 @@
uid://b7h0k2h2qwlqv

Binary file not shown.

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1,0,0,1,34.4806,-89.0415)">
<path d="M185.254,992.427C601.296,991.628 768.576,997.711 778.133,294.568" style="fill:none;stroke:rgb(191,244,196);stroke-width:70px;"/>
</g>
<g id="icon.afdesign" transform="matrix(28.1622,0,0,28.1622,387.945,401.774)">
<g transform="matrix(1,0,0,1,-12.5,-12.5)">
<g transform="matrix(0.268293,0,0,0.255556,-0.914634,-0.277778)">
<path d="M58.4,10.7C66.4,10.7 73,17.2 73,25.3L73,66.3C73,79 62.7,89.3 50,89.3C37.3,89.3 27,79 27,66.3L27,25.3C27,17.3 33.5,10.7 41.6,10.7L58.4,10.7M58.4,5L41.6,5C30.4,5 21.3,14.1 21.3,25.3L21.3,66.3C21.3,82.1 34.1,95 50,95C65.9,95 78.7,82.1 78.7,66.3L78.7,25.3C78.7,14.1 69.6,5 58.4,5Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
<g transform="matrix(0.268293,0,0,0.255556,-0.914634,-0.277778)">
<path d="M50,52.5C49.7,52.5 49.3,52.4 49,52.2L40.2,46C39.4,45.5 39.2,44.4 39.8,43.6C40.3,42.8 41.4,42.6 42.2,43.2L50,48.7L57.8,43.2C58.6,42.7 59.6,42.8 60.2,43.6C60.7,44.4 60.6,45.4 59.8,46L51,52.2C50.7,52.4 50.3,52.5 50,52.5Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
<g transform="matrix(0.268293,0,0,0.255556,-0.914634,-0.277778)">
<path d="M50.1,65.8C49.8,65.8 49.4,65.7 49.1,65.5L40.3,59.3C39.5,58.8 39.3,57.7 39.9,56.9C40.4,56.1 41.5,55.9 42.3,56.5L50.1,62L57.9,56.5C58.7,56 59.7,56.1 60.3,56.9C60.8,57.7 60.7,58.7 59.9,59.3L51.1,65.5C50.8,65.7 50.5,65.8 50.1,65.8Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
<g transform="matrix(0.268293,0,0,0.255556,-0.914634,-0.277778)">
<path d="M50,78.8C49.7,78.8 49.3,78.7 49,78.5L40.2,72.3C39.4,71.8 39.2,70.7 39.8,69.9C40.4,69.1 41.4,68.9 42.2,69.5L50,75L57.8,69.5C58.6,69 59.6,69.1 60.2,69.9C60.7,70.7 60.6,71.7 59.8,72.3L51,78.5C50.7,78.7 50.3,78.8 50,78.8Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
<g transform="matrix(0.268293,0,0,0.255556,-0.914634,-0.277778)">
<path d="M50,36.3C48.1,36.3 46.6,34.8 46.6,32.9L46.6,25.4C46.6,23.5 48.1,22 50,22C51.9,22 53.4,23.5 53.4,25.4L53.4,32.9C53.4,34.8 51.9,36.3 50,36.3Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
</g>
</g>
<g transform="matrix(-10.6313,1.88738e-15,-3.10862e-15,-25.7598,1344.05,1429.95)">
<path d="M50,52.5C49.7,52.5 49.3,52.4 49,52.2L40.2,46C39.4,45.5 39.2,44.4 39.8,43.6C40.3,42.8 41.4,42.6 42.2,43.2L50,48.7L57.8,43.2C58.6,42.7 59.6,42.8 60.2,43.6C60.7,44.4 60.6,45.4 59.8,46L51,52.2C50.7,52.4 50.3,52.5 50,52.5Z" style="fill:rgb(191,244,196);fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://4ok12qtgl7xq"
path="res://.godot/imported/icon.svg-5b01e8115f19d6d63dc265815ce29c75.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/SmoothScroll/scroll_damper/icon.svg"
dest_files=["res://.godot/imported/icon.svg-5b01e8115f19d6d63dc265815ce29c75.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,33 @@
extends ScrollDamper
class_name LinearScrollDamper
## Friction, not physical.
## The higher the value, the more obvious the deceleration.
@export_range(0.001, 10000.0, 0.001, "or_greater", "hide_slider")
var friction := 4.0:
set(val):
friction = max(val, 0.001)
_factor = pow(10.0, friction) - 1.0
## Factor to use in formula
var _factor := 10000.0:
set(val): _factor = max(val, 0.000000000001)
func _calculate_velocity_by_time(time: float) -> float:
if time <= 0.0: return 0.0
return time * _factor
func _calculate_time_by_velocity(velocity: float) -> float:
return abs(velocity) / _factor
func _calculate_offset_by_time(time: float) -> float:
time = max(time, 0.0)
return 1.0/2.0 * _factor * time*time
func _calculate_time_by_offset(offset: float) -> float:
return sqrt(abs(offset) * 2.0 / _factor)

View File

@@ -0,0 +1 @@
uid://dvvc75dvopgcg

View File

@@ -0,0 +1,33 @@
extends ScrollDamper
class_name QuadScrollDamper
## Friction, not physical.
## The higher the value, the more obvious the deceleration.
@export_range(0.001, 10000.0, 0.001, "or_greater", "hide_slider")
var friction := 4.0:
set(val):
friction = max(val, 0.001)
_factor = pow(10.0, friction) - 1.0
## Factor to use in formula
var _factor := 10000.0:
set(val): _factor = max(val, 0.000000000001)
func _calculate_velocity_by_time(time: float) -> float:
if time <= 0.0: return 0.0
return time*time * _factor
func _calculate_time_by_velocity(velocity: float) -> float:
return sqrt(abs(velocity) / _factor)
func _calculate_offset_by_time(time: float) -> float:
time = max(time, 0.0)
return 1.0/3.0 * _factor * time*time*time
func _calculate_time_by_offset(offset: float) -> float:
return pow(abs(offset) * 3.0 / _factor, 1.0/3.0)

View File

@@ -0,0 +1 @@
uid://ccgjrqkk3oksk

View File

@@ -0,0 +1,74 @@
@icon("icon.svg")
extends Resource
class_name ScrollDamper
## Abstract class
## Rebound strength. The higher the value, the faster it attracts.
@export_range(0.0, 1.0, 0.001, "or_greater", "hide_slider")
var rebound_strength := 7.0:
set(val):
rebound_strength= max(val, 0.0)
_attract_factor = rebound_strength * rebound_strength * rebound_strength
## Factor for attracting.
var _attract_factor := 400.0:
set(val):
_attract_factor = max(val, 0.0)
# Abstract method
func _calculate_velocity_by_time(time: float) -> float:
return 0.0
# Abstract method
func _calculate_time_by_velocity(velocity: float) -> float:
return 0.0
# Abstract method
func _calculate_offset_by_time(time: float) -> float:
return 0.0
# Abstract method
func _calculate_time_by_offset(offset: float) -> float:
return 0.0
func _calculate_velocity_to_dest(from: float, to: float) -> float:
var dist = to - from
var time = _calculate_time_by_offset(abs(dist))
var vel = _calculate_velocity_by_time(time) * sign(dist)
return vel
func _calculate_next_velocity(present_time: float, delta_time: float) -> float:
return _calculate_velocity_by_time(present_time - delta_time)
func _calculate_next_offset(present_time: float, delta_time: float) -> float:
return _calculate_offset_by_time(present_time) \
- _calculate_offset_by_time(present_time - delta_time)
## Return the result of next velocity and position according to delta time
func slide(velocity: float, delta_time: float) -> Array:
var present_time = _calculate_time_by_velocity(velocity)
return [
_calculate_next_velocity(present_time, delta_time) * sign(velocity),
_calculate_next_offset(present_time, delta_time) * sign(velocity)
]
## Emulate force that attracts something to destination.
## Return the result of next velocity according to delta time
func attract(from: float, to: float, velocity: float, delta_time: float) -> float:
var dist = to - from
var target_vel = _calculate_velocity_to_dest(from, to)
velocity += _attract_factor * dist * delta_time \
+ _calculate_velocity_by_time(delta_time) * sign(dist)
if (
(dist > 0 and velocity >= target_vel) \
or (dist < 0 and velocity <= target_vel) \
):
velocity = target_vel
return velocity

View File

@@ -0,0 +1 @@
uid://bcy471w0pi8af