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

❮ مرجع قماش HTML

الصورة المراد استخدامها:

خروف

مثال

كرر الصورة أفقيًا وعموديًا:

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

جافا سكريبت:

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("lamp");
var pat = ctx.createPattern(img, "repeat");
ctx.rect(0, 0, 150, 100);
ctx.fillStyle = pat;
ctx.fill();

دعم المتصفح

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

Method
createPattern() Yes 9.0 Yes Yes Yes

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

تكرر طريقة createPattern () العنصر المحدد في الاتجاه المحدد.

يمكن أن يكون العنصر صورة أو فيديو أو عنصر <canvas> آخر.

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

بناء جملة JavaScript: سياق .createPattern ( صورة ، "كرر | كرر س | كرر ص | لا تكرار") ؛

قيمه المعامل

Parameter Description Play it
image Specifies the image, canvas, or video element of the pattern to use  
repeat Default. The pattern repeats both horizontally and vertically
repeat-x The pattern repeats only horizontally
repeat-y The pattern repeats only vertically
no-repeat The pattern will be displayed only once (no repeat)

❮ مرجع قماش HTML