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
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.
- draw image canvas in desired size
- create path marks edges of shape want "cut out". 3. set
context.fillcolor
solid without alpha transparency when don't did so - set
context.globalcompositeoperation = 'destination-in'
- use
context.fillpath
draw path in destination-in mode. erases outside of path , keeps inside path. - set context.globalcompositeoperation = 'source-over'` restore normal drawing behavior.
Comments
Post a Comment