@machete-jhun/canvas-studio 0.0.1 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -75
- package/dist/constants-CHIlz4uF.js +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +25 -25
- package/dist/utils/index.js +1 -0
- package/dist/utils/shapeTools.js +1 -0
- package/dist/utils-DrbTlu3h.js +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,i as a,n as o,o as r,r as t,s as i,t as m}from"../utils-DrbTlu3h.js";export{m as assertNever,o as complementaryHexColor,t as getPointerPosition,a as getStageCenter,s as getStageViewPortCenter,r as getVector2Position,i as isMac};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as t,o as e}from"../constants-CHIlz4uF.js";import{nanoid as i}from"nanoid";var a=()=>({id:i(),width:void 0,scaleX:1,scaleY:1,rotation:0,visible:!0,displayName:"shape",opacity:1});const n=t=>({...t,id:i()}),r=(e,i,n,r,o,s=0,d=0,l="")=>{const c=a();return l&&(c.id=l),{...c,type:t.TEXT,x:s,y:d,letterSpacing:0,text:e,lineHeight:1,fontSize:i,fontStyle:"normal",textDecoration:"",fontFamily:n,fontId:`${r}`,fill:"#000",align:"left",displayName:e,name:"c1",info:{fontUrl:o}}},o=(e,i,n,r="",o=0,s=0,d=0,l=0)=>{const c=a();return r&&(c.id=r),{type:t.IMAGE,...c,imageName:i,x:o,y:s,width:d,height:l,imageSource:e,displayName:n,name:"c1"}},s=(e=0,i=0,n=0,r=0,o="",s="transparent",d=0,l="transparent")=>{const c=a();return o&&(c.id=o),{type:t.RECT,...c,x:e,y:i,width:n,height:r,fill:s,stroke:l,strokeWidth:d,name:"c1"}},d=(e,i,n,r=0,o=0,s=0,d=0,l="")=>{const c=a();return l&&(c.id=l),{type:t.SVG,...c,url:e,colors:n,displayName:i,x:r,y:o,width:s,height:d,name:"c1"}},l=(e,i,n=0,r=0,o=100,s=100,d="")=>{const l=a();return d&&(l.id=d),{type:t.QR_CODE,...l,source:e,displayName:i,x:n,y:r,width:o,height:s,margin:0,errorCorrectionLevel:"M",dark:"#000000",light:"#ffffff",name:"c1"}},c=(e,i,n=0,r=0,o=200,s=100,d="")=>{const l=a();return d&&(l.id=d),{type:t.BAR_CODE,...l,source:e,displayName:i,x:n,y:r,width:o,height:s,displayValue:!0,background:"#ffffff",lineColor:"#000000",margin:10,barType:"CODE128",name:"c1"}},y=(e,i,n,r=0,o=0,s=0,d=0,l="",c,y,p)=>{const h=a();return l&&(h.id=l),{type:t.RIVE,...h,url:e,stateMachine:i,artboard:p,displayName:n,x:r,y:o,width:s,height:d,inputs:c,name:"c1",variableObj:y}},p=(e,i,n=0,r=0,o=0,s=0,d="")=>{const l=a();return d&&(l.id=d),{type:t.VIDEO,...l,url:e,displayName:i,x:n,y:r,width:o,height:s,name:"c1"}},h=(e,n,r,o,s,d,l,c=i())=>{const y=a();return c&&(y.id=c),{type:t.BACK_SCREEN,...y,screenId:e,displayName:n,x:o,y:s,width:d,height:l,fill:r,name:"c1"}};function m(e){return e.type===t.TEXT}function f(e){return e.type===t.IMAGE}export{n as copyShape,h as createBackScreen,c as createBarCode,o as createImage,l as createQrCode,s as createRect,y as createRive,d as createSvg,r as createText,p as createVideo,f as isImgShape,m as isTextShape};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(){return/macintosh|mac os x/i.test(window.navigator.userAgent)}function e(t){throw new Error(`Unexpected object: ${t}`)}const n=t=>{let e="#";for(let n=0;n<3;n++)e+=(255-Number(`0x${t.slice(2*n+1,2*n+3)}`)).toString(16).padStart(2,"0");return e};function s(t,e){const{x:n,y:s}=t.position(),o=t.scaleX();return{x:(e.x-n)/o,y:(e.y-s)/o}}function o(t){return s(t.currentTarget,{x:t.evt.offsetX,y:t.evt.offsetY})}function r(t,e=0,n=0){return{x:(t.width()+e+t.offsetX())/t.scaleX()/2,y:(t.height()+n+t.offsetY())/t.scaleY()/2}}function a({stage:t,offsetWidth:e=0,offsetHeight:n=0}){const s=r(t,e,n);return{x:s.x-t.x()/t.scaleX(),y:s.y-t.y()/t.scaleY()}}export{a,r as i,n,s as o,o as r,t as s,e as t};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@machete-jhun/canvas-studio",
|
|
3
3
|
"description": "一个基于 React 和 Konva 的画布编辑组件库,支持多种图形和媒体元素的添加与编辑,适用于构建复杂的图形应用。",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -14,10 +14,19 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./utils": {
|
|
19
|
+
"import": "./dist/utils/index.js",
|
|
20
|
+
"types": "./dist/utils/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./utils/shapeTools": {
|
|
23
|
+
"import": "./dist/utils/shapeTools.js",
|
|
24
|
+
"types": "./dist/utils/shapeTools.d.ts"
|
|
17
25
|
}
|
|
18
26
|
},
|
|
19
27
|
"files": [
|
|
20
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
21
30
|
],
|
|
22
31
|
"scripts": {
|
|
23
32
|
"dev": "vite",
|