生产图片

master
夜笙歌 7 months ago
parent 3e2e9f3ad7
commit f97930769a

@ -6276,37 +6276,42 @@
<script>
$(()=>{
// 假设有一个颜色数组
const colors = [];
for(let i = 0;i<768;i+=3){
colors.push('#FF0000')
colors.push('#00FF00')
colors.push('#0000FF')
let getColorByTemperature = {
23:'#ff0000',
24:'#0000ff'
}
$.post(prefix+'/newDataStreak',(e)=>{
let colors = []
for(i in e.rows[0]){
if(i.includes('site')){
colors.push(getColorByTemperature[e.rows[0][i]])
}
}
// 获取canvas元素并设置上下文
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
// 设置canvas的宽度和高度
const width = $('#canvasDiv').width();
const height =($('#canvasDiv').width()/32) *24;
canvas.width = width;
canvas.height = height;
// 设置canvas的宽度和高度
const width = $('#canvasDiv').width();
const height =($('#canvasDiv').width()/32) *24;
canvas.width = width;
canvas.height = height;
const gridWidth = width / 32;
const gridHeight = height / 24;
const gridWidth = width / 32;
const gridHeight = height / 24;
// 遍历颜色数组,绘制矩形
for (let i = 0; i < 768; i++) {
const color = colors[i]; // 获取当前颜色
const x = (i % 32) * gridWidth; // 计算x坐标
const y = Math.floor(i / 32) * gridHeight; // 计算y坐标
// 遍历颜色数组,绘制矩形
for (let i = 0; i < 768; i++) {
const color = colors[i]; // 获取当前颜色
const x = (i % 32) * gridWidth; // 计算x坐标
const y = Math.floor(i / 32) * gridHeight; // 计算y坐标
// 绘制格子
ctx.fillStyle = color; // 设置填充颜色为十六进制颜色值
ctx.fillRect(x, y, gridWidth, gridHeight); // 绘制矩形格子
}
// 绘制格子
ctx.fillStyle = color; // 设置填充颜色为十六进制颜色值
ctx.fillRect(x, y, gridWidth, gridHeight); // 绘制矩形格子
}
})
})
</script>

Loading…
Cancel
Save