













Code
<html>
<script type="text/javascript" src="wz_jsgraphics.js"></script><body>
<script type="text/javascript">
<!--
function getPrice(distance, night) {
var unitPrice = 2.0,
basicDistance = 3,
basicPrice = 10,
extDistance = 15,
extPrice = 3.0;
var price = 0.0;
if ( distance == 0 ) return 0;
if ( distance <= basicDistance ) return basicPrice;
if ( distance <= extDistance ) {
price = basicPrice + unitPrice * (distance - basicDistance);
return price;
}
price += basicPrice + unitPrice*(extDistance-basicDistance) + extPrice*(distance-extDistance)
return price;
}function getPriceWithReset(distance, night, reset) {
if ( reset == 0 ) {
return getPrice(distance, night);
} else {
return getPrice(reset, night) * Math.floor(distance/reset) + getPrice(distance % reset, night);
}
}var coordXUnit = 8, coordYUnit = 3,
basicX = 100, basicY = 50,
coordMaxX = 101, coordMaxY = 251;function drawString(str, x, y) {
jg.drawString(str, basicX+x*coordXUnit, basicY+(coordMaxY-y)*coordYUnit);
}
function drawPoint(x, y) {
drawLine(x, y, x, y);
}function drawLine(x1, y1, x2, y2) {
jg.drawLine(basicX + x1*coordXUnit, basicY + (coordMaxY-y1)*coordYUnit, basicX + x2*coordXUnit, basicY + (coordMaxY-y2)*coordYUnit);
}function drawPolyline(ax, ay) {
var axx = new Array(), ayy = new Array();for (var e in ax) {
axx.push(basicX + (ax[e] * coordXUnit) );
}for (var e in ay) {
ayy.push(basicY + (coordMaxY - ay[e])*coordYUnit);
}
jg.drawPolyline(axx, ayy);
}
drawCoordinate();
drawString(
drawString(getPriceWithReset(
35, 0, 15), 0, -20);此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。