Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
WangMargin opened this issue May 9, 2019 · 4 comments
Closed

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

WangMargin opened this issue May 9, 2019 · 4 comments

Comments

@WangMargin
Copy link

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
				});
@xd-tayde
Copy link
Owner

xd-tayde commented May 9, 2019

尝试这样看看会不会生效:
smallStyle:{
color:'#ffffff',
font:'50px Microsoft YaHei,sans-serif',
}

@WangMargin
Copy link
Author

WangMargin commented May 9, 2019 via email

@xd-tayde
Copy link
Owner

xd-tayde commented May 10, 2019

哦。~我知道了。 .text('HELLO WORLD') 对应的是 normalStyle。。 你写的 smallStyle 需要使用 .text('<s>HELLO WORLD</s>')

@WangMargin
Copy link
Author

感谢感谢 问题已经解决了 给大佬点赞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants