javascript - HTML Canvas not displaying my rectangles -


  & lt;! DOCTYPE html & gt; & lt; html lang = "en" & gt; & Lt; शीर्ष & gt; & Lt; मेटा वर्णसेट = "यूटीएफ -8" & gt; & LT; स्क्रिप्ट & gt; window.onload = function () {var कैनवास = दस्तावेज़.getElementById ("नक्शा"), c = canvas.getContext ("2d"); cf.fillStyle = "काला"; C.fillRect (0, 0, कैनवास। वाइड, कैनवास। हाइट); c.fillStyle = "red"; C.fillRect = (20, 30, 50, 250); c.fillSyle = "white"; CfillRect = (50,50,25,25); }; & Lt; / स्क्रिप्ट & gt; & Lt; / head & gt; & LT; बॉडी & gt; & Lt; कैनवास आईडी = "नक्शा" चौड़ाई = "800" ऊंचाई = "400" & gt; & Lt; img src = "चित्र / उदास डायनासोर। Jpg" / & gt; आपको इस पृष्ठ को देखने के लिए एक अद्यतन ब्राउज़र की आवश्यकता होगी! & Lt; / कैनवास & gt; & Lt; / body & gt; & Lt; / html & gt;   

मैं कैनवास के साथ थोड़ा सा तंग कर रहा हूं जो मुझे यह महसूस करने की कोशिश करता है कि यह कैसे काम करता है। हालांकि, मैं देख रहा हूँ ट्यूटोरियल वीडियो c.fillRect और c.fillStyle के लिए कोडिंग को सटीक रूप से उसी प्रारूप में दिखाता है जो मैंने अपने कोड में दिखाया है, अभी तक मेरी स्क्रीन केवल पहले निर्देशों के सेट से काले आयताकार दिखाती है।

fillRect के लिए वाक्यविन्यास है c.fillRect (...) , के विपरीत c.fillRect = (...) । अपने पिछले कॉल के साथ अपनी पहली कॉल की तुलना करें।

इसके अलावा, आपका अंतिम fillStyle को fillSyle के रूप में गलत टाइप किया गया है।

  window.onload = function () {var canvas = document.getElementById (" नक्शा "), c = canvas.getContext (" 2d "); cf.fillStyle = "काला"; C.fillRect (0, 0, कैनवास। वाइड, कैनवास। हाइट); c.fillStyle = "red"; C.fillRect (20, 30, 50, 250); c.fillStyle = "white"; C.fillRect (50, 50, 25, 25); };   



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

php - How can I cram 6+31 numeric characters into 22 alphanumeric characters? -

mysql - where clause in inner join query -