draw_frame = function(date) {
const overall_radius = jitter_radius / 100 * (Math.sin(Date.now()/1000) + 1)/2
const prop_list = []
let ix = -1
for (let feature of hi_res_counties) {
ix += 1
if (feature.vertices === null) {continue}
if (feature.coordinates === null) {continue}
if (handler.element_handler.get(ix) === undefined) {
handler.element_handler.set(ix, gl.elements({
primitive: 'triangles',
usage: 'static',
data: feature.vertices,
type: "uint" + feature.coord_resolution,
length: feature.vertices.length,
count: feature.vertices.length / feature.coord_resolution * 8
}))
handler.coord_handler.post_data(ix, feature.coordinates)
}
if (handler.get_prop("angle", ix) === undefined) handler.set_prop("angle", ix, 0)
let rand = handler.get_prop("rand", ix) || handler.set_prop("random", ix, 0)
const { STATE, COUNTY } = feature
let c_stats = long_term_corona_counts.get(STATE + COUNTY + "-" + date)
const pop = pops.get(`${STATE}${COUNTY}`)
if (c_stats == undefined) {
c_stats = {delta: 1, rolling: 0};
}
let { delta, rolling } = c_stats;
const rate = rolling/pop
const pop_per_area = pop/(feature.CENSUSAREA + 1e-10)
const magnitude = distortion(rate)
if (isNaN(delta)) {
delta = 1
} else if (delta <= 0) {
delta = .1
}
handler.set_prop("angle", ix, handler.get_prop("angle", ix) + delta_scale(delta))
const t = Math.sin(Date.now()/(600+rand[1]*10))
let color = incidence_color(rate) || 'rgb(0, 0, 0)'
let [r, g, b] = color.split(/\(|\)/)[1].split(",").map(d => +d)
//r = 128; g = 128; b = 128;
let x_shift = -feature.centroid_x
let y_shift = -feature.centroid_y
const v = {
color: [r/255, g/255, b/255],
zoom,
centroid: [feature.centroid_x, feature.centroid_y],
angle: handler.get_prop("angle", ix),
scale: scale_by_votes == "yes" ? size_scale(rolling/feature.CENSUSAREA) : 1,
elements: handler.element_handler.get(ix),
coords: handler.coord_handler.get(ix),
translate: [0, 0],
incidence: incidence
}
prop_list.push(v)
}
render(prop_list)
}