signed_distance_fields

Crates.iosigned_distance_fields
lib.rssigned_distance_fields
version1.0.6
sourcesrc
created_at2022-10-08 08:42:46.954791
updated_at2022-10-10 07:13:27.582409
descriptionA implementation of SDFs (signed distance fields) and some operators to play with these SDFs
homepage
repositoryhttps://github.com/MAA28/Signed-Distance-Fields
max_upload_size
id683410
size367,892
(MAA28)

documentation

README

Signed Distance Fields

github crates.io docs.rs

You can combine, transform and even develop completly new SDFs that can be rendered with one of this libraries multiple renderes

Examples

Primitives

$ cargo run --example primitives
Circle:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                              ++++++++                                              
                                     ++++++++++++++++++++++++++                                     
                                +++++++----------------------+++++++                                
                             +++++-------                  -------+++++                             
                          ++++-----                              -----++++                          
                       ++++----                                      ----++++                       
                     ++++----                                          ----++++                     
                   ++++---                                                ---++++                   
                  +++---                                                    ---+++                  
                 +++---                                                      ---+++                 
               +++---                                                          ---+++               
              +++---                                                            ---+++              
             +++---                                                              ---+++             
             ++---                                                                ---++             
            +++--                                                                  --+++            
           +++---                                                                  ---+++           
           +++--                                                                    --+++           
           ++---                                                                    ---++           
           ++--                                                                      --++           
          +++--                                                                      --+++          
          +++--                                                                      --+++          
           ++--                                                                      --++           
           ++---                                                                    ---++           
           +++--                                                                    --+++           
           +++---                                                                  ---+++           
            +++--                                                                  --+++            
             ++---                                                                ---++             
             +++---                                                              ---+++             
              +++---                                                            ---+++              
               +++---                                                          ---+++               
                 +++---                                                      ---+++                 
                  +++---                                                    ---+++                  
                   ++++---                                                ---++++                   
                     ++++----                                          ----++++                     
                       ++++----                                      ----++++                       
                          ++++-----                              -----++++                          
                             +++++-------                  -------+++++                             
                                +++++++----------------------+++++++                                
                                     ++++++++++++++++++++++++++                                     
                                              ++++++++                                              
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Rectangle:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                              ++++++++++++++++++++++++++++++++++++++++                              
                              +--------------------------------------+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +--------------------------------------+                              
                              ++++++++++++++++++++++++++++++++++++++++                              
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Line:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
             ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
             ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++             
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Straight:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Plane:
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************

Operators

Transform

$ cargo run --example operators_transform
None:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                              ++++++++++++++++++++++++++++++++++++++++                              
                              +--------------------------------------+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +---                                ---+                              
                              +--------------------------------------+                              
                              ++++++++++++++++++++++++++++++++++++++++                              
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Translate:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
      +++++++++++++++++++++++++++++++++++++++                                                       
     ++-------------------------------------+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       
     ++--                                ---+                                                       

Rotate:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                               ++                   
                                                                        +++++----+                  
                                                                  ++++-----------++                 
                                                           ++++---------       ---+                 
                                                    ++++---------               --++                
                                             ++++---------                      ---+                
                                      +++++--------                              ---+               
                               +++++---------                                     --++              
                         ++++---------                                            ---+              
                  ++++---------                                                    --++             
           ++++---------                                                           ---+             
        +--------                                                                   ---+            
         +--                                                                         --++           
         +---                                                                        ---+           
          +---                                                                        --++          
          ++--                                                                        ---+          
           +---                                                                        ---+         
           ++--                                                                         --+         
            +---                                                                   --------+        
             +---                                                           ---------++++           
             ++--                                                    ---------++++                  
              +---                                            ---------++++                         
              ++--                                     ---------+++++                               
               +---                              --------+++++                                      
                +---                      ---------++++                                             
                ++--               ---------++++                                                    
                 +---       ---------++++                                                           
                 ++-----------++++                                                                  
                  +----+++++                                                                        
                   ++                                                                               
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Scale:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
          +++-----                                                                -----+++          
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Matrix:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
  ++-+++++                                                                                          
     +--   --------++++                                                                             
       +---             --------++++                                                                
         +---                         --------+++                                                   
           ++--                                ---+                                                 
              +--                                ---+                                               
                +--                                 --+                                             
                  +---                                --++                                          
                    +---                                ---+                                        
                      ++--                                ---+                                      
                         +--                                 --+                                    
                           +---                                --+                                  
                             +---                                --++                               
                               ++--                                ---+                             
                                  +--                                ---+                           
                                    +--                                 --+                         
                                      +---                                --++                      
                                        +---                                ---+                    
                                          ++--                                ---+                  
                                             +--                                 --+                
                                               +---                                --+              
                                                 +---                                --++           
                                                   +++--------                         ---+         
                                                                ++++--------             ---+       
                                                                             ++++--------   --+     
                                                                                          +++++-++  
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

Boolean

$ cargo run --example operators_boolean
a:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                        ++++++++++++++++++++                                        
                                    +++++------------------+++++                                    
                                 ++++------              ------++++                                 
                               +++-----                      -----+++                               
                             +++----                            ----+++                             
                           +++----                                ----+++                           
                          +++---                                    ---+++                          
                         +++---                                      ---+++                         
                        +++---                                        ---+++                        
                        ++---                                          ---++                        
                       +++--                                            --+++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       +++--                                            --+++                       
                        ++---                                          ---++                        
                        +++---                                        ---+++                        
                         +++---                                      ---+++                         
                          +++---                                    ---+++                          
                           +++----                                ----+++                           
                             +++----                            ----+++                             
                               +++-----                      -----+++                               
                                 ++++------              ------++++                                 
                                    +++++------------------+++++                                    
                                        ++++++++++++++++++++                                        
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

b:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
            ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++            
            +--------------------------------------------------------------------------+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--------------------------------------------------------------------------+            
            ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++            
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

a ∪ b:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                        ++++++++++++++++++++                                        
                                    +++++------------------+++++                                    
                                 ++++------              ------++++                                 
                               +++-----                      -----+++                               
                             +++----                            ----+++                             
                           +++----                                ----+++                           
            +++++++++++++++++---                                    ---+++++++++++++++++            
            +------------------                                      ------------------+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +--                                                                      --+            
            +------------------                                      ------------------+            
            +++++++++++++++++---                                    ---+++++++++++++++++            
                           +++----                                ----+++                           
                             +++----                            ----+++                             
                               +++-----                      -----+++                               
                                 ++++------              ------++++                                 
                                    +++++------------------+++++                                    
                                        ++++++++++++++++++++                                        
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

a ∩ b:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                          ++++++++++++++++++++++++++++++++++++++++++++++++                          
                         +++--------------------------------------------+++                         
                        +++---                                        ---+++                        
                        ++---                                          ---++                        
                       +++--                                            --+++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       ++---                                            ---++                       
                       +++--                                            --+++                       
                        ++---                                          ---++                        
                        +++---                                        ---+++                        
                         +++--------------------------------------------+++                         
                          ++++++++++++++++++++++++++++++++++++++++++++++++                          
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    

a\b:
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
            --------------------                                    --------------------            
            -+++++++++++++++---                                      ---+++++++++++++++-            
            -++         +++---                                        ---+++         ++-            
            -++         ++---                                          ---++         ++-            
            -++        +++--                                            --+++        ++-            
            -++        ++---                                            ---++        ++-            
            -++        ++---                                            ---++        ++-            
            -++        ++---                                            ---++        ++-            
            -++        ++---                                            ---++        ++-            
            -++        +++--                                            --+++        ++-            
            -++         ++---                                          ---++         ++-            
            -++         +++---                                        ---+++         ++-            
            -+++++++++++++++---                                      ---+++++++++++++++-            
            --------------------                                    --------------------            
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
Commit count: 26

cargo fmt