@@ -39,7 +39,7 @@ const computedContent = computed(() => {
3939});
4040const computedFont = computed (() => {
4141 const defaultFont: IWatermarkFont = {
42- color: ' rgba(214, 209, 210 , 1)' ,
42+ color: ' rgba(233, 233, 233 , 1)' ,
4343 fontFamily: ` Inter,
4444 -apple-system,
4545 BlinkMacSystemFont,
@@ -117,24 +117,40 @@ function updateWatermark() {
117117 ctx .textBaseline = computedFont .value .textBaseline ! ;
118118 ctx .font = ` ${computedFont .value .fontStyle } ${computedFont .value .fontWeight } ${computedFont .value .fontSize }px ${computedFont .value .fontFamily } ` ;
119119 ctx .fillStyle = computedFont .value .color ! ;
120+
121+ ctx .save ();
122+ ctx .translate (props .width / 2 , props .height / 2 );
123+ ctx .rotate ((330 * Math .PI ) / 180 );
124+ ctx .fillText (props .content as string , 0 , 0 );
125+ ctx .restore ();
126+
120127 ctx .save ();
121- ctx .fillText (' 重要机密' , computedOffset .value .x , computedOffset .value .y );
122- ctx .fillText (
123- ' 重要机密' ,
124- computedOffset .value .x + props .width + computedGap .value .x ,
125- computedOffset .value .y + props .height + computedGap .value .y ,
128+ ctx .translate (
129+ props .width / 2 + (props .width + computedGap .value .x ) * 1 ,
130+ props .height / 2 + (props .height + computedGap .value .y ) * 1 ,
126131 );
127- ctx .fillText (
128- ' 重要机密' ,
129- computedOffset .value .x ,
130- computedOffset .value .y + (props .height + computedGap .value .y ) * 2 ,
132+ ctx .rotate ((330 * Math .PI ) / 180 );
133+ ctx .fillText (props .content as string , 0 , 0 );
134+ ctx .restore ();
135+
136+ ctx .save ();
137+ ctx .translate (
138+ props .width / 2 ,
139+ props .height / 2 + (props .height + computedGap .value .y ) * 2 ,
131140 );
132- ctx .fillText (
133- ' 重要机密1' ,
134- computedOffset .value .x + props .width + computedGap .value .x ,
135- computedOffset .value .y + (props .height + computedGap .value .y ) * 3 ,
141+ ctx .rotate ((330 * Math .PI ) / 180 );
142+ ctx .fillText (props .content as string , 0 , 0 );
143+ ctx .restore ();
144+
145+ ctx .save ();
146+ ctx .translate (
147+ props .width / 2 + (props .width + computedGap .value .x ) * 1 ,
148+ props .height / 2 + (props .height + computedGap .value .y ) * 3 ,
136149 );
150+ ctx .rotate ((330 * Math .PI ) / 180 );
151+ ctx .fillText (props .content as string , 0 , 0 );
137152 ctx .restore ();
153+
138154 // 将canvas保存为图片
139155 watermark .value = canvas .toDataURL ();
140156}
0 commit comments