Here you can find the source of clamp(int value, int min, int max)
public static int clamp(int value, int min, int max)
//package com.java2s; public class Main { public static float clamp(float value, float min, float max) { float clamped = min > value ? min : value; return max < clamped ? max : clamped; }//from w ww . j a va 2 s . co m public static int clamp(int value, int min, int max) { int clamped = min > value ? min : value; return max < clamped ? max : clamped; } }