Commit afa31d35 authored by limingzhe's avatar limingzhe

fix: debug

parent 212b4834
...@@ -300,7 +300,7 @@ cc.Class({ ...@@ -300,7 +300,7 @@ cc.Class({
this.centerItemArr = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '1'); this.centerItemArr = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '1');
this.benchmark1Data = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '3')[0]; this.benchmark1Data = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '3')[0];
this.benchmark2Data = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '4')[0]; this.benchmark2Data = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '4')[0];
// this.firstItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '5')[0]; this.firstItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '5')[0];
// this.topItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '0')[0]; // this.topItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '0')[0];
...@@ -333,7 +333,7 @@ cc.Class({ ...@@ -333,7 +333,7 @@ cc.Class({
const firstItemRect = this.firstItemData.rect; const firstItemRect = this.firstItemData.rect;
baseX = firstItemRect.x + firstItemRect.width / 2; baseX = firstItemRect.x + firstItemRect.width / 2;
baseY = firstItemRect.y + firstItemRect.height / 2; baseY = firstItemRect.y + firstItemRect.height / 2;
unitW = benchmark1Rect.x + benchmark1Rect.width / 2 - (firstItemRect.x + firstItemRect.width); unitW = benchmark1Rect.x + benchmark1Rect.width - (firstItemRect.x + firstItemRect.width / 2);
unitH = (firstItemRect.y + firstItemRect.height / 2) - benchmark1CenterY; unitH = (firstItemRect.y + firstItemRect.height / 2) - benchmark1CenterY;
} }
...@@ -523,10 +523,17 @@ cc.Class({ ...@@ -523,10 +523,17 @@ cc.Class({
//调起检测 //调起检测
startTesting() { startTesting() {
// this.getPhotoData((data) => { this.ques_region = [
// this.photoEnd(data); 0, 0.077,
// }); 1, 0.077,
// return; 1, 0.331,
0, 0.331,
]
this.getPhotoData((data) => {
this.photoEnd(data);
});
return;
const cw = window.courseware; const cw = window.courseware;
...@@ -588,6 +595,8 @@ cc.Class({ ...@@ -588,6 +595,8 @@ cc.Class({
console.log(' this.photo end ', data); console.log(' this.photo end ', data);
this.changeBboxPos(data);
const isRightArea = this.checkIsRightArea(data); const isRightArea = this.checkIsRightArea(data);
if (!isRightArea) { if (!isRightArea) {
// playAudio(this.audioTipArea.clip) // playAudio(this.audioTipArea.clip)
...@@ -608,15 +617,19 @@ cc.Class({ ...@@ -608,15 +617,19 @@ cc.Class({
this.isCanDraw = false; this.isCanDraw = false;
}) })
this.debugDrawLayer.removeAllChildren(); this.debugDrawLayer.removeAllChildren();
const benchmark1Text = this.benchmark1Data.labelText // const benchmark1Text = this.benchmark1Data.labelText
const benchmark1TextArr = benchmark1Text.split(' '); // const benchmark1TextArr = benchmark1Text.split(' ');
const benchmark1LabelData = this.getPhotoLabelData(benchmark1TextArr, data?.result?.text); // const benchmark1LabelData = this.getPhotoLabelData(benchmark1TextArr, data?.result?.text);
// const benchmark2Text = this.benchmark2Data.labelText
// const benchmark2TextArr = benchmark2Text.split(' ');
// const benchmark2LabelData = this.getPhotoLabelData(benchmark2TextArr, data?.result?.text);
const benchmark2Text = this.benchmark2Data.labelText
const benchmark2TextArr = benchmark2Text.split(' ');
const benchmark2LabelData = this.getPhotoLabelData(benchmark2TextArr, data?.result?.text);
const answerData = this.getAnswerData(data); const answerData = this.getAnswerData(data);
...@@ -763,13 +776,93 @@ cc.Class({ ...@@ -763,13 +776,93 @@ cc.Class({
}, },
changeBboxPos(data) {
const text = data?.result?.text;
if (!text) {
return;
}
for (let i=0; i<text.length; i++) {
let {left, top, right, bottom} = text[i];
const q_left = this.ques_region[0];
const q_top = this.ques_region[1];
const q_right = this.ques_region[2];
const q_bottom = this.ques_region[7];
const rect = {x: q_left, y: q_top, width: q_right - q_left, height: q_bottom - q_top};
text[i].left = q_left + left * rect.width;
text[i].top = q_top + top * rect.height;
text[i].right = q_left + right * rect.width;
text[i].bottom = q_top + bottom * rect.height;
}
// console.log('bbox: ', bbox);
// const x1 = bbox[0].x1;
// const y1 = bbox[0].y1;
// const x2 = bbox[1].x2;
// const y2 = bbox[1].y2;
// const x3 = bbox[2].x3;
// const y3 = bbox[2].y3;
// const x4 = bbox[3].x4;
// const y4 = bbox[3].y4;
// const left = this.ques_region[0];
// const top = this.ques_region[1];
// const right = this.ques_region[2];
// const bottom = this.ques_region[7];
// const rect = {x: left, y:top, width: right - left, height: bottom - top};
// const y1_new = top + y1 * rect.height;
// const y2_new = y1_new;
// const y3_new = top + y3 * rect.height;
// const y4_new = y3_new;
// const x1_new = left + x1 * rect.width;
// const x2_new = left + x2 * rect.width;
// const x3_new = x2_new;
// const x4_new = x1_new;
// bbox[0].x1 = x1_new;
// bbox[0].y1 = y1_new;
// bbox[1].x2 = x2_new;
// bbox[1].y2 = y2_new;
// bbox[2].x3 = x3_new;
// bbox[2].y3 = y3_new;
// bbox[3].x4 = x4_new;
// bbox[3].y4 = y4_new;
// console.log('~~rect: ', rect);
},
getTopLeftLetter2(text, block, topLabelData) { getTopLeftLetter2(text, block, topLabelData) {
const benchmark1Rect = this.benchmark1Data.rect; const benchmark1Rect = this.benchmark1Data.rect;
const tempUnitW = benchmark1Rect.width; const rect = {
x: topLabelData.left,
y: -topLabelData.bottom,
width: Math.abs( topLabelData.right - topLabelData.left ),
height: Math.abs( topLabelData.bottom - topLabelData.top ),
}
const colorRect = this.getColorRect(rect, "green");
this.debugDrawLayer.addChild(colorRect);
const tempUnitW = benchmark1Rect.x + benchmark1Rect.width;
const tempUnitH = benchmark1Rect.height; const tempUnitH = benchmark1Rect.height;
const tempBaseX = benchmark1Rect.x; const tempBaseX = benchmark1Rect.x + benchmark1Rect.width / 2;
const tempBaseY = benchmark1Rect.y + benchmark1Rect.height / 2; const tempBaseY = benchmark1Rect.y + benchmark1Rect.height / 2;
...@@ -786,6 +879,12 @@ cc.Class({ ...@@ -786,6 +879,12 @@ cc.Class({
const unitH2 = firstItemRect.height / tempUnitH; const unitH2 = firstItemRect.height / tempUnitH;
console.log('tempUnitW: ', tempUnitW);
console.log('tempUnitH: ', tempUnitH);
console.log('tempBaseX: ', tempBaseX);
console.log('tempBaseY: ', tempBaseY);
console.log('firstItemY: ', firstItemY); console.log('firstItemY: ', firstItemY);
console.log('tempBaseY: ', tempBaseY); console.log('tempBaseY: ', tempBaseY);
console.log('tempUnitH: ', tempUnitH); console.log('tempUnitH: ', tempUnitH);
...@@ -802,9 +901,9 @@ cc.Class({ ...@@ -802,9 +901,9 @@ cc.Class({
const topLocationRight = topLabelData.right; const topLocationRight = topLabelData.right;
const topLocationBottom = topLabelData.bottom; const topLocationBottom = topLabelData.bottom;
const baseX = topLocationLeft; const baseX = topLocationLeft + (topLocationRight - topLocationLeft) / 2;
const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2; const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2;
const unitW = topLocationRight - topLocationLeft; const unitW = topLocationRight;
const unitH = topLocationBottom - topLocationTop; const unitH = topLocationBottom - topLocationTop;
...@@ -830,7 +929,7 @@ cc.Class({ ...@@ -830,7 +929,7 @@ cc.Class({
console.log(' r: ', r); console.log(' r: ', r);
console.log(' checkLetter: ', checkLetter); console.log(' checkLetter: ', checkLetter);
const dot = this.getColorDot(x, -y, r, r, 'red'); const dot = this.getColorDot(x, -y, r, r, 'blue');
this.debugDrawLayer.addChild(dot, 5); this.debugDrawLayer.addChild(dot, 5);
dot.labelText = checkLetter.labelText; dot.labelText = checkLetter.labelText;
...@@ -957,148 +1056,148 @@ cc.Class({ ...@@ -957,148 +1056,148 @@ cc.Class({
getTopLeftLetter(text, block, topLabelData) { getTopLeftLetter(text, block, topLabelData) {
const topItemRect = this.topItemData.rect; // const topItemRect = this.topItemData.rect;
const tempUnitW = topItemRect.width; // const tempUnitW = topItemRect.width;
const tempUnitH = topItemRect.height; // const tempUnitH = topItemRect.height;
const tempBaseX = topItemRect.x; // const tempBaseX = topItemRect.x;
const tempBaseY = topItemRect.y + topItemRect.height / 2; // const tempBaseY = topItemRect.y + topItemRect.height / 2;
const firstItemData = this.firstItemData; // const firstItemData = this.firstItemData;
console.log('firstItemData: ', firstItemData); // console.log('firstItemData: ', firstItemData);
const firstItemRect = this.firstItemData.rect; // const firstItemRect = this.firstItemData.rect;
const firstItemX = firstItemRect.x + firstItemRect.width / 2; // const firstItemX = firstItemRect.x + firstItemRect.width / 2;
const firstItemY = firstItemRect.y + firstItemRect.height / 2; // const firstItemY = firstItemRect.y + firstItemRect.height / 2;
const unitX = (firstItemX - tempBaseX) / tempUnitW; // const unitX = (firstItemX - tempBaseX) / tempUnitW;
const unitY = (firstItemY - tempBaseY) / tempUnitH; // const unitY = (firstItemY - tempBaseY) / tempUnitH;
const unitW2 = firstItemRect.width / tempUnitW; // const unitW2 = firstItemRect.width / tempUnitW;
const unitH2 = firstItemRect.height / tempUnitH; // const unitH2 = firstItemRect.height / tempUnitH;
console.log('firstItemY: ', firstItemY); // console.log('firstItemY: ', firstItemY);
console.log('tempBaseY: ', tempBaseY); // console.log('tempBaseY: ', tempBaseY);
console.log('tempUnitH: ', tempUnitH); // console.log('tempUnitH: ', tempUnitH);
firstItemData.unitX = unitX; // firstItemData.unitX = unitX;
firstItemData.unitY = unitY; // firstItemData.unitY = unitY;
firstItemData.unitW = unitW2; // firstItemData.unitW = unitW2;
firstItemData.unitH = unitH2; // firstItemData.unitH = unitH2;
// const topLabelData = this.topLabelData; // // const topLabelData = this.topLabelData;
const firstTopWordLocation = topLabelData.word[0].location; // const firstTopWordLocation = topLabelData.word[0].location;
const lastTopWordLocation = topLabelData.word[topLabelData.word.length - 1].location // const lastTopWordLocation = topLabelData.word[topLabelData.word.length - 1].location
const topLocationLeft = firstTopWordLocation.left; // const topLocationLeft = firstTopWordLocation.left;
const topLocationTop = firstTopWordLocation.top; // const topLocationTop = firstTopWordLocation.top;
const topLocationRight = lastTopWordLocation.right; // const topLocationRight = lastTopWordLocation.right;
const topLocationBottom = lastTopWordLocation.bottom; // const topLocationBottom = lastTopWordLocation.bottom;
const baseX = topLocationLeft; // const baseX = topLocationLeft;
const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2; // const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2;
const unitW = topLocationRight - topLocationLeft; // const unitW = topLocationRight - topLocationLeft;
const unitH = topLocationBottom - topLocationTop; // const unitH = topLocationBottom - topLocationTop;
const checkLetter = firstItemData; // const checkLetter = firstItemData;
console.log('baseY: ', baseY); // console.log('baseY: ', baseY);
console.log('checkLetter.unitY: ', checkLetter.unitY); // console.log('checkLetter.unitY: ', checkLetter.unitY);
console.log('unitH: ', unitH); // console.log('unitH: ', unitH);
let x = baseX + checkLetter.unitX * unitW; // let x = baseX + checkLetter.unitX * unitW;
const y = baseY + checkLetter.unitY * unitH; // const y = baseY + checkLetter.unitY * unitH;
const w = checkLetter.unitW * unitW; // const w = checkLetter.unitW * unitW;
const h = checkLetter.unitH * unitH; // const h = checkLetter.unitH * unitH;
const r = Math.min(w, h) / 2; // const r = Math.min(w, h) / 2;
// const centerX = baseX + this.centerUnitW * unitW; // // const centerX = baseX + this.centerUnitW * unitW;
// x += (centerX - x) * 0.005 * (y * 0.05); // // x += (centerX - x) * 0.005 * (y * 0.05);
console.log(' x: ', x); // console.log(' x: ', x);
console.log(' y: ', y); // console.log(' y: ', y);
console.log(' r: ', r); // console.log(' r: ', r);
const dot = this.getColorDot(x, -y, r, r, 'purple'); // const dot = this.getColorDot(x, -y, r, r, 'purple');
this.debugDrawLayer.addChild(dot, 5); // this.debugDrawLayer.addChild(dot, 5);
dot.labelText = checkLetter.labelText; // dot.labelText = checkLetter.labelText;
const wordDataArr = this.getPhotoWordArr(text, block, topLabelData); // const wordDataArr = this.getPhotoWordArr(text, block, topLabelData);
let topLeftLetterData; // let topLeftLetterData;
const {dotRect, labelText} = dot // const {dotRect, labelText} = dot
for (let i=0; i<wordDataArr.length; i++) { // for (let i=0; i<wordDataArr.length; i++) {
const tempWordArr = wordDataArr[i].word;
const lineRect = this.getLineRect( wordDataArr[i] ); // const tempWordArr = wordDataArr[i].word;
const isInLineRect = lineRect.intersects(dotRect)
if (!isInLineRect) {
continue;
}
for (let k=0; k<tempWordArr.length; k++) { // const lineRect = this.getLineRect( wordDataArr[i] );
const {location , content} = tempWordArr[k]; // const isInLineRect = lineRect.intersects(dotRect)
// if (!isInLineRect) {
// continue;
// }
const tempRect = { // for (let k=0; k<tempWordArr.length; k++) {
x: location.left, // const {location , content} = tempWordArr[k];
y: -location.bottom,
width: Math.abs( location.right - location.left ),
height: Math.abs( location.bottom - location.top ),
}
const colorRect = this.getColorRect(tempRect);
colorRect.labelText = content;
// this.debugDrawLayer.addChild(colorRect);
const label = this.getLabel(content); // const tempRect = {
label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX; // x: location.left,
label.y = colorRect.y - colorRect.height / 2 //* colorRect.scaleY; // y: -location.bottom,
label.color = cc.Color.GREEN; // width: Math.abs( location.right - location.left ),
// this.debugDrawLayer.addChild(label); // height: Math.abs( location.bottom - location.top ),
// }
// const colorRect = this.getColorRect(tempRect);
// colorRect.labelText = content;
// // this.debugDrawLayer.addChild(colorRect);
// const label = this.getLabel(content);
// label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX;
// label.y = colorRect.y - colorRect.height / 2 //* colorRect.scaleY;
// label.color = cc.Color.GREEN;
// // this.debugDrawLayer.addChild(label);
const rect = colorRect.ccRect; // const rect = colorRect.ccRect;
const targetLabelText = colorRect.labelText; // const targetLabelText = colorRect.labelText;
// console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() ); // // console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() );
// console.log('labelText.toLowerCase() : ', labelText.toLowerCase() ); // // console.log('labelText.toLowerCase() : ', labelText.toLowerCase() );
const isInLineText = this.checkWordIsInLine(wordDataArr[i], labelText); // const isInLineText = this.checkWordIsInLine(wordDataArr[i], labelText);
if (isInLineText) { // if (isInLineText) {
// if (targetLabelText.toLowerCase().indexOf(labelText.toLowerCase()) != -1 && rect.intersects(dotRect)) { // // if (targetLabelText.toLowerCase().indexOf(labelText.toLowerCase()) != -1 && rect.intersects(dotRect)) {
topLeftLetterData = wordDataArr[i]; // topLeftLetterData = wordDataArr[i];
// answerData[i.toString()] = colorRect; // // answerData[i.toString()] = colorRect;
// return; // // return;
} // }
} // }
} // }
return topLeftLetterData; // return topLeftLetterData;
...@@ -1108,55 +1207,55 @@ cc.Class({ ...@@ -1108,55 +1207,55 @@ cc.Class({
// const topRect = this.topItemData.rect; // // const topRect = this.topItemData.rect;
// const topCenterY = (topRect.y + topRect.height / 2); // // const topCenterY = (topRect.y + topRect.height / 2);
// const bottomCenterY = (bottomRect.y + bottomRect.height / 2); // // const bottomCenterY = (bottomRect.y + bottomRect.height / 2);
// const unitH = bottomCenterY - topCenterY; // // const unitH = bottomCenterY - topCenterY;
// const unitW = topRect.width; // // const unitW = topRect.width;
// const baseX = topRect.x; // // const baseX = topRect.x;
// const baseY = topRect.y + topRect.height; // // const baseY = topRect.y + topRect.height;
// const titleBottom = this.getTitleBottom(); // // const titleBottom = this.getTitleBottom();
// console.log("titleBottom: ", titleBottom); // // console.log("titleBottom: ", titleBottom);
// let topLeftLetter; // // let topLeftLetter;
// const wordDataArr = this.getPhotoWordArr(text, block, topLabelData); // // const wordDataArr = this.getPhotoWordArr(text, block, topLabelData);
// for (let i=0; i<wordDataArr.length; i++) { // // for (let i=0; i<wordDataArr.length; i++) {
// const tempWordArr = wordDataArr[i].word; // // const tempWordArr = wordDataArr[i].word;
// for (let k=0; k<tempWordArr.length; k++) { // // for (let k=0; k<tempWordArr.length; k++) {
// const {location , content} = tempWordArr[k]; // // const {location , content} = tempWordArr[k];
// // console.log('location: ~~ ', location); // // // console.log('location: ~~ ', location);
// // if (location.top <= titleBottom) { // // // if (location.top <= titleBottom) {
// // continue; // // // continue;
// // } // // // }
// wordDataArr[i].tmpLen = this.getToZeroLen(location) // // wordDataArr[i].tmpLen = this.getToZeroLen(location)
// if (!topLeftLetter) { // // if (!topLeftLetter) {
// topLeftLetter = wordDataArr[i]; // // topLeftLetter = wordDataArr[i];
// } else { // // } else {
// if (topLeftLetter.tmpLen > wordDataArr[i].tmpLen) { // // if (topLeftLetter.tmpLen > wordDataArr[i].tmpLen) {
// topLeftLetter = wordDataArr[i]; // // topLeftLetter = wordDataArr[i];
// } // // }
// } // // }
// } // // }
// } // // }
// return topLeftLetter; // // return topLeftLetter;
}, },
...@@ -1542,12 +1641,6 @@ cc.Class({ ...@@ -1542,12 +1641,6 @@ cc.Class({
const benchmark1LabelData = this.benchmark1LabelData; const benchmark1LabelData = this.benchmark1LabelData;
let benchmark2LabelData ; let benchmark2LabelData ;
if (this.benchmark2LabelData) {
benchmark2LabelData = this.benchmark2LabelData;
}
const centerItemArr = this.centerItemArr; const centerItemArr = this.centerItemArr;
const benchmark1Left = benchmark1LabelData.left; const benchmark1Left = benchmark1LabelData.left;
...@@ -1555,33 +1648,66 @@ cc.Class({ ...@@ -1555,33 +1648,66 @@ cc.Class({
const benchmark1Right = benchmark1LabelData.right; const benchmark1Right = benchmark1LabelData.right;
const benchmark1Bottom = benchmark1LabelData.bottom; const benchmark1Bottom = benchmark1LabelData.bottom;
const benchmark2Left = benchmark2LabelData.left; let baseX;
const benchmark2Top = benchmark2LabelData.top; let baseY;
const benchmark2Right = benchmark2LabelData.right; let unitW;
const benchmark2Bottom = benchmark2LabelData.bottom; let unitH;
if (this.benchmark2LabelData) {
benchmark2LabelData = this.benchmark2LabelData;
const bottomLocation = benchmark2LabelData;
let baseX = benchmark1Left; const benchmark2Left = benchmark2LabelData.left;
let baseY = benchmark1Top + (benchmark1Bottom - benchmark1Top) / 2; const benchmark2Top = benchmark2LabelData.top;
let unitW = benchmark2Right - benchmark1Left; const benchmark2Right = benchmark2LabelData.right;
let unitH = bottomLocation.top + (bottomLocation.bottom - bottomLocation.top) / 2 - baseY; const benchmark2Bottom = benchmark2LabelData.bottom;
const bottomLocation = benchmark2LabelData;
baseX = benchmark1Left;
baseY = benchmark1Top + (benchmark1Bottom - benchmark1Top) / 2;
unitW = benchmark2Right - benchmark1Left;
unitH = bottomLocation.top + (bottomLocation.bottom - bottomLocation.top) / 2 - baseY;
const benchmark2Rect = {
x: benchmark2Left,
y: -benchmark2Bottom,
width: Math.abs( benchmark2Left - benchmark2Right ),
height: Math.abs( benchmark2Top - benchmark2Bottom ),
}
const colorbenchmark2Rect = this.getColorRect(benchmark2Rect, 'green');
this.debugDrawLayer.addChild(colorbenchmark2Rect);
}
if (this.firstItemLabelData) { if (this.firstItemLabelData) {
const firstItemLeft = this.firstItemLabelData.left; const {location} = this.firstItemLabelData;
const firstItemRight = this.firstItemLabelData.right; const firstItemLeft = location.left;
const firstItemTop = this.firstItemLabelData.top; const firstItemRight = location.right;
const firstItemBottom = this.firstItemLabelData.bottom; const firstItemTop = location.top;
const firstItemBottom = location.bottom;
console.log(' location: ', location);
console.log(' firstItemLeft: ', firstItemLeft);
console.log(' firstItemRight: ', firstItemRight);
console.log(' firstItemTop: ', firstItemTop);
console.log(' firstItemBottom: ', firstItemBottom);
baseX = firstItemLeft + (firstItemRight - firstItemLeft) / 2; baseX = firstItemLeft + (firstItemRight - firstItemLeft) / 2;
baseY = firstItemTop + (firstItemBottom - firstItemTop) / 2; baseY = firstItemTop + (firstItemBottom - firstItemTop) / 2;
unitW = benchmark1Left + (benchmark1Right - benchmark1Left) / 2 - ( firstItemLeft + (firstItemRight - firstItemLeft) / 2 ); unitW = benchmark1Left + (benchmark1Right - benchmark1Left) - ( firstItemLeft + (firstItemRight - firstItemLeft) / 2 );
unitH = ( firstItemTop + (firstItemBottom - firstItemTop) / 2 ) - (benchmark1Top + (benchmark1Bottom - benchmark1Top) / 2); unitH = ( firstItemTop + (firstItemBottom - firstItemTop) / 2 ) - (benchmark1Top + (benchmark1Bottom - benchmark1Top) / 2);
} }
console.log(' baseX ~~~ ', baseX);
console.log(' baseY ~~~ ', baseY);
console.log(' unitW ~~~ ', unitW); console.log(' unitW ~~~ ', unitW);
console.log(' unitH ~~~ ', unitH); console.log(' unitH ~~~ ', unitH);
...@@ -1636,7 +1762,7 @@ cc.Class({ ...@@ -1636,7 +1762,7 @@ cc.Class({
// const dot = this.getColorDot(x, -y, newW, newH); // const dot = this.getColorDot(x, -y, newW, newH);
const dot = this.getColorDot(x, -y, w, h); const dot = this.getColorDot(x, -y, w / 2, h / 2);
...@@ -1652,7 +1778,7 @@ cc.Class({ ...@@ -1652,7 +1778,7 @@ cc.Class({
// console.log('dotArr: ', dotArr);
console.log('benchmark1LabelData: ', benchmark1LabelData); console.log('benchmark1LabelData: ', benchmark1LabelData);
const answerData = {}; const answerData = {};
...@@ -1662,7 +1788,7 @@ cc.Class({ ...@@ -1662,7 +1788,7 @@ cc.Class({
const wordDataArr = this.getPhotoWordArr(checkLetter.labelText, text, benchmark1LabelData); const wordDataArr = this.getPhotoWordArr(checkLetter.labelText, text, benchmark1LabelData);
// console.log('~~~wordDataArr: ', wordDataArr); console.log('~~~wordDataArr: ', wordDataArr);
for (let i=0; i<wordDataArr.length; i++) { for (let i=0; i<wordDataArr.length; i++) {
...@@ -1685,10 +1811,11 @@ cc.Class({ ...@@ -1685,10 +1811,11 @@ cc.Class({
// console.log('colorRect: ', colorRect); // console.log('colorRect: ', colorRect);
const label = this.getLabel(content); const label = this.getLabel(content, colorRect.scaleX * colorRect.width);
label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX; label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX;
label.y = colorRect.y - colorRect.height / 2 //* colorRect.scaleY; label.y = colorRect.y + colorRect.height / 2 * colorRect.scaleY;
label.color = cc.Color.GREEN; label.color = cc.Color.BLACK;
this.debugDrawLayer.addChild(label); this.debugDrawLayer.addChild(label);
...@@ -1715,15 +1842,8 @@ cc.Class({ ...@@ -1715,15 +1842,8 @@ cc.Class({
const colorbenchmark1Rect = this.getColorRect(benchmark1Rect, 'green'); const colorbenchmark1Rect = this.getColorRect(benchmark1Rect, 'green');
this.debugDrawLayer.addChild(colorbenchmark1Rect); this.debugDrawLayer.addChild(colorbenchmark1Rect);
const benchmark2Rect = {
x: benchmark2Left,
y: -benchmark2Bottom,
width: Math.abs( benchmark2Left - benchmark2Right ),
height: Math.abs( benchmark2Top - benchmark2Bottom ),
}
const colorbenchmark2Rect = this.getColorRect(benchmark2Rect, 'green');
this.debugDrawLayer.addChild(colorbenchmark2Rect);
// const rectTop = { // const rectTop = {
...@@ -1997,10 +2117,10 @@ cc.Class({ ...@@ -1997,10 +2117,10 @@ cc.Class({
setOneAnswerData(colorRect, dotArr, answerData, line) { setOneAnswerData(colorRect, dotArr, answerData, line) {
// console.log(' in setOneAnswerData') console.log(' in setOneAnswerData')
// console.log('colorRect: ', colorRect) console.log('colorRect: ', colorRect)
// console.log('dotArr: ', dotArr) console.log('dotArr: ', dotArr)
// console.log('answerData: ', answerData) console.log('answerData: ', answerData)
const rect = colorRect.ccRect; const rect = colorRect.ccRect;
...@@ -2010,9 +2130,9 @@ cc.Class({ ...@@ -2010,9 +2130,9 @@ cc.Class({
const {dotRect, labelText, key} = dotArr[i]; const {dotRect, labelText, key} = dotArr[i];
// console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() ); console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() );
// console.log('labelText.toLowerCase() : ', labelText.toLowerCase() ); console.log('labelText.toLowerCase() : ', labelText.toLowerCase() );
// console.log('rect.intersects(dotRect) : ', rect.intersects(dotRect) ); console.log('rect.intersects(dotRect) : ', rect.intersects(dotRect) );
if (labelText.toLowerCase().indexOf(targetLabelText.toLowerCase()) != -1 && rect.intersects(dotRect)) { if (labelText.toLowerCase().indexOf(targetLabelText.toLowerCase()) != -1 && rect.intersects(dotRect)) {
const len = targetLabelText.trim().length; const len = targetLabelText.trim().length;
...@@ -2077,7 +2197,7 @@ cc.Class({ ...@@ -2077,7 +2197,7 @@ cc.Class({
getColorDot(x, y, w=100, h=100, color='blue') { getColorDot(x, y, w=100, h=100, color='red') {
const node = new cc.Node(); const node = new cc.Node();
if (!h) { if (!h) {
...@@ -2104,10 +2224,10 @@ cc.Class({ ...@@ -2104,10 +2224,10 @@ cc.Class({
const colorDot = getSprNode(color); const colorDot = getSprNode(color);
colorDot.anchorX = 0; // colorDot.anchorX = 0;
colorDot.anchorY = 0; // colorDot.anchorY = 0;
colorDot.x = rect.x; // colorDot.x = rect.x;
colorDot.y = rect.y; // colorDot.y = rect.y;
colorDot.scaleX = rect.width / colorDot.width; colorDot.scaleX = rect.width / colorDot.width;
colorDot.scaleY = rect.height / colorDot.height; colorDot.scaleY = rect.height / colorDot.height;
node.addChild(colorDot); node.addChild(colorDot);
...@@ -2443,100 +2563,8 @@ cc.Class({ ...@@ -2443,100 +2563,8 @@ cc.Class({
getPhotoData(cb) { getPhotoData(cb) {
const tmpData1 = { const tmpData1 = {"result":{"text":[{"left":0.08800879865884781,"right":0.42794278264045715,"top":0.010067113675177097,"bottom":0.16778524219989777,"score":1,"content":"CTrace,write,and say."},{"left":0.09350935369729996,"right":0.48184818029403687,"top":0.1845637559890747,"bottom":0.46644294261932373,"score":0.9882554411888123,"content":"AAAA"},{"left":0.5731573104858398,"right":0.6347634792327881,"top":0.20469798147678375,"bottom":0.463087260723114,"score":0.9638504385948181,"content":"A"},{"left":0.751375138759613,"right":0.8129813075065613,"top":0.20134228467941284,"bottom":0.4563758373260498,"score":0.8285241723060608,"content":"A"},{"left":0.5665566325187683,"right":0.6281628012657166,"top":0.6677852272987366,"bottom":0.8791946172714233,"score":0.8251835703849792,"content":"a"}]}}
"result":{ // const tmpData1 = {"result":{"text":[{"left":0.09814612567424774,"right":0.4471101462841034,"top":0.006644518114626408,"bottom":0.15614618360996246,"score":1,"content":"CTrace,write,and say."},{"left":0.10796073824167252,"right":0.5049073100090027,"top":0.1827242523431778,"bottom":0.4518272280693054,"score":0.9702169299125671,"content":"AAAA"},{"left":0.5834242105484009,"right":0.659760057926178,"top":0.17607973515987396,"bottom":0.4485049843788147,"score":0.9523985981941223,"content":"A"},{"left":0.6706652045249939,"right":0.8298800587654114,"top":0.15614618360996246,"bottom":0.43853819370269775,"score":0.9089533090591431,"content":"A"},{"left":0.5866957306861877,"right":0.6521264910697937,"top":0.634551465511322,"bottom":0.8504983186721802,"score":0.8326067328453064,"content":"a"},{"left":0.7699018716812134,"right":0.8276990056037903,"top":0.6411960124969482,"bottom":0.8039867281913757,"score":0.8035371899604797,"content":"a"}]}}
"text":[
{
"left":0,
"right":0.33299797773361206,
"top":0.0971250981092453,
"bottom":0.12354312092065811,
"score":1,
"content":"CTrace,write,and say."
},
{
"left":0.14084507524967194,
"right":0.9476861357688904,
"top":0.13131313025951385,
"bottom":0.21445220708847046,
"score":0.9066159129142761,
"content":"AAAA-A-AA"
},
{
"left":0.28470826148986816,
"right":0.9315895438194275,
"top":0.2735042870044708,
"bottom":0.32867133617401123,
"score":0.9610617756843567,
"content":"aaaq qa"
},
{
"left":0.03018108569085598,
"right":0.6438632011413574,
"top":0.37995338439941406,
"bottom":0.41025641560554504,
"score":1,
"content":"Listen. Then write Aa or cross it out. o5"
},
{
"left":0.636820912361145,
"right":0.7655935883522034,
"top":0.4755244851112366,
"bottom":0.5314685106277466,
"score":0.8729087710380554,
"content":"Aa"
},
{
"left":0.10663983970880508,
"right":0.11167001724243164,
"top":0.5788655877113342,
"bottom":0.6021755933761597,
"score":0.7464486360549927,
"content":"4"
},
{
"left":0.1589537262916565,
"right":0.29074445366859436,
"top":0.5936285853385925,
"bottom":0.6596736311912537,
"score":0.8887001872062683,
"content":"Aa"
},
{
"left":0.6549295783042908,
"right":0.7786720395088196,
"top":0.5920745730400085,
"bottom":0.6643356680870056,
"score":0.9307805895805359,
"content":"Aa"
},
{
"left":0.11267605423927307,
"right":0.4034205377101898,
"top":0.7700077891349792,
"bottom":0.807303786277771,
"score":1,
"content":"Lusten and chant, bd"
},
{
"left":0.28973841667175293,
"right":0.7162978053092957,
"top":0.9254079461097717,
"bottom":0.9712509512901306,
"score":0.9342746138572693,
"content":"户藤미 Ow"
},
{
"left":0.8158953785896301,
"right":0.7203219532966614,
"top":0.9611499905586243,
"bottom":0.9370629191398621,
"score":0.7845855951309204,
"content":"0章"
}
]
}
}
cb(tmpData1); cb(tmpData1);
return; return;
// const tmpData = {"allText":"Look and Trace\nblackboard\nwindow","block":[{"line":[{"word":[{"content":"Look","cornerPoint":[{"x":87,"y":203},{"x":83,"y":166},{"x":93,"y":164},{"x":97,"y":201}],"location":{"bottom":97,"left":85,"right":124,"top":83},"recognizedLanguage":"und"},{"content":"and","cornerPoint":[{"x":85,"y":161},{"x":82,"y":138},{"x":90,"y":137},{"x":93,"y":160}],"location":{"bottom":93,"left":127,"right":151,"top":82},"recognizedLanguage":"und"},{"content":"Trace","cornerPoint":[{"x":81,"y":132},{"x":77,"y":96},{"x":86,"y":95},{"x":90,"y":131}],"location":{"bottom":90,"left":156,"right":193,"top":77},"recognizedLanguage":"und"}]}]},{"line":[{"word":[{"content":"blackboard","cornerPoint":[{"x":119,"y":129},{"x":116,"y":58},{"x":131,"y":57},{"x":134,"y":128}],"location":{"bottom":134,"left":159,"right":231,"top":116},"recognizedLanguage":"und"}]}]},{"line":[{"word":[{"content":"window","cornerPoint":[{"x":171,"y":123},{"x":166,"y":72},{"x":177,"y":70},{"x":182,"y":121}],"location":{"bottom":182,"left":165,"right":218,"top":166},"recognizedLanguage":"und"}]}]}]} // const tmpData = {"allText":"Look and Trace\nblackboard\nwindow","block":[{"line":[{"word":[{"content":"Look","cornerPoint":[{"x":87,"y":203},{"x":83,"y":166},{"x":93,"y":164},{"x":97,"y":201}],"location":{"bottom":97,"left":85,"right":124,"top":83},"recognizedLanguage":"und"},{"content":"and","cornerPoint":[{"x":85,"y":161},{"x":82,"y":138},{"x":90,"y":137},{"x":93,"y":160}],"location":{"bottom":93,"left":127,"right":151,"top":82},"recognizedLanguage":"und"},{"content":"Trace","cornerPoint":[{"x":81,"y":132},{"x":77,"y":96},{"x":86,"y":95},{"x":90,"y":131}],"location":{"bottom":90,"left":156,"right":193,"top":77},"recognizedLanguage":"und"}]}]},{"line":[{"word":[{"content":"blackboard","cornerPoint":[{"x":119,"y":129},{"x":116,"y":58},{"x":131,"y":57},{"x":134,"y":128}],"location":{"bottom":134,"left":159,"right":231,"top":116},"recognizedLanguage":"und"}]}]},{"line":[{"word":[{"content":"window","cornerPoint":[{"x":171,"y":123},{"x":166,"y":72},{"x":177,"y":70},{"x":182,"y":121}],"location":{"bottom":182,"left":165,"right":218,"top":166},"recognizedLanguage":"und"}]}]}]}
......
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