विधि strokeText

strokeText विधि canvas पर पाठ की रूपरेखा बनाती है। पहला पैरामीटर ड्राइंग के लिए पाठ लेता है, और दूसरा और तीसरा - कैनवास कैनवास पर इस पाठ के निर्देशांक। आकार और फ़ॉन्ट प्रकार font गुण का उपयोग करके निर्धारित किए जाते हैं।

वाक्य - विन्यास

javascriptcontext.strokeRect(पाठ, x, y);

उदाहरण

आइए strokeRect का उपयोग करके पाठ की रूपरेखा बनाएं, इसे 30px आकार और Arial प्रकार दें:

html<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
javascriptlet canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');

ctx.font = '30px Arial';
ctx.strokeText('Hello world', 30, 50);

Результат:

यह भी देखें

  • fillText विधि,
    जो सामान्य पाठ बनाती है
  • font गुण,
    जो आकार और फ़ॉन्ट प्रकार निर्धारित करता है