Here is how I approached this issue using Zerb Foundation 3 responsive web framework, Javascript, jQuery and Processing.js. You can take a look at Living Map Project if you want to dig through the source.
in javascript / jquery:
// handle page resizing
$(window).resize(function() {
var pjs = Processing.getInstanceById('livingmap');
pjs.resizeSketch(document.getElementById('div_p5canvas').offsetWidth, document.getElementById('div_p5canvas').offsetHeight);
} );
in your .pde processing js code (note: the calculation was what I felt worked well using zurb's foundation 3, the grid I defined and how that translated as pixels:
void resizeSketch(int w, int h) {
if (w < 680) {
size(w, floor(float(w)/680*610) - 30);
} else size(680, 610 - 30);
}
in your html:
<div class="flex-video widescreen" id="div_p5canvas"
<canvas id="livingmap" data-processing-sources="livingmap_2.pde" style="height:auto; width:auto; focus { outline: 0; }" tabindex="1"></canvas>
</div>