* [task#127427] adjust rendering logic of think3c widget.
This commit is contained in:
+12
-11
@@ -1,11 +1,13 @@
|
||||
const colors = ['#CFE7FE', '#DCEFF9', '#E0EBFC', '#DBE9FA', '#D4EEE9', '#E4DFF7', '#E7EBF6'];
|
||||
$(document).ready(function()
|
||||
|
||||
window.initThinkCanvas = function()
|
||||
{
|
||||
const canvas = $('#canvas')[0];
|
||||
const ctx = canvas.getContext('2d');
|
||||
const image = new Image();
|
||||
const model = $('.model-canvas').data('model');
|
||||
|
||||
image.src = modelImg;
|
||||
image.src = `data/thinmory/thumbnail/init${model}.png`;
|
||||
image.onload = function()
|
||||
{
|
||||
const size = getCanvasSize(image.width, image.height);
|
||||
@@ -68,12 +70,7 @@ $(document).ready(function()
|
||||
/* 检查图片是否已加载完成,如未完成,手动触发处理逻辑。*/
|
||||
/* Check if the image has been loaded completely. If not, manually trigger the processing logic. */
|
||||
if(image.complete && image.naturalWidth != 0) image.onload();
|
||||
});
|
||||
|
||||
$(document).on('blur', '.model-canvas input', function()
|
||||
{
|
||||
$(this).attr('title', $(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染高亮的区域。
|
||||
@@ -292,7 +289,7 @@ function processRegionRows(data)
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function drawRegionInput(canvas, region, colorIndex)
|
||||
window.drawRegionInput = function(canvas, region, colorIndex)
|
||||
{
|
||||
region.minX += 30;
|
||||
region.maxY -= 10;
|
||||
@@ -303,7 +300,7 @@ function drawRegionInput(canvas, region, colorIndex)
|
||||
|
||||
let left = centerX - boxWidth / 2;
|
||||
let top = centerY - boxHeight / 2;
|
||||
if([0, 4, 5].includes(colorIndex)) top -= 40;
|
||||
if([0, 4, 5].includes(colorIndex)) top -= 40;
|
||||
if(colorIndex == 1) left -= 20;
|
||||
if(colorIndex == 2) left += 30;
|
||||
if(colorIndex == 4) left -= 50;
|
||||
@@ -347,8 +344,12 @@ function drawRegionInput(canvas, region, colorIndex)
|
||||
*/
|
||||
function renderRegionInput(regions)
|
||||
{
|
||||
const model = $('.model-canvas').data('model');
|
||||
let drawInputFunc = `drawRegionInputOf${model}`;
|
||||
drawInputFunc = (drawInputFunc in window) ? window[drawInputFunc] : window['drawRegionInput'];
|
||||
|
||||
regions.forEach((region, index) => {
|
||||
if(!$(`#input_${index}`).length) drawRegionInput($('#canvas')[0], region, index);
|
||||
if(!$(`#input_${index}`).length) drawInputFunc($('#canvas')[0], region, index);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user