当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.round函数代码示例

本文整理汇总了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
    );
}
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:27,代码来源:draw.ts

示例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
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:56,代码来源:payment-option.ts

示例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();
     };
 }
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:15,代码来源:game.ts

示例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)
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:7,代码来源:calculateMonthlyIncomeExpense.ts

示例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);
 }
开发者ID:railsstudent,项目名称:angular2-appcheck,代码行数:16,代码来源:database-instance.ts

示例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)}`
   );
 }
开发者ID:HarryTmetic,项目名称:r2,代码行数:8,代码来源:BrokerPositionImpl.ts

示例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
         )
     }
 })
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:19,代码来源:draw.ts

示例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++;
 });
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:10,代码来源:widget-chart-pie.component.ts

示例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);
      }
    }
  }
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:20,代码来源:Path.spec.ts

示例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];
 }
开发者ID:prallabh,项目名称:ceph-1,代码行数:11,代码来源:formatter.service.ts


注:本文中的lodash.round函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。