Click here to Skip to main content
15,616,869 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi Hello, I would like to help with that. I drew the head of a heart with canvas html5 in mind and I tried to repeat it over and over again, but I failed. I hope you can help me in repeating it

What I have tried:

JavaScript
var la = document.getElementById("her");
var ra =la.getContext("2d");

var img = new Image ();
img.scr='canvas - createpattern.png';
img.onload = function (){
    var pattern = ra.createPattern(img,'repeat')
    ra.fillStyle= pattern ;
};

img.scr="file:///C:/Users/TOSHIba/Downloads/html/her123/her1.html"
ra.beginPath();

for (var i = 0; i
Posted
Updated 6-Apr-22 13:00pm
v2
Comments
Chris Copeland 6-Apr-22 6:02am    
This code is both incomplete and invalid, this wouldn't run at all within a browser. Can you post the most up-to-date and complete solution you've tried?
three three 6-Apr-22 19:06pm    
Can you contact me with this email? layanmanl123451234@gmail.com
Because the code does not appear in full here
three three 6-Apr-22 18:56pm    

<canvas id="her" width="600px" height="600px" style="border:4px solid black">


var la = document.getElementById("her");
var ra =la.getContext("2d");

var img = new Image ();
img.scr='canvas - createpattern.png';
img.onload = function (){

var pattern = ra.createPattern(img,'repeat')

ra.fillStyle= pattern ;





};

img.scr="file:///C:/Users/TOSHIba/Downloads/html/her123/her1.html"

ra.beginPath();





for (var i = 0; i < 2 ; i++) {


ra.moveTo(255,115)
ra.bezierCurveTo ( (293),(39), (497), (133), (294) , (323));









ra.moveTo(255,115);
ra.bezierCurveTo ( (169), (33), (113), (138), (294), (323));


ra.fill();




ra.fillStyle="#000000";
ra.lineWidth= 3;
ra.fillRect(0,0,600,600);














ra.fillStyle = '#050505';
ra.strokeStyle='#ef42f5';








































ra.fill();

ra.stroke();
ra.endpath();


}













































Weird, it worked for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900