Web Programming with html5, css, and JavaScript



Download 18,68 Mb.
Pdf ko'rish
bet86/98
Sana28.10.2022
Hajmi18,68 Mb.
#857632
1   ...   82   83   84   85   86   87   88   89   ...   98
Bog'liq
Web Programming with HTML5, CSS, and JavaScript

FIGUre 12.23G
shows the rest of 
solarAngles.js
. The 
runClock
function executes 
when a user clicks the web page’s 
Run Clock
button. It starts by initializing the global 
timer
variable with a 
handle,
which refers to a 
handler
method. It does this by invoking a predefined 
window
method called 
setInterval
, whose first argument is the name of the handler method 
the browser is to call at the ends of successive time intervals, and whose second argument is the 
desired length of those time intervals in milliseconds. The handler method is usually a custom 
JavaScript function. In the present case, it’s the 
updateDisplay
function also in Figure 12.23G. 
621
12.12 Case Study: Solar Shadowing Dynamics


FIGUre 12.23F 
JavaScript file for Solar Shadowing web page
function getObscuration(x0, y0) {
var latitude; // earth latitude
var projLength; // north-south horizontal projection
var width; // east-west width of panel array
var tanShadeAngle; // tan(shade angle)
var shadeLength; // upward in panel plane
var offset; // east-west shadow offset
var obscuredWidth; // east-west inter-panel shadow extent 
var obscuration = 0; // fractional inter-panel shadowing
latitude = form.elements["latitude"].value * Math.PI/180;
projLength = image.height * Math.cos(slope);
width = image.width;
context.globalAlpha = 0.4; // shadow opacity
context.fillStyle = "black";
// Sun behind panels
if (cosIncidenceAngle <= 0) {
// cover bottom edge but keep top edge white
if (slope > 0) {y0 = y0 + 2 - projLength;}
context.fillRect(x0, y0 - 1, width, projLength);
} // end if
// Inter-panel shading
else if (Math.cos(azimuth) * (y0 - 0.5 * canvas.height) > 0 &&
latitude * slope > 0) {
tanShadeAngle = Math.tan(altitude) / Math.cos(azimuth - Math.PI);
shadeLength = length 
- spacing / (Math.cos(slope) + Math.sin(slope) / tanShadeAngle);
if (shadeLength < 0) {shadeLength = 0;} // no obscuration
projLength = shadeLength * Math.cos(slope);
offset = Math.abs(Math.tan(azimuth) *
(spacing + projLength - length * Math.cos(slope))); 
if (slope > 0) {y0 += 1;} // cover image bottom
else {projLength = - projLength;}
if (Math.sin(azimuth) < 0) {
context.fillRect(x0 + offset, y0, width - offset, - projLength);}
else {context.fillRect(x0, y0, width - offset, - projLength);}
obscuration = (shadeLength * (width - offset)) / (length * width);
if (obscuration < 0) {obscuration = 0;}
} // end else if
context.globalAlpha = 1.0;
return obscuration;
} // end getObscuration

Download 18,68 Mb.

Do'stlaringiz bilan baham:
1   ...   82   83   84   85   86   87   88   89   ...   98




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