Web Programming with html5, css, and JavaScript
Web Programming with HTML5, CSS, and JavaScript
onclick="addCheerleader();"> onclick="displayStuntGroup();"> onclick="rotateClockwise();"> onclick="moveUp();"> Solar Shadowing by Collector Array614 Chapter 12 Canvas FIGUre 12.23a JavaScript file for Solar Shadowing web page /*********************************************************************** * solarAngles.js * John Dean * * This file contains functions supporting solarShadowing.html ***********************************************************************/ var image; // image of one row of PV solar collectors var form; // html input form var spacing; // pixel distance between array bases var slope; // radians up from horizontal facing south var canvas; // active display var context; // nature of active display var length = 0.5 * 160; // 80 pixels for 160 cm panel height var X0 = 50; // left side of arrays var Y0; // bottom of north array var dyP; // panel bottom-to-top horizontal projection var altitude; // solar altitude angle above horizon var azimuth; // solar azimuth angle from south var cosIncidenceAngle; // angle between sun and normal to panel var timer; // timer controlling display dynamics // This function is called when the Install Collectors button is clicked. function setup(solarForm) { image = document.getElementById("pvArray"); form = solarForm; spacing = length * parseFloat(form.elements["spacing"].value); slope = form.elements["panelSlope"].value * Math.PI/180; canvas = document.getElementById("topView"); context = canvas.getContext("2d"); canvas.style.backgroundColor = "lightgray"; context.clearRect(0, 0, canvas.width, canvas.height); context.fillStyle = "black"; context.font = "1em Tahoma"; context.fillText("(North)", 324, 20); if (slope < 0) { // north-facing panels Y0 = 0.5 * (canvas.height - spacing - length); dyP = + length * Math.cos(slope); // south end higher } else { // south-facing panels Y0 = 0.5 * (canvas.height - spacing + length); dyP = - length * Math.cos(slope); // north end higher } drawOneArray(Y0); drawOneArray(Y0 + spacing); } // end setup 615 12.12 Case Study: Solar Shadowing Dynamics The setup function executes when a user clicks the web page’s Install Collectors button. It initializes the first five global variables and sets the canvas background color. It then clears the canvas drawing area. The clearing operation is not necessary at first, but after a change in Panel Slope, it is needed to remove previously painted panels. The setup method then writes “(North)” at the top of the canvas drawing area to orient the user. The X0 and Y0 variables specify the location of the lower west corner of the northern panel array such that the two arrays will be equally spaced north and south of the centerline of the canvas if their slopes are zero, that is, if they are horizontal. If the panels face south— positive panelSlope —the lower end is the south end. If the panels face north—negative panelSlope — the lower end is the north end. The dyP variable is the horizontal projection of the distance from the lower end of either array to the upper end of that same array. It’s the canvas’s y -distance in pixels. For north-sloping (southern hemisphere) arrays, dyP is downward and positive. For south-sloping (northern hemisphere) arrays, dyP is upward and negative. The setup function ends by making a call to the subordinate drawOneArray function for each of the two panel arrays. FIGUre 12.23B shows the drawOneArray function. First the function deposits a collec- tor image that is scaled down in the y -direction to depict an overhead view of a sloped surface. Because the context.scale function scales both the image and its location, this scaling must be reversed for the y -location argument in the drawImage method call to make the deposited image’s location independent of slope. Because the drawImage method specifies the location by the image’s minimum- x and minimum- y (its Northwest corner), and because y0 specifies the location of the lower edge of the array and the lower edge is the southern edge when slope is Download 18,68 Mb. Do'stlaringiz bilan baham: Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024 ma'muriyatiga murojaat qiling |
kiriting | ro'yxatdan o'tish Bosh sahifa юртда тантана Боғда битган Бугун юртда Эшитганлар жилманглар Эшитмадим деманглар битган бодомлар Yangiariq tumani qitish marakazi Raqamli texnologiyalar ilishida muhokamadan tasdiqqa tavsiya tavsiya etilgan iqtisodiyot kafedrasi steiermarkischen landesregierung asarlaringizni yuboring o'zingizning asarlaringizni Iltimos faqat faqat o'zingizning steierm rkischen landesregierung fachabteilung rkischen landesregierung hamshira loyihasi loyihasi mavsum faolyatining oqibatlari asosiy adabiyotlar fakulteti ahborot ahborot havfsizligi havfsizligi kafedrasi fanidan bo’yicha fakulteti iqtisodiyot boshqaruv fakulteti chiqarishda boshqaruv ishlab chiqarishda iqtisodiyot fakultet multiservis tarmoqlari fanidan asosiy Uzbek fanidan mavzulari potok asosidagi multiservis 'aliyyil a'ziym billahil 'aliyyil illaa billahil quvvata illaa falah' deganida Kompyuter savodxonligi bo’yicha mustaqil 'alal falah' Hayya 'alal 'alas soloh Hayya 'alas mavsum boyicha yuklab olish |