'Relative shadow sizes using drawingContext in p5.js

I'm having issues keeping my shadows consistent across different resolutions using the following:

  drawingContext.shadowOffsetY = 0;
  drawingContext.shadowBlur = w(0.01);
  drawingContext.shadowColor = 'black';

where

function w(val) {if (val == null) return width;return width * val;}

defines the relative size .

Any tips on how to keep tie the size of the shadow to the resolution?

Thanks



Solution 1:[1]

A ratio of the display with makes sense (at least for square compositions), but you might also want to support different display densities (e.g. for Apple Retina displays, smart phones, etc.). To do this look into:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 George Profenza