本文整理汇总了TypeScript中lodash.round函数的典型用法代码示例。如果您正苦于以下问题:TypeScript round函数的具体用法?TypeScript round怎么用?TypeScript round使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了round函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: character
export function character(character: Character, camera: Camera, context: any): void {
// assume the character should be centered
let screenX: number = character.centerPosition.x;
let screenY: number = character.centerPosition.y;
if (character.is.leftOfCenter) {
screenX = character.x;
};
if (character.is.rightOfCenter) {
// character's max screenX - character's distance from the map's right edge
screenX = (camera.width - character.width) - (character.maxX - character.x);
}
if (character.is.upOfCenter) {
screenY = character.y;
}
if (character.is.downOfCenter) {
// character's max screenY - character's distance from the map's bottom edge
screenY = (camera.height - character.height) - (character.maxY - character.y);
}
context.drawImage(
character.image,
_.round(screenX),
_.round(screenY),
character.width,
character.height
);
}
示例2: generateCourtOfferedPaymentIntention
static generateCourtOfferedPaymentIntention (draft: DraftClaimantResponse, claim: Claim, decisionType: DecisionType): PaymentIntention {
const courtOfferedPaymentIntention = new PaymentIntention()
const claimResponse = claim.response as FullAdmissionResponse | PartialAdmissionResponse
const admittedClaimAmount: number = AdmissionHelper.getAdmittedAmount(claim)
if (decisionType === DecisionType.CLAIMANT || decisionType === DecisionType.CLAIMANT_IN_FAVOUR_OF_DEFENDANT) {
courtOfferedPaymentIntention.paymentOption = PaymentOption.IMMEDIATELY
courtOfferedPaymentIntention.paymentDate = MomentFactory.currentDate().add(5, 'days')
}
if (decisionType === DecisionType.COURT) {
const paymentPlanFromDefendantFinancialStatement: PaymentPlan = PaymentPlanHelper.createPaymentPlanFromDefendantFinancialStatement(claim, draft)
if (claimResponse.paymentIntention.paymentOption === PaymentOption.INSTALMENTS) {
const defendantFrequency: Frequency = Frequency.of(claimResponse.paymentIntention.repaymentPlan.paymentSchedule)
const paymentPlanConvertedToDefendantFrequency: PaymentPlan = paymentPlanFromDefendantFinancialStatement.convertTo(defendantFrequency)
courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
courtOfferedPaymentIntention.repaymentPlan = {
firstPaymentDate: paymentPlanConvertedToDefendantFrequency.startDate,
instalmentAmount: paymentPlanConvertedToDefendantFrequency.instalmentAmount > admittedClaimAmount ?
admittedClaimAmount : _.round(paymentPlanConvertedToDefendantFrequency.instalmentAmount,2),
paymentSchedule: Frequency.toPaymentSchedule(paymentPlanConvertedToDefendantFrequency.frequency),
completionDate: paymentPlanConvertedToDefendantFrequency.calculateLastPaymentDate(),
paymentLength: paymentPlanConvertedToDefendantFrequency.calculatePaymentLength()
}
} else {
const paymentPlanConvertedToMonthlyFrequency: PaymentPlan = paymentPlanFromDefendantFinancialStatement.convertTo(Frequency.MONTHLY)
courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
courtOfferedPaymentIntention.repaymentPlan = {
firstPaymentDate: paymentPlanConvertedToMonthlyFrequency.startDate,
instalmentAmount: paymentPlanConvertedToMonthlyFrequency.instalmentAmount > admittedClaimAmount ?
admittedClaimAmount : _.round(paymentPlanConvertedToMonthlyFrequency.instalmentAmount,2),
paymentSchedule: Frequency.toPaymentSchedule(paymentPlanConvertedToMonthlyFrequency.frequency),
completionDate: paymentPlanConvertedToMonthlyFrequency.calculateLastPaymentDate(),
paymentLength: paymentPlanConvertedToMonthlyFrequency.calculatePaymentLength()
}
}
}
if (decisionType === DecisionType.DEFENDANT) {
if (claimResponse.paymentIntention.paymentOption === PaymentOption.BY_SPECIFIED_DATE) {
courtOfferedPaymentIntention.paymentDate = claimResponse.paymentIntention.paymentDate
courtOfferedPaymentIntention.paymentOption = PaymentOption.BY_SPECIFIED_DATE
}
if (claimResponse.paymentIntention.paymentOption === PaymentOption.INSTALMENTS) {
courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
courtOfferedPaymentIntention.repaymentPlan = claimResponse.paymentIntention.repaymentPlan
}
}
return courtOfferedPaymentIntention
}
示例3: drawView
drawView(): void {
let offsetX: number = _.round(-this.camera.x + (this.tilesInView.startCol * this.map.tileWidth));
let offsetY: number = _.round(-this.camera.y + (this.tilesInView.startRow * this.map.tileHeight));
_.each(_.range(this.map.layers.length), (layer: number) => {
// if it is the correct layer, draw the character
if(this.character && layer === this.character.layer) {
this.drawCharacter();
};
// draw the layer
this.drawLayer(layer, offsetX, offsetY);
});
if(this.character && this.map.layers.length <= this.character.layer) {
this.drawCharacter();
};
}
示例4: calculateTotalAmount
static calculateTotalAmount (sources: IncomeExpenseSource[]): number {
const totalMonthlyAmount = _.reduce(sources, function (total: number, source: IncomeExpenseSource) {
const monthlyAmount = source.amount * source.schedule.valueInMonths
return total + monthlyAmount
}, 0)
return _.round(totalMonthlyAmount, 2)
}
示例5: constructor
constructor(id: number, factory: string, name: string, type: string,
storage: number, schema: Array<DatabaseSchema>) {
this.id = id;
this.factory = factory;
this.name = name;
this.type = type;
this.storage = storage;
this.schema = schema;
this.usedSpace = 0;
let ref = this;
_.forEach(this.schema, function(s) {
ref.usedSpace = ref.usedSpace + s.memoryUsedInGB;
});
this.availSpace = _.round(this.storage - this.usedSpace, 2);
this.usedSpace = _.round(this.usedSpace, 2);
}
示例6: toString
toString(): string {
const isOk = b => (b ? 'OK' : 'NG');
return (
`${padEnd(this.broker, 10)}: ${padStart(_.round(this.btc, 3), 5)} BTC, ` +
`${t`LongAllowed`}: ${isOk(this.longAllowed)}, ` +
`${t`ShortAllowed`}: ${isOk(this.shortAllowed)}`
);
}
示例7:
_.each(_.range(tiles.startCol, tiles.endCol + 1), (col: number) => {
let tile = map.layers[layer][row][col];
if (tile !== 0) {
let source = map.spriteSheet[tile];
let destX = ((col - tiles.startCol) * map.tileWidth) + offsetX;
let destY = ((row - tiles.startRow) * map.tileHeight) + offsetY;
context.drawImage(
map.spriteSheet.image,
source.x,
source.y,
source.width,
source.height,
_.round(destX),
_.round(destY),
map.tileWidth,
map.tileHeight
)
}
})
示例8: function
_.forEach(data.values, function(value: number) {
let percentage = _.round(value / total * 100, 2);
values.push({
name: that.parent.widget.chart.labels[idx],
y: percentage,
color: that.parent.widget.chart.colors[idx],
hits: value
});
idx++;
});
示例9: checkCommandsEqual
function checkCommandsEqual(actual: ReadonlyArray<Command>, expected: ReadonlyArray<Command>) {
expect(actual.length).toEqual(expected.length);
for (let i = 0; i < actual.length; i++) {
const a = actual[i];
const e = expected[i];
expect(a.type).toEqual(e.type);
expect(a.points.length).toEqual(e.points.length);
for (let j = 0; j < a.points.length; j++) {
const ap = a.points[j];
const ep = e.points[j];
if (!ap || !ep) {
expect(ap).toEqual(undefined);
expect(ep).toEqual(undefined);
} else {
expect(_.round(ap.x, 8)).toEqual(ep.x);
expect(_.round(ap.y, 8)).toEqual(ep.y);
}
}
}
}
示例10: format_number
format_number(n: any, divisor: number, units: string[], decimals: number = 1): string {
if (_.isString(n)) {
n = Number(n);
}
if (!_.isNumber(n)) {
return '-';
}
const unit = n < 1 ? 0 : Math.floor(Math.log(n) / Math.log(divisor));
const truncatedFloat = _.round(n / Math.pow(divisor, unit), decimals).toString();
return truncatedFloat === '' ? '-' : truncatedFloat + units[unit];
}