npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paperjs-offset-core

v1.0.10

Published

An offset function for paperjs paths when using paper-core.js

Downloads

100

Readme

Paperjs Offset Core

A fork from the excellent work made in paperjs-offset (Thanks!). The difference is to be able to provide a PaperScope to the offsetting functionality in case you need to work with paper-core.js directly from paper/dist/paper-core. Current use case is when using paper-core.js and working with paperjs using javascript with a bundler included. Could perhaps also be useful when working with multiple paperjs scopes. Other changes includes:

  • Removed deprecated ExtendPaperJs functionality.
  • Removed window global

Under development. Not tested for use in Node.js, only in browser.

Background from original paperjs-offset, 2016-2019


The dicussion to implement a offset function in paper.js started years ago, yet the author have not decided to put a offset feature into the library. So I implement an extension of my own. As far as I know, the author has promised recently to implement a native offset functionality in near feature, the library will be closed once the native implement is published. This library implement both path offset and stroke offset, you may offset a path or expand a stroke like what you did in Adobe illustrator. Offset complicate path may cause unwanted self intersections, this library already take care some cases but bugs still exists. Please let me notice the false conditions in the issue pannel so I can correct it.


Usage

Installation

npm install paperjs-offset-core

And then, in your project:

import paper from 'paper/dist/paper-core' // if using bundlers otherwise skip and include in <script>. See demo dir.
import { PaperOffset } from 'paperjs-offset'
// Optionally setup paper
let canvas = document.querySelector('canvas')
paper.setup(canvas)
paper.view.center = [0, 0]

const offsetOptions = {
  scope: paper
  // ...other options
}
let path = new paper.Path(/* params */)
// call offset
PaperOffset.offset(path, offset, offsetOptions)

// call offset stroke
PaperOffset.offsetStroke(path, offset, offsetOptions)

Sample references:

offset(path: paper.Path | paper.CompoundPath, offset: number, options?: OffsetOptions): paper.Path | paper.CompoundPath

offsetStroke(path: paper.Path | paper.CompoundPath, offset: number, options?: OffsetOptions): paper.Path | paper.CompoundPath

interface OffsetOptions {
  // the join style of offset path, default is 'miter'
  join?: 'miter' | 'bevel' | 'round';
  // the cap style of offset (only validate for offsetStroke), default is 'butt', ('square' will be supported in future)
  cap?: 'butt' | 'round';
  // the limit for miter style (refer to the miterLimit definition in paper)
  limit?: number;
  // whether the result should be insert into the canvas, default is true
  insert?: boolean;
  // reference to the PaperScope
  scope: paper.PaperScope
}

Preview

You can use open demo folder for simple cases demonstration.

License

Distributed under the MIT license.