Skip to main content

occult

vpype plug-in to remove lines occulted by polygons from SVG files.

Examples

Basic usage

Draw a line, then a square:

vpype line 0 0 5cm 5cm rect 2cm 2cm 1cm 1cm show

Same drawing, after applying occult:

vpype line 0 0 5cm 5cm rect 2cm 2cm 1cm 1cm occult show

Order of path is important: occult will consider the last geometry in a SVG file to be "on top" of all other geometries, the last but one is above every other geometries except the last one. For instance, using vpype rect 2cm 2cm 1cm 1cm occult show will not modify geometries.

Working with multiple layers

By default, occult performs occlusion layer by layer. For instance, applying occlusion on the image below will not change anything:

occult -i ignores layers, so that occlusion is performed on all objects, regardless of their layer. Geometries in layers with a larger ID number are considered to be "on top" of geometries in layers with a smaller ID number.

  • Without -i flag
  • With -i flag

occult -a only performs occlusions across layers, ignoring occlusions that occur within a layer. As in occult -i, geometries in layers with a larger ID number are considered to be "on top" of geometries in layers with a smaller ID number. This option overrides -i.

  • Without -a or -i flags
  • With -i flag
  • With -a flag

Save occulted lines

occult -k keeps occulted lines in a separate layers.

  • Without -k flag
  • With -k flag

Using vpype's viewer (show command), you can visualize occulted lines and remaining lines separately.

Using occult with Vsketch

occult can be invoked from a Vksetch sketch, using vsk.vpype("occult"). When using the GUI, calling occult within the sketch draw() method will display occulted geometries at each code save / seed change. For sketches with lots of geometries, occlusion can take a significant amount of time. Invoke occult within the finalize() method of a sketch to perform occlusion only when saving a specific output.

import vsketch

class Sketch(vsketch.SketchClass):
    def draw(self, vsk: vsketch.Vsketch):
        vsk.size('10x10cm')
        vsk.scale('mm')
        
        vsk.line(-5, -5, 5, 5)
        vsk.circle(0, 0, 3)

        # Uncomment to perform occlusion at every GUI reload
        # vsk.vpype("occult")
  
    def finalize(self, vsk: vsketch.Vsketch) -> None:
        # Occlusion (and other vpype commands) invoked only when saving
        vsk.vpype("linesimplify occult linemerge linesort")


if __name__ == "__main__":
    Sketch.display()

Installation

See the installation instructions for information on how to install vpype.

Existing vpype installation

If vpype was installed using pipx, use the following command:

$ pipx inject vpype vpype-occult

If vpype was installed using pip in a virtual environment, activate the virtual environment and use the following command:

$ pip install vpype-occult

Check that your install is successful:

$ vpype --help
Usage: vpype [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...

Options:
  -v, --verbose
  -I, --include PATH  Load commands from a command file.
  --help              Show this message and exit.

Commands:
[...]
  Plugins:
    occult
[...]

Stand-alone installation

Use this method if you need to edit this project. First, clone the project:

$ git clone https://github.com/LoicGoulefert/occult.git
$ cd occult

Create a virtual environment:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip

Install occult and its dependencies (including vpype):

$ pip install -e .

Check that your install is successful:

$ vpype --help
Usage: vpype [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...

Options:
  -v, --verbose
  -I, --include PATH  Load commands from a command file.
  --help              Show this message and exit.

Commands:
[...]
  Plugins:
    occult
[...]

Documentation

The complete plug-in documentation is available directly in the CLI help:

$ vpype occult --help

License

See the LICENSE file for details.

Metadata

Release files for vpype-occult 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vpype-occult 0.4.0
File Size Uploaded Provenance Actions
vpype-occult-0.4.0.tar.gz 7.2 kB Without provenance Details for vpype-occult-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vpype-occult 0.4.0
File Interpreter ABI Platform Actions
vpype_occult-0.4.0-py3-none-any.whl Python 3 none any Details for vpype_occult-0.4.0-py3-none-any.whl

Total release size: 14.6 kB

Release files / vpype-occult-0.4.0.tar.gz

Download URL vpype-occult-0.4.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d424c1c5915c7c1183ac5702eccdec0a2232bd22f0f0db6b442daaed7014afe5
BLAKE2b-256 checksum
How to use checksums
871f09d174242d7db35f99514898a5491ff5673558109fa81a37a9715d775a10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release files / vpype_occult-0.4.0-py3-none-any.whl

Download URL vpype_occult-0.4.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ed3348430470d629049508114432c60f5296878d5393f052238e092cf6544b4
BLAKE2b-256 checksum
How to use checksums
61157b1ac7987835405cb34501193352f4444297ba0deacf2e01fd138a818123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Security for vpype-occult 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page