قماش HTML createRadialGradient () الطريقة

❮ مرجع قماش HTML

مثال

ارسم مستطيلاً واملأه بتدرج لوني نصف قطري / دائري:

لا يدعم متصفحك HTML5canvastag.

جافا سكريبت:

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");

var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");

// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10, 10, 150, 100);

دعم المتصفح

تحدد الأرقام الواردة في الجدول إصدار المتصفح الأول الذي يدعم الطريقة بالكامل.

Method
createRadialGradient() Yes 9.0 Yes Yes Yes

التعريف والاستخدام

تنشئ طريقة createRadialGradient () كائنًا متدرجًا شعاعيًا / دائريًا.

يمكن استخدام التدرج لتعبئة المستطيلات والدوائر والخطوط والنص وما إلى ذلك.

تلميح: استخدم هذا الكائن كقيمة لخصائص strokeStyle أو fillStyle .

نصيحة: استخدم طريقة addColorStop () لتحديد ألوان مختلفة ، ومكان وضع الألوان في كائن التدرج اللوني.

بناء جملة JavaScript: السياق .createRadialGradient ( x0، y0، r0، x1، y1، r1 ) ؛

قيمه المعامل

Parameter Description
x0 The x-coordinate of the starting circle of the gradient
y0 The y-coordinate of the starting circle of the gradient
r0 The radius of the starting circle
x1 The x-coordinate of the ending circle of the gradient
y1 The y-coordinate of the ending circle of the gradient
r1 The radius of the ending circle

❮ مرجع قماش HTML