Giter Club home page Giter Club logo

mcanvas's People

Contributors

xd-tayde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcanvas's Issues

生成非png格式图片会有个黑色边框,

代码如下

    createCertificateBase64 () {
      let _this = this
      const mc = new MCanvas({
        width: 1025,
        height: 1455,
        backgroundColor: '#fff'
      })

      mc.background(image), {
        type: 'origin',
        color: '#ffffff'
      })

      // 由于异步的缘故,因此只有在该回调中,才能取到 base64 和 各项配置系数;
      mc.draw({
        // 导出图片格式: png/jpg/jpeg/webp;
        // default : png;
        type: 'jpg',

        //  图片质量,对 png 格式无效; 0~1;
        quality: 0.9,

        // 成功回调;
        success (b64) {
          console.log(b64)
        },

        // 错误回调;
        error (err) {
          console.log(err)
        }
      })
    }

图片大小

您好,请问如果可以做到不论图片宽高多少,只能在这个区域显示。。,让图片铺满这个区域。图片是通过微信选择的图片。。

可以考虑开放textBaseline属性设置吗

如题,由于需要做一个图片加文字的合成功能,文字可拖拽编辑那种;但是看源码目前text绘制时textBaseline固定为alphabetic,会导致输出的文字位置偏下;

image

基线位置不符合我这边的需求,可以开放textBaseline属性吗?

字体问题

您好,想问下text方法里,能设置font-face么,想自定义字体该怎么办呢,谢谢

图片上插入文字,文字有些模糊

const that = this;
const mc = new MC({
width: 684,
height: 214,
backgroundColor: '#fff'
});

mc.background('https://view.didistatic.com/static/dcms/5p5vwvyjrfk8zkurgo_684x219_compress.png', {
  left: 0,
  top: 0,
  type: 'origin',
}).text('迎新年发劵', {
  pos: {
    x: 38,
    y: 30,
  },
  normalStyle: {
    font: '36px Microsoft YaHei,sans-serif',
  }
}).text('加油8.8折 轻松享受', {
  pos: {
    x: 44,
    y: 88 - 9,
  },
  normalStyle: {
    font: '300 24px Microsoft YaHei,sans-serif',
    color: '#a6a6a6',
  }
}).text('立即领取', {
  pos: {
    x: 54,
    y: 134,
  },
  normalStyle: {
    font: '20px Microsoft YaHei,sans-serif',
    color: 'white',
  }
}).draw({
  type: 'jpg',
  quality: 1,
  success(b64) {
    that.setState({
      pic: b64,
    });
  },
  error(err) {
    console.log('err=', err);
  }
});

英文单词自动换行被切割

英文单词自动换行被切割

  • 建议加一个选项,自动换行的时候对于一个完整的英文单词是否要换行来完整显示还是被切割显示
  • 或者加入换行相关样式参数,让用户自定义

React native - ReferenceError: Can't find variable: doucoumt

我是在 React native 中使用的

MCanvas.prototype._init = function () {
    this.canvas = document.createElement('canvas');
    this.canvas.width = this.ops.width;
    this.canvas.height = this.ops.height;
    this.ctx = this.canvas.getContext('2d');

    this.ops.backgroundColor && this.setBgColor(this.ops.backgroundColor);
};

document.createElement('canvas');

这一句报错了,该怎么处理呢?

字体颜色设置不生效,请问是什么问题呢?

let mc = new MC({
// width: 1000,
// height: 1000,
// backgroundColor: 'black',
});

			// background : 准备底图;提供多种模式
			mc.background(bg, {
					left: 0,
					top: 0,
					color: '#FFFFFF',
					type: 'origin',
				})
				// add 添加图片素材基础函数;
				.add(userHeadImg, {
					width: 130,
					height: 130,
					pos: {
						x: 30,
						y: 30,
						rotate: 1,
					},
				})

				// add 添加图片素材基础函数;
				.add(ercode, {
					width: 200,
					pos: {
						x: 515,
						y: 1090,
					},
				})

				// text 添加文字数据基础函数;
				.text(user.nickname, {
					width: '300px',
					smallStyle: {
						// 字体颜色;
						color: '#ffffff',
					},
					pos: {
						x: 180,
						y: 50,
					},
				})
				.text(shareDesc, {
					width: '300px',
					smallStyle: {
						// 字体颜色;
						color: '#FFF',
						// 文字渐变
						gradient: {
							type: 2, // 1: 横向渐变; 2: 纵向渐变;
							colorStop: ['red', 'blue'],
						},
					},
					pos: {
						x: 180,
						y: 90,
					},
				})

				// draw 最终绘制函数,用于最终的绘制;
				.draw(b64 => {
					that.$data.shareCanvasImg = b64
				});

img load error

“img load error ”这个错误一般是什么情况下会出现?我在PC和手机浏览器测过都没问题,唯独微信里面有这个问题,跑不通,求解,谢谢
在‘add()’的时候报错

请问是否支持react native,用于开发App?

你好,目前我使用react native进行App开发,打算实现图像的绘制(合成),我看到你的库好像能够方便实现这个功能,但是基于Canvas,我试了下好像是用不了,请问有什么别的库推荐支持RN的吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.