Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/split-cube-studios/silk

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/split-cube-studios/silk

  • v0.1.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

Go Reference SCS - Engineering

Silk

Silk is an N-dimensional implementation of the wave function collapse algorithm. This utility was largely inspired by the work of Maxim Gumin and his WaveFunctionCollapse repository.

Silk aims not only to provide a flexible implementation of the algorithm, but also provide out-of-the-box for some common data types/use-cases. Currently Silk only supports generating 2D images, but a user is able to implement their own silk.Shuttle for other data types/dimensions.

Silk CLI

Silk comes with a CLI that can use the provided silk.Shuttle implementations to generate outputs. The CLI can be installed with:

go install github.com/split-cube-studios/silk/cmd/silk

Below is the output of silk help:

NAME:
   silk - Generate procedural data with wave function collapse.

USAGE:
   silk [global options] command [command options] [arguments...]

COMMANDS:
   image    Generate an image.
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h    show help (default: false)
   --seed value  Seed value for the random number generator. (default: 1665169812)

Silk uses subcommands for different datatypes, which each may have different flags. See silk help <command> for more information.

Silk API

Silk can also be used as a library. The silk package provides the core functionality of the algorithm, while the silk/pkg/shuttle package provides some common implementations of the silk.Shuttle interface.

Below is an example of using Silk to generate a 2D image:

package main

import (
    "image"
    "image/color"
    "image/png"
    "os"

    "github.com/split-cube-studios/silk"
    "github.com/split-cube-studios/silk/pkg/shuttle"
)

func main() {

    f, err := os.Open("input.png")
    if err != nil {
        panic(err)
    }
    defer f.Close()

    img, _, err := image.Decode(f)
    if err != nil {
        panic(err)
    }
    
    size := 128
    loom := silk.NewLoom(
        []int{size, size},
        shuttle.NewImageShuttle(
            img,
            shuttle.ImageShuttleOptions{
				W: size,
				H: size,
			},
        ),
    )

    if err := loom.Weave(); err != nil {
        panic(err)
    }
}

Samples

CommandInputOutput (Progression)Output (Final)
silk image --input ./samples/lines.png -a -r xyInputOutputOutput
silk image --input ./samples/island.png -a -r xInputOutputOutput

Contributing

Contributions are welcome! Contribution guides are coming soon.

FAQs

Package last updated on 07 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc