xxxxxxxxxx
55
let skid_length_slider
function setup() {
createCanvas(400, 400);
skid_length_slider = createSlider(0, 1500)
}
function draw() {
background(220);
const distance = skid_length_slider.value()
const distance_meters = distance * 0.3048
const speed_wet = sqrt(30 * distance * 0.4)
const speed_wet_metric = speed_wet * 1.609344
const speed_dry = sqrt(30 * distance * 0.8)
const speed_dry_metric = speed_dry * 1.609344
fill(0)
let x = 40
let y = 40
text("Skid mark length", x, y)
y += 20
text(nf(distance, 1, 1) + " ft", x, y)
y += 20
text(nf(distance_meters, 1, 1) + " meters", x, y)
y += 20
y += 20
{
let y_local = y
text("Dry conditions", x, y_local)
y_local += 20
text(nf(speed_dry, 1, 1) + " mph", x ,y_local)
y_local += 20
text(nf(speed_dry_metric, 1, 1) + " kph", x ,y_local)
}
{
x += 120
let y_local = y
text("Wet conditions", x, y_local)
y_local += 20
text(nf(speed_wet, 1, 1) + " mph", x ,y_local)
y_local += 20
text(nf(speed_wet_metric, 1, 1) + " kph", x ,y_local)
}
}