Skip to content

Commit 38bd9fc

Browse files
committed
Closes #9 (Color-Shift)
1 parent c2d1e45 commit 38bd9fc

38 files changed

+101
-73
lines changed
Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
/* Example for shifting colors.
2+
* Click on a color in the picture to select a color.
3+
* Move the mouse from left to right to see the color shifting.
24
*
35
* Author: Nick 'Milchreis' Müller
46
*/
57

68
import milchreis.imageprocessing.*;
79

810
PImage image;
9-
color blue = #3896F2;
11+
int hue = 0;
12+
int x = 0, y = 0;
13+
int shiftedColor = 0;
14+
int pixel = 0;
1015

1116
void setup() {
1217
size(550, 550);
@@ -17,13 +22,36 @@ void setup() {
1722
void draw() {
1823

1924
if(mousePressed == true) {
20-
image(image, 0, 0);
25+
// Select color from clicked position
26+
pixel = image.get(mouseX, mouseY);
27+
28+
// Save mouse position to compare the shifted value
29+
x = mouseX;
30+
y = mouseY;
31+
32+
// Get hue value
33+
hue = (int)Tools.rgbToHsb(pixel)[0];
34+
2135
} else {
36+
// Get shift by mouse x-axis
2237
int shift = (int)map(mouseX, 0, width, -30, 30);
23-
int hue = (int)map(mouseY, 0, height, 0, 360);
24-
//float shift = map(mouseX, 0, width, -0.3, 0.3);
38+
39+
// Shift the selected color by hue value
2540
PImage p = ColorShift.applyHue(image, hue, 10, shift);
2641

42+
// Get new shifted color
43+
shiftedColor = p.get(x, y);
44+
2745
image(p, 0, 0);
2846
}
47+
48+
noStroke();
49+
50+
// Draw selected color
51+
fill(pixel);
52+
rect(0, height - 10, width/2, 10);
53+
54+
// Draw shifted color
55+
fill(shiftedColor);
56+
rect(width/2, height - 10, width/2, 10);
2957
}

img/colorshift.png

620 KB
Loading

library/ImageProcessing.jar

0 Bytes
Binary file not shown.

reference/allclasses-frame.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:40 CET 2018 -->
66
<title>All Classes (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/allclasses-noframe.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:40 CET 2018 -->
66
<title>All Classes (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/constant-values.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:39 CET 2018 -->
66
<title>Constant Field Values (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/deprecated-list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:39 CET 2018 -->
66
<title>Deprecated List (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/help-doc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:40 CET 2018 -->
66
<title>API Help (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/index-all.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:39 CET 2018 -->
66
<title>Index (Javadocs: ImageProcessing)</title>
7-
<meta name="date" content="2018-01-30">
7+
<meta name="date" content="2018-01-31">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

reference/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- NewPage -->
33
<html lang="de">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_151) on Tue Jan 30 20:47:01 CET 2018 -->
5+
<!-- Generated by javadoc (1.8.0_151) on Wed Jan 31 22:42:40 CET 2018 -->
66
<title>Javadocs: ImageProcessing</title>
77
<script type="text/javascript">
88
tmpTargetPage = "" + window.location.search;

0 commit comments

Comments
 (0)