chart_update = {
var t_shade = 2 * sun_vec[2];
var ctx = chart.context;
var canvas = ctx.canvas;
var path = mkpath(ctx, chart.map_rect);
prepare_canvas(ctx);
var land_color = land_shade(t_shade);
ctx.fillStyle = land_color;
ctx.fill();
ctx.beginPath();
path(water_collection);
ctx.lineWidth = 1;
ctx.fillStyle = water_shade(t_shade);
ctx.strokeStyle = water_edge_shade(t_shade);
ctx.fill();
ctx.stroke();
const glare_colors = ['#7cf', '#ffa'];
for (var mode = wet_mode ? 0 : 1; mode < 2; ++mode) {
ctx.strokeStyle = d3.interpolate(land_color, glare_colors[mode])(.6);
for (var f of road_collection.features)
{
var misery = sun_strike_misery(f, mode == 0);
if (misery > .5)
{
ctx.beginPath();
ctx.lineWidth = 5 * (map_transform.k + 1) * (misery - .2);
path(f);
ctx.stroke();
}
}
}
ctx.save();
ctx.resetTransform();
ctx.drawImage(bg_canvas_ctx.canvas, 0, 0, canvas.width, canvas.height);
ctx.restore();
ctx.lineWidth = 1 + 0.5 * map_transform.k;
for (var f of road_collection.features)
{
var misery = sun_strike_misery(f, wet_mode);
if (misery > 0)
{
ctx.beginPath();
ctx.strokeStyle = sun_strike_shade(misery);
path(f);
ctx.stroke();
}
}
ctx.restore();
ctx.font = "18px 'Source Serif Pro', serif";
ctx.textBaseline = "top";
var mt = ctx.measureText(now_text_weekday);
ctx.fillStyle = "#0007";
ctx.fillRect(0, 0, mt.width + 10, 8 + 18);
ctx.fillStyle = "#fff";
ctx.fillText(now_text_weekday, 5, 4);
const r = 40;
ctx.transform(1, 0, 0, 1, 5 + r, 30 + r);
ctx.beginPath();
ctx.arc(0, 0, r, 2 * Math.PI, false);
ctx.fillStyle = water_shade(t_shade * 2 + 0.5)
ctx.strokeStyle = "#000";
ctx.fill();
ctx.stroke();
if (sun_position.altitude > 0)
{
var r_sun = (1 - sun_position.altitude * 2 / Math.PI) * (r - 5);
var x = -Math.sin(sun_position.azimuth) * r_sun;
var y = Math.cos(sun_position.azimuth) * r_sun;
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(x, y);
ctx.strokeStyle = "#ffa"
ctx.stroke();
ctx.beginPath();
ctx.arc(x, y, 5, 2 * Math.PI, false);
ctx.fillStyle = "#fc4"
ctx.strokeStyle = "#a50";
ctx.fill();
ctx.stroke();
}
ctx.font = "14px 'Source Serif Pro', serif";
var deg_txt = (sun_position.altitude * 180 / Math.PI).toFixed(1);
var mt = ctx.measureText(deg_txt);
ctx.fillStyle = "#000";
ctx.fillText(deg_txt + '°', -mt.width / 2, lon_lat[1] > 0 ? -r+4 : r-15);
ctx.restore();
}