The Field Agent requires a pure black and white bitmap as input (e.g., a PNG exported from a vector image).
- Foreground (the object): Must be pure black.
- Background: Can be white or transparent.
Basic Usage
To convert an input file to an output distance field texture at the same resolution:
ruby field_agent.rb input.png output.png
Controlling Quality and Scale
You can use --quality and --scale to manage resolution and sharpness:
--quality <number>: Scales the input up by this factor (e.g., --quality 4 scales the input to 400% before processing).--scale <number>: Scales the resulting distance field down by this factor (e.g., --scale 0.25 scales the result to 25% of the input resolution).- Combining both: You can combine these for high-quality results (e.g., scaling up then down).
Controlling Edge Blurriness (Spread)
The --spread <pixels> option defines the width of the blurry ribbon around the original edges. The value is in pixels of the output image. The default is 8.
ruby field_agent.rb input.png output.png --spread 6
Summary of CLI Options
Run the script without arguments to see all supported options, which include trimming the texture to the optimal size and inverting colors.
ruby field_agent.rb input.png output.png --quality 4
ruby field_agent.rb input.png output.png --scale 0.25
ruby field_agent.rb input.png output.png --quality 2 --scale 0.25
ruby field_agent.rb input.png output.png --scale 0.25 --spread 6