This commit is contained in:
zoujiandong
2025-08-03 17:46:42 +08:00
parent 6e320c3944
commit e5979f605e
24 changed files with 162 additions and 101 deletions
+16 -14
View File
@@ -1038,15 +1038,15 @@ const fillTextToImgWx = (base64) => {
let font = ""; //fontsize"px Arial";
let fontColor = "#fff";
let strokeWidth =5;
let strokeWidth =10;
uni.getImageInfo({
src: base64,
success: (imageRes) => {
// 设置canvas宽高
let scale =28;
// (imageRes.width / 800) * 30 > 12
// ? (imageRes.width / 800) * 30
// : 12;
//28;
let scale =(imageRes.width / 800) * 30 > 12
? (imageRes.width / 800) * 30
: 12;
font = scale + "px Arial";
console.log(imageRes);
canvas.width = imageRes.width;
@@ -1063,8 +1063,8 @@ const fillTextToImgWx = (base64) => {
// 将图片绘制到canvas上
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
let posXmargin = 10; //this.data.posXmargin // 自定义离左/右边的距离
let posYmargin = 10; // this.data.posYmargin // 自定义离上/下边的距离
let posXmargin =20; //this.data.posXmargin // 自定义离左/右边的距离
let posYmargin = 20; // this.data.posYmargin // 自定义离上/下边的距离
let randomNumber = 3; //Math.floor(Math.random() * (3 + 1));
console.log("randomNumber:" + randomNumber);
switch (randomNumber) {
@@ -1072,8 +1072,7 @@ const fillTextToImgWx = (base64) => {
let lt_x = posXmargin;
let lt_y = posYmargin + textHeight;
ctx.font = font;
ctx.fillStyle = fontColor;
ctx.storkStyle = "black";
ctx.storkStyle = "#000";
ctx.strokeWidth = strokeWidth;
ctx.fillStyle = "#fff";
ctx.fillText(maskText, lt_x, lt_y);
@@ -1090,6 +1089,7 @@ const fillTextToImgWx = (base64) => {
ctx.strokeWidth = strokeWidth;
ctx.fillStyle = "#fff";
ctx.fillText(maskText, lb_x, lb_y);
//ctx.restore()
//ctx.save()
break;
@@ -1111,19 +1111,21 @@ const fillTextToImgWx = (base64) => {
break;
case 3: //右下角
let rb_x =
imgWidth - 276 - posXmargin <= 0
imgWidth - scale*10 - posXmargin <= 0
? 10
: imgWidth - 276- posXmargin;
: imgWidth - scale*10 - posXmargin;
console.log(rb_x)
let rb_y = imgHeight - posYmargin;
ctx.font = font;
ctx.fillStyle = fontColor;
ctx.strokeStyle = "black";
ctx.strokeWidth = strokeWidth;
ctx.strokeStyle = "#000";
//ctx.strokeWidth = strokeWidth;
ctx.fillStyle = "#fff";
console.log('rb_x')
console.log(rb_x)
ctx.fillText(maskText, rb_x, rb_y);
ctx.strokeText(maskText,rb_x, rb_y);
ctx.fillText(maskText, rb_x, rb_y);
//ctx.restore()
//ctx.save()
break;
+5
View File
@@ -671,6 +671,11 @@ const toTop=()=>{
const goBack = () => {
uni.navigateBack({
delta: 1,
fail(){
uni.redirectTo({
url:'/pages/index/index'
})
}
});
};
const editorCotent=ref('')