Commit 67869a71 authored by limingzhe's avatar limingzhe

feat: 添加遮罩

parent 302f5456
...@@ -3,12 +3,26 @@ ...@@ -3,12 +3,26 @@
<div style="padding: 20px;"> <div style="padding: 20px;">
<h2 style="margin-top: 20px;">
封面图
</h2>
<div style="width: 300px; margin-bottom: 50px;">
<app-upload-image-with-preview
[picUrl]="item.bg_url"
(imageUploaded)="onImageUploadSuccess($event, 'bg_url')">
</app-upload-image-with-preview>
</div>
<div style="width: 400px; display: flex; justify-content: center;"> <div style="width: 400px; display: flex; justify-content: center;">
<h2 style="width: 60px;">标题:</h2> <h2 style="width: 60px;">标题:</h2>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" style="margin-left: 15px"> <input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" style="margin-left: 15px">
</div> </div>
<div *ngFor="let s of item.sentenceArr; let i = index" style=" margin-bottom: 10px; display: flex;"> <div *ngFor="let s of item.sentenceArr; let i = index" style=" margin-bottom: 10px; display: flex;">
<input type="text" nz-input [(ngModel)]="s.text" (blur)="save()" style="width: 500px;"> <input type="text" nz-input [(ngModel)]="s.text" (blur)="save()" style="width: 500px;">
<input type="text" nz-input [(ngModel)]="s.answer" (blur)="save()" style="margin-left: 15px; width: 120px;"> <input type="text" nz-input [(ngModel)]="s.answer" (blur)="save()" style="margin-left: 15px; width: 120px;">
......
...@@ -434,8 +434,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -434,8 +434,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}; };
addPicUrl(contentObj.bg_url);
// addPicUrl(contentObj.bgItem.url);
} }
...@@ -515,8 +515,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -515,8 +515,11 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.isTeacher) { if (this.isTeacher) {
this.sentBtn.visible = false; this.sentBtn.visible = false;
this.sentBtn.shadowSpr.visible = false; this.sentBtn.shadowSpr.visible = false;
this.maskPic.visible = true;
} else { } else {
this.changeBtnOn(); this.changeBtnOn();
this.maskPic.visible = false;
} }
} }
...@@ -550,6 +553,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -550,6 +553,7 @@ export class PlayComponent implements OnInit, OnDestroy {
initView() { initView() {
this.initBg(); this.initBg();
...@@ -562,8 +566,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -562,8 +566,14 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initIframe(); this.initIframe();
this.initWindowListener(); this.initWindowListener();
this.initMaskPic();
this.relink(); this.relink();
} }
relink() { relink() {
...@@ -597,11 +607,38 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -597,11 +607,38 @@ export class PlayComponent implements OnInit, OnDestroy {
this.checkShowSubTemplateOne(); this.checkShowSubTemplateOne();
return; return;
} }
}
maskPic;
initMaskPic() {
const bgUrl = this.data.contentObj.bg_url;
console.log('bgUrl', bgUrl);
const maskPic = this.getMySprite(bgUrl);
const sx = this.canvasWidth / maskPic.width;
const sy = this.canvasHeight / maskPic.height;
const s = Math.max(sx, sy);
maskPic.setScaleXY(s);
maskPic.x = this.canvasWidth / 2;
maskPic.y = this.canvasHeight / 2;
if (this.isTeacher) {
maskPic.visible = false;
}
this.maskPic = maskPic;
}
getMySprite(resName, isSetScale = true) {
const spr = new MySprite();
spr.init(this.images.get(resName))
if (isSetScale) {
spr.setScaleXY(this.mapScale);
}
return spr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment