项目作者: x8BitRain

项目描述 :
SVG and Emoji Corrupter built in React
高级语言: SCSS
项目地址: git://github.com/x8BitRain/svg-emoji-corrupt.git
创建时间: 2019-10-11T00:57:39Z
项目社区:https://github.com/x8BitRain/svg-emoji-corrupt

开源协议:

下载


icon

SVG/Emoji Corrupter

https://x8bitrain.github.io/svg-emoji-corrupt/

Feed it an emoji or an SVG file and the corrupter will target the numbers you specify inside the d=”” paths of the SVG
and replaces them with a random number between whatever you set in the “replace with” slider. Why not?

TODO

  • Add an emoji merge feature.

Adding Custom Corrupter functions

Two methods are exposed to the window object for adding and getting corruption functions.

Getting all corruption functions:

  1. window.getCorrupters()

Adding a custom function:

  1. window.addCorrupter({
  2. id: "multiply",
  3. name: "Multiply",
  4. active: true,
  5. description: "Multiply the target values by the selected value",
  6. function: (
  7. pathData,
  8. search,
  9. value,
  10. node
  11. ) => {
  12. return pathData.replace(search, (match) =>
  13. String(Math.trunc(Number(match) * Number(value))),
  14. );
  15. },
  16. });

Explanation:

This function is called for each found <path> node in the SVG. The function must return pathData (modified or not)
otherwise the SVG will disappear.

  1. function: (
  2. pathData: string, // The raw `d` attribute value, i.e. "d="M361.794,351.072c2...."
  3. search: RegExp, // The regular expression containing the selected target values, i.e. `/1|2|3|4|5/gi`
  4. value: string, // The current value of the slider, i.e. 5
  5. node: SVGPathElement // The entire SVG path node, you could add any attribute or class this way.
  6. ) => {}

All of the corruption functions are stored in the corruptions.ts object in src/utils/corruptions.ts. Feel free to
open a PR to add your own!

Made with

FAQ

Development

  1. git clone https://github.com/x8BitRain/svg-emoji-corrupt.git
  2. cd svg-emoji-corrupt/
  3. bun install
  1. bun dev

Development

  1. bun build