TNT-Weekly icon indicating copy to clipboard operation
TNT-Weekly copied to clipboard

【开源自荐】Pictode-最方便集成的绘图编辑器

Open JessYan0913 opened this issue 2 years ago • 0 comments

推荐项目

  • 项目地址:https://github.com/JessYan0913/pictode
  • 类别:JS
  • 项目标题:Pictode-最方便集成的绘图编辑器
  • 项目描述:

Pictode是一个基于Konva.js开发的绘图编辑器框架,具备流畅的交互体验,面向开发者提供友好的集成方式和可扩展特点。

也许你已经在网上看到许多技术大咖分享如何实现画板或图片编辑器的方法。他们或许详细解释了编辑器的原理和代码实现,有些甚至直接使用原生Canvas构建编辑器。但你是否和我有相同的感受?

我们既敬佩技术大咖,又感到自己阅读后除了感叹:“🐮🍺!”外收获很少。原因在于我们无法将他们的代码应用到项目中。虽然阅读、点赞和收藏了这些文章,但仍感头脑空空,实际收获有限。

把图形编辑器嵌入自己的项目,有时真麻烦。比如,编辑器用React构建,你的项目用Vue;或者编辑器不够灵活。

Pictode就是你的救星,像🚀一样,解决这些问题,让你事半功倍。

  • 亮点:基于Konva.js库、方便集成、可自定义工具、可自定义插件、与UI框架无关

  • 示例代码:

Pictode offers various plugins to cater to diverse needs.

Edit pictode

🕒 History Plugin

  1. Install the @pictode/plugin-history dependency.
npm install @pictode/plugin-selector
  1. Instantiate the historyPlugin plugin.
import { HistoryPlugin } from '@pictode/plugin-history';

const historyPlugin = new HistoryPlugin();
  1. Use the app.use(historyPlugin) method to load the plugin.
app.use(historyPlugin);
  1. You can now implement undo and redo functionality with the app.undo() and app.redo() methods.

✅ Selector Plugin

  1. Install the @pictode/plugin-selector dependency.
npm install @pictode/plugin-selector
  1. Instantiate the selectorPlugin plugin.
import { SelectorPlugin } from '@pictode/plugin-selector';

const selectorPlugin = new SelectorPlugin();
  1. Use the app.use(selectorPlugin) method to load the plugin.
app.use(selectorPlugin);
  1. Implement selecting and deselecting shapes using mouse clicks or the app.select(...) and app.cancelSelect(...) methods. Hold down the Shift key to enable multi-selection and deselection.

🔄 Alignment Tools

  1. Install the @pictode/plugin-alignment dependency.
npm install @pictode/plugin-selector
  1. Instantiate the alignmentPlugin plugin.
import { AlignmentPlugin } from '@pictode/plugin-alignment';

const alignmentPlugin = new AlignmentPlugin();
  1. Use the app.use(alignmentPlugin) method to load the plugin.
app.use(alignmentPlugin);
  1. You can now perform alignment operations using a range of methods, including app.alignTop, app.alignRight, app.alignBottom, app.alignLeft, app.alignCenterX, app.alignCenterY, and more.

  2. Additionally, use app.distributeX and app.distributeY methods to achieve horizontal and vertical distribution.

  • 截图:

效果图

  • 后续更新计划:

v1.0.0

v2.0.0

v3.0.0

JessYan0913 avatar Oct 20 '23 03:10 JessYan0913