canvas 2d toDataURL

AngDH發表於2024-07-29

var ab = document.createElement('canvas');
var ac = ab.getContext('2d');
ac['textBaseline'] = 'alphabetic';
ac['fillStyle'] = '#f60';
ac['fillRect'](0x7d, 0x1, 0x3e, 0x14);
ac['fillStyle'] = '#069';
ac['font'] = '11pt Arial';
ac['fillText']('Cwm fjordbank glyphs vext quiz, 😃', 0x2, 0xf);
ac['fillStyle'] = 'rgba(102, 204, 0, 0.7)';
ac['font'] = '18pt Arial';
ac['fillText']('Cwm fjordbank glyphs vext quiz, 😃', 0x4, 0x2d);
var ad = ac.createLinearGradient(0x0, 0x0, ab.width, ab.height);


ad.addColorStop(0x0, 'blue');
ad.addColorStop(0x1, 'red');
ac['fillStyle'] = ad;
ac['fillRect'](0x0, 0x19, 0x64, 0x64);
ac.beginPath();
ac.moveTo(0x32, 0x32);
ac.bezierCurveTo(0x14, 0x64, 0xc8, 0x64, 0xc8, 0x32);
ac.stroke();
ab.toDataURL();

相關文章