Here you can find the source of clamp(float f, float min, float max)
Parameter | Description |
---|---|
min | a parameter |
max | a parameter |
public static float clamp(float f, float min, float max)
//package com.java2s; //License from project: Open Source License public class Main { /**// ww w .j a v a 2 s . c o m * Rounds the given value so that it's bigger or * equal to min and smaller or equal to max. * @param float * @param min * @param max * @returns the clamped value as a float */ public static float clamp(float f, float min, float max) { float r = f; if (r < min) r = min; if (r > max) r = max; return r; } /** * Rounds the given value so that it's bigger or * equal to min and smaller or equal to max. * @param int * @param min * @param max * @returns the clamped value as an int */ public static int clamp(int i, int min, int max) { int r = i; if (r < min) r = min; if (r > max) r = max; return r; } }