Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kooriookami committed Aug 1, 2023
1 parent 824a528 commit 8e68cd6
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 13 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# 游戏王卡片 Yugioh Card

一个使用 Canvas 渲染游戏王卡片的工具。

目前有 5 种卡片:

- 游戏王
- 超速决斗
- 游戏王卡背
- 场地中心卡
- 游戏王 2 期

## 在线演示

[在线演示](https://kooriookami.github.io/yugioh-card/)

## 使用说明

```npm i yugioh-card```

```js
import { YugiohCard } from 'yugioh-card';

const card = new YugiohCard({
view: '', // div 容器
data: {
... // 参数见 packages/yugioh-card/src/yugioh-card/index.js => this.defaultData
},
resourcePath: 'src/assets/yugioh-card', // 静态资源路径
});
```

## 示例代码

[示例代码](src/components/YugiohCard.vue)
Binary file added docs/assets/blue-eyes-6a425603.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/blue-eyes-old-7608f0af.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/field-center-6794f4c2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/index-4e96d3f9.css

Large diffs are not rendered by default.

192 changes: 192 additions & 0 deletions docs/assets/index-6f0a59f8.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Yugioh Card</title>
<script type="module" crossorigin src="./assets/index-6f0a59f8.js"></script>
<link rel="stylesheet" href="./assets/index-4e96d3f9.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
1 change: 1 addition & 0 deletions docs/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html lang="en">
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<title>Yugioh Card</title>
</head>
<body>
<div id="app"></div>
Expand Down
20 changes: 13 additions & 7 deletions src/components/YugiohCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
/>
</el-form-item>
</el-form>

<div class="button-group">
<el-button type="primary" @click="exportImage">导出图片</el-button>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -108,7 +112,6 @@
form.data = yugiohDemo;
Card = YugiohCard;
}
form.data.scale = 0.2;
cardLeaf.value = new Card({
view: card.value,
data: form.data,
Expand All @@ -117,6 +120,10 @@
jsonData.value = form.data;
}
function exportImage() {
cardLeaf.value.leafer.export('卡片.png');
}
watch(() => jsonData.value, () => {
try {
form.data = JSON.parse(jsonData.value);
Expand Down Expand Up @@ -186,12 +193,11 @@
.form-main {
padding: 20px;
::v-deep(.el-form) {
.el-form-item {
.tip {
margin-left: 10px;
color: var(--normal-color);
}
.button-group {
margin-top: 20px;
.el-button {
width: 100%;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function editPackageJson() {

const buildLib = {
lib: {
entry: path.resolve(__dirname, 'packages/yugioh-card-card'),
entry: path.resolve(__dirname, 'packages/yugioh-card'),
name: 'YugiohCard',
fileName: format => {
if (format === 'es') {
Expand All @@ -35,9 +35,9 @@ const buildLib = {
plugins: [
copy({
targets: [
{ src: 'packages/yugioh-card-card/LICENSE', dest: 'dist' },
{ src: 'packages/yugioh-card-card/README.md', dest: 'dist' },
{ src: 'packages/yugioh-card-card/package.json', dest: 'dist' },
{ src: 'packages/yugioh-card/LICENSE', dest: 'dist' },
{ src: 'packages/yugioh-card/README.md', dest: 'dist' },
{ src: 'packages/yugioh-card/package.json', dest: 'dist' },
],
hook: 'writeBundle',
}),
Expand Down

0 comments on commit 8e68cd6

Please sign in to comment.