rect পদ্ধতি
rect পদ্ধতি একটি নির্দিষ্ট বিন্দুতে একটি
আয়তক্ষেত্র আঁকে। stroke বা fill পদ্ধতি প্রয়োগ করলেই
এই আয়তক্ষেত্রটি দৃশ্যমান হবে।
প্রথম ক্ষেত্রে কনট্যুরটি দেখা যাবে, এবং দ্বিতীয় ক্ষেত্রে
- ভরাট আকারটি দেখা যাবে।
সিনট্যাক্স
context.rect(x, y, width, height)
উদাহরণ
চলুন rect ব্যবহার করে একটি কনট্যুর আঁকি:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.rect(50, 50, 100, 75);
ctx.stroke();
:
উদাহরণ
এবং এখন একটি ভরাট আকার আঁকুন:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.rect(50, 50, 100, 75);
ctx.fill();
:
আরও দেখুন
-
fillRectপদ্ধতি,
যা একটি ভরাট আয়তক্ষেত্র আঁকে -
strokeRectপদ্ধতি,
যা একটি আয়তক্ষেত্রের কনট্যুর আঁকে