You are not logged in.
Finally got around to taking a picture of (nonlewd) japan haul
You sure get the weirdest ideas sometimes.
It's really not sure if it should come yet or not.
#triggered
The sandwiches I made just were pretty nice. Garlic is 5/5.
Didn't know you're stamper.
Moving blog:
definitely not going overboard with autism
The nearby store, you'll have to drink it yourself though.
Moving blog:
priorities, pt 2
Moving blog:
priorities
>nano
>hacker
:----------D
public class ArrayColorConversion {
/**
* Method arrayMin
* returns the smallest value in a given array
* @param array array to find minimum from
* @return minimum value in array
*/
public static int arrayMin(int[] array) {
int temp = array[0]; // set value of first index in temp
for (int n = 1;n < array.length;n++) {
if (temp > array[n]) // compare current value against temp
temp = array[n]; // if current value is smaller, save it in temp
}
return temp; // return temp that now has the smallest value
}
/**
* Method arrayMax
* returns the largest value in a given array
* @param array array to find maximum from
* @return maximum value in array
*/
public static int arrayMax(int[] array) {
int temp = array[0];
for (int n = 1;n < array.length;n++) {
if (temp < array[n]) // the only difference to min is the flip of > to <
temp = array[n];
}
return temp;
}
/**
* Method RGBtoHSV
* converts given RGB value to a HSV value
* @param array array to convert values from
* @return array with values in HSV format
*/
public static int[] RGBtoHSV(int[] array) {
//initialize return array and temporary array
int[] hsv = {0,0,0};
double[] hsv_t = {0,0,0};
// convert the 0-255 rgb values to 0-1
double r = (double) array[0] / 255;
double g = (double) array[1] / 255;
double b = (double) array[2] / 255;
// calculate max, min and delta
double cmax = (double) arrayMax(array) / 255;
double cmin = (double) arrayMin(array) / 255;
double delta = cmax - cmin;
if (cmax <= 0) { // if max is 0, then everything is 0 and HSV values are 0,0,0
return hsv;
}
else { // if not, calculate hsv values
if (r >= cmax)
hsv_t[0] = (g - b) / delta;
else if (g >= cmax)
hsv_t[0] = ((b - r) / delta) + 2.0;
else
hsv_t[0] = ((r - g) / delta) + 4.0;
hsv_t[0] *= 60;
if (hsv_t[0] < 0)
hsv_t[0] += 360;
hsv_t[1] = (delta / cmax) * 100;
hsv_t[2] = cmax * 100;
}
// dump the temp values into int array
hsv[0] = (int) Math.round(hsv_t[0]);
hsv[1] = (int) Math.round(hsv_t[1]);
hsv[2] = (int) Math.round(hsv_t[2]);
return hsv;
}
/**
* Main program
* @param args user input, not used
*/
public static void main(String args[]) {
int[] colour = { 255,0,128 }; //the prettiest of colours
int[] colourHSV = RGBtoHSV(colour);
System.out.print("H: " + colourHSV[0] + "\n");
System.out.print("S: " + colourHSV[1] + "\n");
System.out.print("V: " + colourHSV[2] + "\n");
}
}
At least that one is somewhat interesting but it's still java
public class ArrayMinMax {
/**
* Method arrayMin
* returns the smallest value in a given array
* @param array array to find minimum from
*/
public static int arrayMin(int[] array) {
int temp = array[0]; // set value of first index in temp
for (int n = 1;n < array.length;n++) {
if (temp > array[n]) // compare current value against temp
temp = array[n]; // if current value is smaller, save it in temp
}
return temp; // return temp that now has the smallest value
}
/**
* Method arrayMax
* returns the largest value in a given array
* @param array array to find maximum from
*/
public static int arrayMax(int[] array) {
int temp = array[0];
for (int n = 1;n < array.length;n++) {
if (temp < array[n]) // the only difference to min is the flip of > to <
temp = array[n];
}
return temp;
}
/**
* Main program
* @param user input, not used
*/
public static void main(String args[]) {
int[] values = { 1, -5, 10, -15, 0, 7 };
// prints out min and max with formatting
System.out.printf("%-5s%2d\n%-5s%2d\n","Min:",arrayMin(values),"Max:",arrayMax(values));
}
}