javascript - Upload image in div of different size using html5 -


i want upload image box (div) may rectangle, square , circle or of shape using html5

something below enter image description here

any appreciated

from comments assume know how upload , draw image normally, explain how image "into shape" when drawing it.

take @ compositing settings of 2d context. these allow use path or image perform masking on canvas.

  1. draw image canvas in desired size
  2. create path marks edges of shape want "cut out". 3. set context.fillcolor solid without alpha transparency when don't did so
  3. set context.globalcompositeoperation = 'destination-in'
  4. use context.fillpath draw path in destination-in mode. erases outside of path , keeps inside path.
  5. set context.globalcompositeoperation = 'source-over'` restore normal drawing behavior.

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -