Skip to content

Commit

Permalink
1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ningbo committed Mar 17, 2021
1 parent 38cff33 commit 448bd59
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cp.getPicture().then((picture)=>{

- `new CreatePicture();` - 初始化,可接受一个对象参数
- `drawImage()` - 绘制图片,第一个参数为图片路径,其他参数与 [CanvasRenderingContext2D.drawImage()](https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/drawImage) 参数相同
- `drawRectImage()` - 绘制重复排列的图片
- `drawRepeatImage()` - 绘制重复排列的图片
- `drawCirclePicture()` - 绘制头像等圆形图片,与 `drawImage` 参数相同
- `drawText()` - 绘制文本,返回文字宽度(可选)
- `getPicture().then((picture)=>{});` - 最终合成的图片
Expand All @@ -52,7 +52,7 @@ cp.getPicture().then((picture)=>{
- 第一个参数为图片路径
- 其他参数与 [CanvasRenderingContext2D.drawImage()](https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/drawImage) 参数相同

### drawRectImage() 参数
### drawRepeatImage() 参数

- 第一个参数为图片路径
- 第二、三参数为平铺文件的宽高
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ declare class CreatePicture{
drawImage(image: any, dx: number, dy: number): void;
drawImage(image: any, dx: number, dy: number, dw: number, dh: number): void;
drawImage(image: any, sx: number, sy: number, sw: number|string, sh: number|string, dx: number, dy: number, dw: number, dh: number): void;
drawRectImage(image: any, dx: number, dy: number, dw: number, dh: number): void;
drawRepeatImage(image: any, dx: number, dy: number, dw: number, dh: number): void;
drawCirclePicture(image: any, dx: number, dy: number): void;
drawCirclePicture(image: any, dx: number, dy: number, dw: number, dh: number): void;
drawCirclePicture(image: any, sx: number, sy: number, sw: number|string, sh: number|string, dx: number, dy: number, dw: number, dh: number): void;
Expand Down
16 changes: 2 additions & 14 deletions lib/create-picture.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* 说明 V 1.1.2
/* 说明 V 1.1.3
* 该组件提供了 canvas 的图片绘制与文本绘制功能,使用同步的语法完成异步绘制,简化原生 canvas 绘制语法。
* API:https://github.com/ningbonb/create-picture
* npm:https://www.npmjs.com/package/create-picture
* */

let saidHello = false;
const VERSION = '1.1.2';
const VERSION = '1.1.3';
const defaultProp = {
width: 750,
height: 1448,
Expand Down Expand Up @@ -43,10 +43,6 @@ export default class CreatePicture{
this.map.set(prop,'picture');
this.pictureMap.set(prop,prop[0]);
}
drawRectImage(...prop){
this.map.set(prop,'rectPicture');
this.pictureMap.set(prop,prop[0]);
}
drawRepeatImage(...prop){
this.map.set(prop, 'repeatPicture');
this.pictureMap.set(prop, prop[0]);
Expand Down Expand Up @@ -102,7 +98,6 @@ export default class CreatePicture{
for(let [key,value] of this.map.entries()){
if(value === 'picture') this.addPicture(key);
if(value === 'repeatPicture') this.addRepeatPicture(key);
if(value === 'rectPicture') this.addRectPicture(key);
if(value === 'circlePicture') this.addCirclePicture(key);
if(value === 'text') this.addText(key);
}
Expand All @@ -115,13 +110,6 @@ export default class CreatePicture{
key[0] = this.pictureMap.get(key);
this.ctx.drawImage(...key);
}
addRectPicture(key){
key[0] = this.pictureMap.get(key);
const [ pictureWidth, pictureHeight, rectWidth, rectHeight ] = [ key[0].width, key[0].height, 180, 220];
key[1] = key[1] + (rectWidth - pictureWidth) / 2;
key[2] = key[2] + (rectHeight - pictureHeight);
this.ctx.drawImage(...key);
}
addRepeatPicture(key){
key[0] = this.pictureMap.get(key);
this.ctx.save();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-picture",
"version": "1.1.2",
"version": "1.1.3",
"description": "该组件提供了 Canvas 的图片绘制与文本绘制功能,使用同步的语法完成异步绘制,简化原生 canvas 绘制语法。",
"main": "lib/create-picture.js",
"scripts": {
Expand Down

0 comments on commit 448bd59

Please sign in to comment.