Smoothly interpolate between variations of SVG paths.

Overview

svg-path-morph

ci coverage size version

A simple library for morphing between variations of SVG paths. Use svg-path-morph to smoothly morph between X variations of the same SVG path (i.e. same commands, different values).

Installation

npm install svg-path-morph

Demo

its-morpin-time-2.mp4

See demo.html and src/demo.js for the implementation of the above demonstration

Usage

import { compile, morph } from 'svg-path-morph'


// Get the d attributes of the <path> elements you want to morph between
const happy = document.getElemenyById('happy').getAttribute('d')
const angry = document.getElemenyById('angry').getAttribute('d')

// Compile the morph base (average path embedding)
const compiled = compile([ 
  happy, 
  angry 
])

// Morph between the happy/angry faces
const slightlyAngry = morph(
  compiled,
  [
    0.80,  // 80% happy
    0.20   // 20% angry
  ]
)

// Use the face is the d attribute of a <path> element
document.getElementById('the-face').setAttribute('d', slightlyAngry)
You might also like...

📃 Typed primitives for Typescript to work with file paths

typed-file-system-path typed-file-system-path takes inspiration from Path.swift in swift-tools-support-core and provides typed primitives to work with

Dec 15, 2022

Cloud Native, DevOps, GitOps, Open Source, industry news, culture, and the 'ish between.

Cloud Native, DevOps, GitOps, Open Source, industry news, culture, and the 'ish between.

DevOps'ish DevOps'ish is authored by Chris Short and Made in Michigan. What is DevOps? I'm glad you asked. Newsletter Writing Process Everyone needs a

Jan 12, 2022

Babel plugin and helper functions for interoperation between Node.js native ESM and Babel ESM

babel-plugin-node-cjs-interop and node-cjs-interop: fix the default import interoperability issue in Node.js The problem to solve Consider the followi

Nov 6, 2022

DoMe is a ToDo App. you can add, delete and reorder elements of the todo list using drag and drop. You can also toggle between dark&light mode

DO ME Todo App Live Preview : DO ME Built With : - ReactJS - TailwindCSS Make sure you have: - Git - Nodejs version 14 or higher (we recommend using

Nov 18, 2022

JavaScript game for Rock Paper Scissors between player and bot

rock-paper-scissors-game JavaScript game for Rock Paper Scissors between player and bot Try it here! : https://rock-paper-scissors-221ef.web.app/ V1.1

Feb 10, 2022

Heliaia - a proxy that sits between your wallet and a node🧑‍⚖️

Heliaia Heliaia is a proxy that sits between your wallet and a node, with the sole purpose to intercept transactions before they are broadcasted. Tran

Oct 26, 2022

enables communication between command-line or desktop applications and browser-based Ethereum wallets such as Metamask.

@securerpc/walletbus @securerpc/walletbus Abstract Quickstart Installation Usage Ethers.js Web3.js Configuration options Logging Development Automated

Dec 27, 2022

Differences between Node + Koa and Deno + Oak

Node + Koa VS Deno + Oak Differences between Node + Koa and Deno + Oak About This is a project that aims to observe the differences between a simple R

Jun 28, 2022
Comments
  • Delete settings.json

    Delete settings.json

    To get the code coverage, change <BRANCH_NAME> to the --separated branch name, e.g. feature/added-hooks --> feature-added-hooks

    Coverage Badge

    Description

    Delete settings.json

    Motivation and Context

    less content created

    Related Issue

    https://github.com/Minibrams/svg-path-morph/issues/1

    How Has This Been Tested?

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have read the contribution guidelines document.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ThiagoYuri 0
Owner
Anders Brams
MSc. Software Engineering, machine learning enthusiast, and published researcher working as a software engineer at Ambolt.
Anders Brams
A plugin that can find the paths between two notes. Not sure who will want to use it...

Obsidian Path Finder Plugin Install BRAT Install Obsidian42-BRAT plugin. Click Add new beta plugin and fill in jerrywcy/obsidian-path-finder. Activate

jerrywcy 29 Dec 31, 2022
Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves.

svg-to-flutter-path-converter Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves. Flutter Clutter The tool

null 30 Jan 2, 2023
A Tailwind plugin that allows to create multiple groups utilities such as group-card or group-1 and works with Tailwind 3 features and all variations.

Tailwind Labeled Groups A plugin that allows to create multiple groups utilities such as group-card or group-1 and works with Tailwind 3 features and

Max 18 Nov 21, 2022
Freeze variations and features in font.

FontFreeze Freeze variations and features in font. Introduction Modern OpenType fonts support variations and features that allow customizable fonts. T

Mu-Tsun Tsai 24 Jan 6, 2023
🍎Transform an SVG icon into multiple themes, and generate React icons,Vue icons,svg icons

IconPark English | 简体中文 Introduction IconPark gives access to more than 2000 high-quality icons, and introduces an interface for customizing your icon

Bytedance Inc. 6.8k Jan 5, 2023
A Javascript library to export svg charts from the DOM and download them as an SVG file, PDF, or raster image (JPEG, PNG) format. Can be done all in client-side.

svg-exportJS An easy-to-use client-side Javascript library to export SVG graphics from web pages and download them as an SVG file, PDF, or raster imag

null 23 Oct 5, 2022
To keep online organized data and be able to add listeners in certain paths by socket.io and http clients

The purpose of this project is to create a state machine server to keep organized data and be able to add listeners with socket.io in specific paths and in addition to providing a possible form of messages between socket.io clients.

Manga 3 Mar 19, 2022
🤠 Functional utilities using object property paths with wildcards and regexps 🌵

?? Functional utilities using object property paths with wildcards and regexps. ?? Available functional methods include: ??️ Mapping: map() ?? Merging

ehmicky 29 Dec 15, 2022
🤠 Object property paths with wildcards and regexps 🌵

?? Object property paths with wildcards and regexps. ?? Get/set object properties using: ⛏️ Dot-delimited paths: foo.bar.0.baz ⭐ Wildcards: foo.*, **.

ehmicky 585 Jan 3, 2023
A webpack plugin to enforce case-sensitive paths when resolving module

@umijs/case-sensitive-paths-webpack-plugin A webpack plugin to enforce case-sensitive paths when resolving module, similar to the well-known case-sens

UmiJS 13 Jul 25, 2022