Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to override 'pixel is inside'-test #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

usefulthink
Copy link
Owner

a new option isInside can be used to specify a function that is called instead of the default inside-function to determine if the given coordinate is considered inside the shape. This can be useful for images that only vary in their opacity but are otherwise completely black.

As this is the only place where the source-image is actually accessed it can also be used to support ndarrays with shapes like [width, height, 1].

Example:

var sourceImage = ndarray(imageData, [width, height, 4])
var output = sdf(sourceImage, { 
  spread: 5, 
  downscale: 1,
  isInside: function(array, x, y)  { 
    return array.get(x,y,3) > 128; 
  }
})

a new option `isInside` can be used to specify a function that is called instead of the default `inside`-function to determine if the given coordinate is considered inside the shape. This can be useful for images that only vary in their opacity but are otherwise completely black. 

As this is the only place where the source-image is actually accessed it can also be used to support ndarrays with shapes like `[width, height, 1]`.

Example:

```javascript

sourceImage = ndarray(imageData, [width, height, 4]);
var output = sdf(sourceImage, { isInside: function(array, x, y)  { return array.get(x,y,3) > 128; }}

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant