Crates.io | signed_distance_fields |
lib.rs | signed_distance_fields |
version | 1.0.6 |
source | src |
created_at | 2022-10-08 08:42:46.954791 |
updated_at | 2022-10-10 07:13:27.582409 |
description | A implementation of SDFs (signed distance fields) and some operators to play with these SDFs |
homepage | |
repository | https://github.com/MAA28/Signed-Distance-Fields |
max_upload_size | |
id | 683410 |
size | 367,892 |
You can combine, transform and even develop completly new SDFs that can be rendered with one of this libraries multiple renderes
$ cargo run --example primitives
Circle:
++++++++
++++++++++++++++++++++++++
+++++++----------------------+++++++
+++++------- -------+++++
++++----- -----++++
++++---- ----++++
++++---- ----++++
++++--- ---++++
+++--- ---+++
+++--- ---+++
+++--- ---+++
+++--- ---+++
+++--- ---+++
++--- ---++
+++-- --+++
+++--- ---+++
+++-- --+++
++--- ---++
++-- --++
+++-- --+++
+++-- --+++
++-- --++
++--- ---++
+++-- --+++
+++--- ---+++
+++-- --+++
++--- ---++
+++--- ---+++
+++--- ---+++
+++--- ---+++
+++--- ---+++
+++--- ---+++
++++--- ---++++
++++---- ----++++
++++---- ----++++
++++----- -----++++
+++++------- -------+++++
+++++++----------------------+++++++
++++++++++++++++++++++++++
++++++++
Rectangle:
++++++++++++++++++++++++++++++++++++++++
+--------------------------------------+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--------------------------------------+
++++++++++++++++++++++++++++++++++++++++
Line:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Straight:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Plane:
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
$ cargo run --example operators_transform
None:
++++++++++++++++++++++++++++++++++++++++
+--------------------------------------+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--- ---+
+--------------------------------------+
++++++++++++++++++++++++++++++++++++++++
Translate:
+++++++++++++++++++++++++++++++++++++++
++-------------------------------------+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
++-- ---+
Rotate:
++
+++++----+
++++-----------++
++++--------- ---+
++++--------- --++
++++--------- ---+
+++++-------- ---+
+++++--------- --++
++++--------- ---+
++++--------- --++
++++--------- ---+
+-------- ---+
+-- --++
+--- ---+
+--- --++
++-- ---+
+--- ---+
++-- --+
+--- --------+
+--- ---------++++
++-- ---------++++
+--- ---------++++
++-- ---------+++++
+--- --------+++++
+--- ---------++++
++-- ---------++++
+--- ---------++++
++-----------++++
+----+++++
++
Scale:
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
+++----- -----+++
Matrix:
++-+++++
+-- --------++++
+--- --------++++
+--- --------+++
++-- ---+
+-- ---+
+-- --+
+--- --++
+--- ---+
++-- ---+
+-- --+
+--- --+
+--- --++
++-- ---+
+-- ---+
+-- --+
+--- --++
+--- ---+
++-- ---+
+-- --+
+--- --+
+--- --++
+++-------- ---+
++++-------- ---+
++++-------- --+
+++++-++
$ cargo run --example operators_boolean
a:
++++++++++++++++++++
+++++------------------+++++
++++------ ------++++
+++----- -----+++
+++---- ----+++
+++---- ----+++
+++--- ---+++
+++--- ---+++
+++--- ---+++
++--- ---++
+++-- --+++
++--- ---++
++--- ---++
++--- ---++
++--- ---++
+++-- --+++
++--- ---++
+++--- ---+++
+++--- ---+++
+++--- ---+++
+++---- ----+++
+++---- ----+++
+++----- -----+++
++++------ ------++++
+++++------------------+++++
++++++++++++++++++++
b:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+--------------------------------------------------------------------------+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+--------------------------------------------------------------------------+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a ∪ b:
++++++++++++++++++++
+++++------------------+++++
++++------ ------++++
+++----- -----+++
+++---- ----+++
+++---- ----+++
+++++++++++++++++--- ---+++++++++++++++++
+------------------ ------------------+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+-- --+
+------------------ ------------------+
+++++++++++++++++--- ---+++++++++++++++++
+++---- ----+++
+++---- ----+++
+++----- -----+++
++++------ ------++++
+++++------------------+++++
++++++++++++++++++++
a ∩ b:
++++++++++++++++++++++++++++++++++++++++++++++++
+++--------------------------------------------+++
+++--- ---+++
++--- ---++
+++-- --+++
++--- ---++
++--- ---++
++--- ---++
++--- ---++
+++-- --+++
++--- ---++
+++--- ---+++
+++--------------------------------------------+++
++++++++++++++++++++++++++++++++++++++++++++++++
a\b:
-------------------- --------------------
-+++++++++++++++--- ---+++++++++++++++-
-++ +++--- ---+++ ++-
-++ ++--- ---++ ++-
-++ +++-- --+++ ++-
-++ ++--- ---++ ++-
-++ ++--- ---++ ++-
-++ ++--- ---++ ++-
-++ ++--- ---++ ++-
-++ +++-- --+++ ++-
-++ ++--- ---++ ++-
-++ +++--- ---+++ ++-
-+++++++++++++++--- ---+++++++++++++++-
-------------------- --------------------