gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
drawHistoryTcks: ( ctx: CanvasRenderingContext2D, tcks: number[], side: string,…
- User
drawHistoryTcks: ( ctx: CanvasRenderingContext2D, tcks: number[], side: string, isBestPrice: boolean, yPosition: number, cellHeight: number, fullWidth: number, dpiScale: number, darkMode: boolean, ) => { ctx.textBaseline = "middle";
codelet currentX = marginForOrders + 100; for (let i = 0; i < Math.min(tcks.length, 10); i++) { const tck = tcks[i]; if (tck === 0) { continue; } const {width} = ctx.measureText(`${tck / 10}`); const textWidth = width + cupOptions().cell.paddingX * dpiScale * 2; const transparency = 1 - i * 0.1; const color = side === "bid" ? "77, 150, 123" : "208, 112, 109"; ctx.fillStyle = `rgba(${color}, ${transparency})`; ctx.fillRect(currentX, yPosition + 3, textWidth + 2, 26); ctx.fillStyle = cupTools.getQuantityColor(side, isBestPrice, darkMode); ctx.fillText( `${tck / 10}`, currentX + cupOptions().cell.paddingX * dpiScale, yPosition + cellHeight / 2, ); currentX += textWidth + 4; }},
нужно, чтобы если tck === 0 его не отрисовывать, но чтобы индекс учитывался для следующих, то есть если первый и второй tck равен нулю, а третий 5, то третий должен отрисовываться дальше по индексу, на третьем месте
- Assistant
Вот обновленный код функции drawHistoryTcks с добавленной логикой игнорирования значений tck, равных нулю:
javascript