toxiclibs 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +6 -4
- data/examples/boolean_shapes.rb +46 -0
- data/lib/toxiclibs/version.rb +1 -1
- data/pom.rb +2 -8
- data/pom.xml +2 -14
- data/src/BooleanShapes.java +66 -0
- data/src/toxi/color/ColorList.java +70 -60
- data/src/toxi/color/ColorTheme.java +1 -1
- data/src/toxi/color/Histogram.java +1 -0
- data/src/toxi/color/Hue.java +7 -7
- data/src/toxi/color/TColor.java +31 -24
- data/src/toxi/geom/AxisAlignedCylinder.java +1 -0
- data/src/toxi/geom/BezierCurve2D.java +1 -1
- data/src/toxi/geom/BezierCurve3D.java +1 -1
- data/src/toxi/geom/BooleanShapeBuilder.java +9 -7
- data/src/toxi/geom/Matrix3d.java +293 -381
- data/src/toxi/geom/Matrix4f.java +447 -568
- data/src/toxi/geom/Matrix4x4.java +42 -47
- data/src/toxi/geom/Quaternion.java +52 -71
- data/toxiclibs.gemspec +6 -8
- metadata +7 -28
- data/src/toxi/audio/AudioBuffer.java +0 -229
- data/src/toxi/audio/AudioSource.java +0 -288
- data/src/toxi/audio/DecompressInputStream.java +0 -159
- data/src/toxi/audio/IIRFilter.java +0 -197
- data/src/toxi/audio/JOALUtil.java +0 -388
- data/src/toxi/audio/MultiTimbralManager.java +0 -162
- data/src/toxi/audio/SoundListener.java +0 -154
- data/src/toxi/audio/SynthUtil.java +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3766bf61befbcc60a27816721ef8528c930f0a5
|
4
|
+
data.tar.gz: cea30dbee7899c25c4183b78b0ab13f894f71a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c77948c8763555278cb9f32eb784f875ffac5388a7d337201d978c514cfbe666811efa3f600823ce2a237f665670772e64c3b380f29b4e0abf9db08d272ab2
|
7
|
+
data.tar.gz: 5e6f35deccaf8e35809cf02495b8377b606c57929b5579ef0615085c90a804f78c34f4cd1b4823ecb41058e1b2c6e1706b55fd7fab91e697ae60d094973f77b8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
## Toxiclibs for JRubyArt
|
2
2
|
|
3
3
|
![travis build](https://travis-ci.org/ruby-processing/toxicgem.svg)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/toxiclibs.svg)](https://badge.fury.io/rb/toxiclibs)
|
4
5
|
|
5
6
|
### Installing
|
6
7
|
```bash
|
7
8
|
gem install toxiclibs
|
8
9
|
```
|
9
10
|
|
10
|
-
### NB: Use version 0.4 for ruby-processing, and 0.
|
11
|
+
### NB: Use version 0.4 for ruby-processing, and 0.9.2 for propane and JRubyArt
|
11
12
|
|
12
|
-
|
13
|
+
NB: Build is only failing because current version of processing is not available at maven central.
|
14
|
+
This gem provides Karsten Schmidts (aka toxi, @postspectacular) toxiclibs jars for JRubyArt. To compile the gem follow the instructions for [JRubyArt][]. Most parts of toxiclibs API is exposed in the latest version, (but only a few examples are included) in principle it should be possible to make all available!!! For this demonstration I have used up to date source code for version 21, since [toxis final release][] has not yet been released (although [Dan Shiffman][] has released a version for processing-3.0+). There are reported to be number of outstanding bugs with toxiclibs, if they affect you report it [here][] (or better fix them yourself and submit a pull request). Version 0.9.2 features java code updated to use java lambda (jdk8) and was compiled against processing-3.3 core.jar. The audio library was not working and has been dropped since version 0.9.2.
|
13
15
|
|
14
16
|
![grayscott image](http://4.bp.blogspot.com/-d4MiL4_0Njk/VFJMv6VUicI/AAAAAAAAEgY/fFAfrXDxNXM/s400/grayscott.png)
|
15
17
|
|
@@ -26,7 +28,7 @@ This gem provides Karsten Schmidts (aka toxi, @postspectacular) toxiclibs jars f
|
|
26
28
|
### Licensing
|
27
29
|
|
28
30
|
I should be clear that the original toxiclibs is the work of Karsten Schmidt see [Copyright][]
|
29
|
-
|
31
|
+
|
30
32
|
This demo & library is free software you can redistribute it and/or
|
31
33
|
modify it under the terms of the GNU Lesser General Public
|
32
34
|
License as published by the Free Software Foundation either
|
@@ -40,4 +42,4 @@ version 2.1 of the License, or (at your option) any later version.
|
|
40
42
|
[Example Usage]:https://github.com/ruby-processing/toxicgem/tree/master/examples
|
41
43
|
[here]:https://github.com/ruby-processing/toxiclibs/issues
|
42
44
|
[Copyright]:https://github.com/ruby-processing/toxiclibs/COPYING.md
|
43
|
-
|
45
|
+
[Dan Shiffman]:https://github.com/shiffman/toxiclibs/tree/p3-update
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'toxiclibs'
|
2
|
+
load_library :control_panel
|
3
|
+
attr_reader :gfx, :bool, :panel, :type, :hide, :polies
|
4
|
+
include Toxi
|
5
|
+
|
6
|
+
TYPE = [BooleanShapeBuilder::Type::UNION, BooleanShapeBuilder::Type::XOR]
|
7
|
+
KEY = %w(union xor).freeze
|
8
|
+
|
9
|
+
def setup
|
10
|
+
sketch_title 'Boolean Shapes'
|
11
|
+
@gfx = Gfx::ToxiclibsSupport.new(self)
|
12
|
+
@bool = KEY.zip(TYPE).to_h
|
13
|
+
control_panel do |c|
|
14
|
+
c.title = 'Control Panel'
|
15
|
+
c.menu :type, KEY, 'union'
|
16
|
+
@panel = c
|
17
|
+
end
|
18
|
+
@hide = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw
|
22
|
+
unless hide
|
23
|
+
@hide = true
|
24
|
+
panel.set_visible(hide)
|
25
|
+
end
|
26
|
+
background(160)
|
27
|
+
builder = BooleanShapeBuilder.new(bool[type])
|
28
|
+
phi = frame_count * 0.01
|
29
|
+
builder.add_shape(Circle.new(mouse_x, mouse_y, 50))
|
30
|
+
builder.add_shape(Ellipse.new(150, 130 + sin(phi) * 50, 120, 60))
|
31
|
+
builder.add_shape(Rect.new(200 + sin(phi * 13 / 8) * 50, 180, 100, 100))
|
32
|
+
builder.add_shape(Triangle2D.create_equilateral_from(
|
33
|
+
TVec2D.new(50 + sin(phi * 15 / 13) * 50, 200), TVec2D.new(300, 200))
|
34
|
+
)
|
35
|
+
builder.add_shape(
|
36
|
+
Circle.new(100, 300, 50 + 30 * sin(phi * 21 / 15)).toPolygon2D(6)
|
37
|
+
)
|
38
|
+
fill(125)
|
39
|
+
stroke(255, 0, 0)
|
40
|
+
@polies = builder.compute_shapes
|
41
|
+
polies.each { |p| gfx.polygon2D(p) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def settings
|
45
|
+
size(400, 400)
|
46
|
+
end
|
data/lib/toxiclibs/version.rb
CHANGED
data/pom.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
project 'toxiclibs' do
|
2
2
|
|
3
3
|
model_version '4.0.0'
|
4
|
-
id 'ruby-processing:toxiclibs:0.9.
|
4
|
+
id 'ruby-processing:toxiclibs:0.9.2'
|
5
5
|
packaging 'jar'
|
6
6
|
|
7
7
|
description 'toxiclibs-library for JRubyArt'
|
@@ -28,9 +28,8 @@ project 'toxiclibs' do
|
|
28
28
|
'polyglot.dump.pom' => 'pom.xml'
|
29
29
|
)
|
30
30
|
|
31
|
-
jar 'org.jogamp.joal:joal-main:2.3.1'
|
32
31
|
jar 'args4j:args4j:2.0.31'
|
33
|
-
jar 'org.processing:core:3.
|
32
|
+
jar 'org.processing:core:3.3.0'
|
34
33
|
|
35
34
|
plugin( :compiler, '3.5.1',
|
36
35
|
'source' => '1.8',
|
@@ -46,11 +45,6 @@ project 'toxiclibs' do
|
|
46
45
|
'artifactId' => 'args4j',
|
47
46
|
'version' => '2.0.31',
|
48
47
|
'type' => 'jar',
|
49
|
-
'outputDirectory' => 'lib' },
|
50
|
-
{ 'groupId' => 'org.jogamp.joal',
|
51
|
-
'artifactId' => 'joal',
|
52
|
-
'version' => '2.3.1',
|
53
|
-
'type' => 'jar',
|
54
48
|
'outputDirectory' => 'lib' } ] )
|
55
49
|
end
|
56
50
|
|
data/pom.xml
CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
12
12
|
<groupId>ruby-processing</groupId>
|
13
13
|
<artifactId>toxiclibs</artifactId>
|
14
|
-
<version>0.9.
|
14
|
+
<version>0.9.2</version>
|
15
15
|
<name>toxiclibs</name>
|
16
16
|
<description>toxiclibs-library for JRubyArt</description>
|
17
17
|
<organization>
|
@@ -50,11 +50,6 @@ DO NOT MODIFIY - GENERATED CODE
|
|
50
50
|
<maven.compiler.target>1.8</maven.compiler.target>
|
51
51
|
</properties>
|
52
52
|
<dependencies>
|
53
|
-
<dependency>
|
54
|
-
<groupId>org.jogamp.joal</groupId>
|
55
|
-
<artifactId>joal-main</artifactId>
|
56
|
-
<version>2.3.1</version>
|
57
|
-
</dependency>
|
58
53
|
<dependency>
|
59
54
|
<groupId>args4j</groupId>
|
60
55
|
<artifactId>args4j</artifactId>
|
@@ -63,7 +58,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
63
58
|
<dependency>
|
64
59
|
<groupId>org.processing</groupId>
|
65
60
|
<artifactId>core</artifactId>
|
66
|
-
<version>3.
|
61
|
+
<version>3.3.0</version>
|
67
62
|
</dependency>
|
68
63
|
</dependencies>
|
69
64
|
<build>
|
@@ -107,13 +102,6 @@ DO NOT MODIFIY - GENERATED CODE
|
|
107
102
|
<type>jar</type>
|
108
103
|
<outputDirectory>lib</outputDirectory>
|
109
104
|
</artifactItem>
|
110
|
-
<artifactItem>
|
111
|
-
<groupId>org.jogamp.joal</groupId>
|
112
|
-
<artifactId>joal</artifactId>
|
113
|
-
<version>2.3.1</version>
|
114
|
-
<type>jar</type>
|
115
|
-
<outputDirectory>lib</outputDirectory>
|
116
|
-
</artifactItem>
|
117
105
|
</artifactItems>
|
118
106
|
</configuration>
|
119
107
|
</execution>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
import processing.core.*;
|
3
|
+
|
4
|
+
import toxi.geom.*;
|
5
|
+
import toxi.processing.*;
|
6
|
+
import toxi.color.*;
|
7
|
+
import java.util.List;
|
8
|
+
|
9
|
+
public class BooleanShapes extends PApplet {
|
10
|
+
|
11
|
+
ToxiclibsSupport gfx;
|
12
|
+
|
13
|
+
@Override
|
14
|
+
public void setup() {
|
15
|
+
|
16
|
+
gfx = new ToxiclibsSupport(this);
|
17
|
+
}
|
18
|
+
|
19
|
+
@Override
|
20
|
+
public void draw() {
|
21
|
+
background(160);
|
22
|
+
BooleanShapeBuilder builder = new BooleanShapeBuilder(
|
23
|
+
BooleanShapeBuilder.Type.XOR);
|
24
|
+
float phi = frameCount * 0.01f;
|
25
|
+
builder.addShape(new Circle(mouseX, mouseY, 50));
|
26
|
+
builder.addShape(new Ellipse(150, 130 + sin(phi) * 50, 120, 60));
|
27
|
+
builder.addShape(new Rect(200 + sin(phi * 13 / 8) * 50, 180, 100, 100));
|
28
|
+
builder.addShape(Triangle2D.createEquilateralFrom(new Vec2D(
|
29
|
+
50 + sin(phi * 15 / 13) * 50, 200), new Vec2D(300, 200)));
|
30
|
+
builder.addShape(new Circle(100, 300, 50 + 30 * sin(phi * 21 / 15))
|
31
|
+
.toPolygon2D(6));
|
32
|
+
noFill();
|
33
|
+
stroke(255, 0, 0);
|
34
|
+
List<Polygon2D> polies = builder.computeShapes();
|
35
|
+
polies.forEach((p) -> {
|
36
|
+
gfx.polygon2D(p);
|
37
|
+
});
|
38
|
+
noStroke();
|
39
|
+
Vec2D p = new Vec2D();
|
40
|
+
for (int y = 10; y < height; y += 20) {
|
41
|
+
for (int x = 10; x < height; x += 20) {
|
42
|
+
gfx.fill(pointInShapes(p.set(x, y), polies) ? TColor.GREEN
|
43
|
+
: TColor.BLUE);
|
44
|
+
gfx.circle(p, 3);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
public boolean pointInShapes(Vec2D p, List<Polygon2D> polies) {
|
50
|
+
return polies.stream().anyMatch((poly) -> (poly.containsPoint(p)));
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
public void settings() {
|
55
|
+
size(400, 400);
|
56
|
+
}
|
57
|
+
|
58
|
+
static public void main(String[] passedArgs) {
|
59
|
+
String[] appletArgs = new String[]{"BooleanShapes"};
|
60
|
+
if (passedArgs != null) {
|
61
|
+
PApplet.main(concat(appletArgs, passedArgs));
|
62
|
+
} else {
|
63
|
+
PApplet.main(appletArgs);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
@@ -2,23 +2,23 @@
|
|
2
2
|
* Some classes in this package have been partly inspired by & bits ported from
|
3
3
|
* Python code written by Tom De Smedt & Frederik De Bleser for the "colors" library
|
4
4
|
* of Nodebox.net.
|
5
|
-
*
|
5
|
+
*
|
6
6
|
* http://nodebox.net/code/index.php/Colors
|
7
7
|
*
|
8
8
|
* Copyright (c) 2006-2011 Karsten Schmidt
|
9
|
-
*
|
9
|
+
*
|
10
10
|
* This library is free software; you can redistribute it and/or
|
11
11
|
* modify it under the terms of the GNU Lesser General Public
|
12
12
|
* License as published by the Free Software Foundation; either
|
13
13
|
* version 2.1 of the License, or (at your option) any later version.
|
14
|
-
*
|
14
|
+
*
|
15
15
|
* http://creativecommons.org/licenses/LGPL/2.1/
|
16
|
-
*
|
16
|
+
*
|
17
17
|
* This library is distributed in the hope that it will be useful,
|
18
18
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19
19
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20
20
|
* Lesser General Public License for more details.
|
21
|
-
*
|
21
|
+
*
|
22
22
|
* You should have received a copy of the GNU Lesser General Public
|
23
23
|
* License along with this library; if not, write to the Free Software
|
24
24
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
@@ -45,7 +45,7 @@ import toxi.math.MathUtils;
|
|
45
45
|
* are also created when working with {@link ColorRange}s. The class has various
|
46
46
|
* methods to manipulate all colors in the list in parallel, as well as sort
|
47
47
|
* them by various criteria.
|
48
|
-
*
|
48
|
+
*
|
49
49
|
* @see ColorRange
|
50
50
|
* @see AccessCriteria
|
51
51
|
*/
|
@@ -56,7 +56,7 @@ public class ColorList implements Iterable<TColor> {
|
|
56
56
|
* ARGB image array. If the number of samples equals or exceeds the number
|
57
57
|
* of pixels in the image and no unique colors are required, the function
|
58
58
|
* will simply return the same as {@link #ColorList(int[])}.
|
59
|
-
*
|
59
|
+
*
|
60
60
|
* @param pixels
|
61
61
|
* int array of ARGB pixels
|
62
62
|
* @param num
|
@@ -78,7 +78,7 @@ public class ColorList implements Iterable<TColor> {
|
|
78
78
|
* the number of pixels in the source image and no unique colors are
|
79
79
|
* required, the function will simply return the same as
|
80
80
|
* {@link #ColorList(int[])}.
|
81
|
-
*
|
81
|
+
*
|
82
82
|
* @param pixels
|
83
83
|
* int array of ARGB pixels
|
84
84
|
* @param num
|
@@ -127,7 +127,7 @@ public class ColorList implements Iterable<TColor> {
|
|
127
127
|
* Factory method. Creates a new ColorList based on the given
|
128
128
|
* {@link ColorTheoryStrategy} instance and the given source color. The
|
129
129
|
* number of colors returned will vary with the strategy chosen.
|
130
|
-
*
|
130
|
+
*
|
131
131
|
* @param strategy
|
132
132
|
* @param c
|
133
133
|
* @return new list
|
@@ -140,7 +140,7 @@ public class ColorList implements Iterable<TColor> {
|
|
140
140
|
/**
|
141
141
|
* Factory method. Creates a ColorList based on the name of a
|
142
142
|
* {@link ColorTheoryStrategy} and the given source color.
|
143
|
-
*
|
143
|
+
*
|
144
144
|
* @param name
|
145
145
|
* strategy name
|
146
146
|
* @param c
|
@@ -174,7 +174,7 @@ public class ColorList implements Iterable<TColor> {
|
|
174
174
|
/**
|
175
175
|
* Creates a ColorList by wrapping the given ArrayList of colors. No copies
|
176
176
|
* of the given colors are created (shallow copy only).
|
177
|
-
*
|
177
|
+
*
|
178
178
|
* @param colors
|
179
179
|
*/
|
180
180
|
public ColorList(Collection<TColor> colors) {
|
@@ -185,7 +185,7 @@ public class ColorList implements Iterable<TColor> {
|
|
185
185
|
/**
|
186
186
|
* Creates a deep copy of the given ColorList. Manipulating the new list or
|
187
187
|
* its color entries does NOT change the colors of the original.
|
188
|
-
*
|
188
|
+
*
|
189
189
|
* @param list
|
190
190
|
* source list to copy
|
191
191
|
*/
|
@@ -199,7 +199,7 @@ public class ColorList implements Iterable<TColor> {
|
|
199
199
|
/**
|
200
200
|
* Creates a new color list from the array of ARGB int values. In most cases
|
201
201
|
* this will be the pixel buffer of an image.
|
202
|
-
*
|
202
|
+
*
|
203
203
|
* @param argbArray
|
204
204
|
*/
|
205
205
|
public ColorList(int[] argbArray) {
|
@@ -213,18 +213,18 @@ public class ColorList implements Iterable<TColor> {
|
|
213
213
|
* Creates new ColorList from the given colors. Copies of the given colors
|
214
214
|
* are created. This is a varargs constructor allowing these two parameter
|
215
215
|
* formats:
|
216
|
-
*
|
216
|
+
*
|
217
217
|
* <pre>
|
218
218
|
* // individual parameters
|
219
219
|
* ColorList cols=new ColorList(TColor.BLACK,TColor.WHITE,TColor.newRGB(1,0,0));
|
220
|
-
*
|
220
|
+
*
|
221
221
|
* // or array of colors
|
222
222
|
* ReadonlyTColor[] colArray=new ReadonlyTColor[] {
|
223
223
|
* TColor.BLACK,TColor.WHITE,TColor.newRGB(1,0,0);
|
224
224
|
* };
|
225
225
|
* ColorList cols=new ColorList(colArray);
|
226
226
|
* </pre>
|
227
|
-
*
|
227
|
+
*
|
228
228
|
* @param colorArray
|
229
229
|
*/
|
230
230
|
public ColorList(ReadonlyTColor... colorArray) {
|
@@ -236,7 +236,7 @@ public class ColorList implements Iterable<TColor> {
|
|
236
236
|
|
237
237
|
/**
|
238
238
|
* Adds a copy of the given color to the list
|
239
|
-
*
|
239
|
+
*
|
240
240
|
* @param c
|
241
241
|
* @return itself
|
242
242
|
*/
|
@@ -248,7 +248,7 @@ public class ColorList implements Iterable<TColor> {
|
|
248
248
|
/**
|
249
249
|
* Adds all entries of the TColor collection to the list (shallow copy only,
|
250
250
|
* manipulating the new list will modify the original colors).
|
251
|
-
*
|
251
|
+
*
|
252
252
|
* @param collection
|
253
253
|
* @return itself
|
254
254
|
*/
|
@@ -259,36 +259,36 @@ public class ColorList implements Iterable<TColor> {
|
|
259
259
|
|
260
260
|
/**
|
261
261
|
* Adjusts the brightness component of all list colors by the given amount.
|
262
|
-
*
|
262
|
+
*
|
263
263
|
* @param step
|
264
264
|
* adjustment value
|
265
265
|
* @return itself
|
266
266
|
*/
|
267
267
|
public ColorList adjustBrightness(float step) {
|
268
|
-
|
268
|
+
colors.forEach((c) -> {
|
269
269
|
c.lighten(step);
|
270
|
-
}
|
270
|
+
});
|
271
271
|
return this;
|
272
272
|
}
|
273
273
|
|
274
274
|
/**
|
275
275
|
* Adjusts the saturation component of all list colors by the given amount.
|
276
|
-
*
|
276
|
+
*
|
277
277
|
* @param step
|
278
278
|
* adjustment value
|
279
279
|
* @return itself
|
280
280
|
*/
|
281
281
|
public ColorList adjustSaturation(float step) {
|
282
|
-
|
282
|
+
colors.forEach((c) -> {
|
283
283
|
c.saturate(step);
|
284
|
-
}
|
284
|
+
});
|
285
285
|
return this;
|
286
286
|
}
|
287
287
|
|
288
288
|
/**
|
289
289
|
* Sorts the list based on two criteria to create clusters/segments within
|
290
290
|
* the list.
|
291
|
-
*
|
291
|
+
*
|
292
292
|
* @param clusterCriteria
|
293
293
|
* main sort criteria
|
294
294
|
* @param subClusterCriteria
|
@@ -334,30 +334,25 @@ public class ColorList implements Iterable<TColor> {
|
|
334
334
|
|
335
335
|
/**
|
336
336
|
* Switches all list colors to their complementary color.
|
337
|
-
*
|
337
|
+
*
|
338
338
|
* @return itself
|
339
339
|
*/
|
340
340
|
public ColorList complement() {
|
341
|
-
|
341
|
+
colors.forEach((c) -> {
|
342
342
|
c.complement();
|
343
|
-
}
|
343
|
+
});
|
344
344
|
return this;
|
345
345
|
}
|
346
346
|
|
347
347
|
/**
|
348
348
|
* Checks if the given color is part of the list. Check is done by value,
|
349
349
|
* not instance.
|
350
|
-
*
|
350
|
+
*
|
351
351
|
* @param color
|
352
352
|
* @return true, if the color is present.
|
353
353
|
*/
|
354
354
|
public boolean contains(ReadonlyTColor color) {
|
355
|
-
|
356
|
-
if (c.equals(color)) {
|
357
|
-
return true;
|
358
|
-
}
|
359
|
-
}
|
360
|
-
return false;
|
355
|
+
return colors.stream().anyMatch((c) -> (c.equals(color)));
|
361
356
|
}
|
362
357
|
|
363
358
|
/**
|
@@ -365,7 +360,7 @@ public class ColorList implements Iterable<TColor> {
|
|
365
360
|
* convention, in that if the index is negative, it is considered relative
|
366
361
|
* to the list end. Therefore the color at index -1 is the last color in the
|
367
362
|
* list.
|
368
|
-
*
|
363
|
+
*
|
369
364
|
* @param i
|
370
365
|
* index
|
371
366
|
* @return color
|
@@ -379,7 +374,7 @@ public class ColorList implements Iterable<TColor> {
|
|
379
374
|
|
380
375
|
/**
|
381
376
|
* Calculates and returns the average color of the list.
|
382
|
-
*
|
377
|
+
*
|
383
378
|
* @return average color or null, if there're no entries yet.
|
384
379
|
*/
|
385
380
|
public ReadonlyTColor getAverage() {
|
@@ -404,7 +399,7 @@ public class ColorList implements Iterable<TColor> {
|
|
404
399
|
/**
|
405
400
|
* Creates a new ColorList by blending all colors in the list with each
|
406
401
|
* other (successive indices only)
|
407
|
-
*
|
402
|
+
*
|
408
403
|
* @param amount
|
409
404
|
* blend amount
|
410
405
|
* @return new color list
|
@@ -420,7 +415,7 @@ public class ColorList implements Iterable<TColor> {
|
|
420
415
|
|
421
416
|
/**
|
422
417
|
* Finds and returns the darkest color of the list.
|
423
|
-
*
|
418
|
+
*
|
424
419
|
* @return darkest color or null if there're no entries yet.
|
425
420
|
*/
|
426
421
|
public TColor getDarkest() {
|
@@ -438,7 +433,7 @@ public class ColorList implements Iterable<TColor> {
|
|
438
433
|
|
439
434
|
/**
|
440
435
|
* Finds and returns the lightest (luminance) color of the list.
|
441
|
-
*
|
436
|
+
*
|
442
437
|
* @return lightest color or null, if there're no entries yet.
|
443
438
|
*/
|
444
439
|
public ReadonlyTColor getLightest() {
|
@@ -464,7 +459,7 @@ public class ColorList implements Iterable<TColor> {
|
|
464
459
|
|
465
460
|
/**
|
466
461
|
* Returns a reversed copy of the current list.
|
467
|
-
*
|
462
|
+
*
|
468
463
|
* @return reversed copy of the list
|
469
464
|
*/
|
470
465
|
public ColorList getReverse() {
|
@@ -473,20 +468,35 @@ public class ColorList implements Iterable<TColor> {
|
|
473
468
|
|
474
469
|
/**
|
475
470
|
* Inverts all colors in the list.
|
476
|
-
*
|
471
|
+
*
|
477
472
|
* @return itself
|
478
473
|
*/
|
479
474
|
public ColorList invert() {
|
480
|
-
|
475
|
+
colors.forEach((c) -> {
|
481
476
|
c.invert();
|
482
|
-
}
|
477
|
+
});
|
483
478
|
return this;
|
484
479
|
}
|
485
480
|
|
481
|
+
|
482
|
+
public String toRubyString() {
|
483
|
+
StringBuilder ruby = new StringBuilder("%w(");
|
484
|
+
colors.stream().map((c) -> {
|
485
|
+
ruby.append('#');
|
486
|
+
ruby.append(c.toHex());
|
487
|
+
return c;
|
488
|
+
}).forEachOrdered((_item) -> {
|
489
|
+
ruby.append(' ');
|
490
|
+
});
|
491
|
+
ruby.deleteCharAt(ruby.length() - 1);
|
492
|
+
ruby.append(")\n");
|
493
|
+
return ruby.toString();
|
494
|
+
}
|
495
|
+
|
486
496
|
/**
|
487
497
|
* Returns an iterator over the internal list. This means the list can be
|
488
498
|
* accessed via standard Iterator loops.
|
489
|
-
*
|
499
|
+
*
|
490
500
|
* @return list iterator
|
491
501
|
*/
|
492
502
|
@Override
|
@@ -496,7 +506,7 @@ public class ColorList implements Iterable<TColor> {
|
|
496
506
|
|
497
507
|
/**
|
498
508
|
* Reverses the current order of the list.
|
499
|
-
*
|
509
|
+
*
|
500
510
|
* @return itself
|
501
511
|
*/
|
502
512
|
public ColorList reverse() {
|
@@ -506,7 +516,7 @@ public class ColorList implements Iterable<TColor> {
|
|
506
516
|
|
507
517
|
/**
|
508
518
|
* Rotates the hues of all colors in the list by the given amount.
|
509
|
-
*
|
519
|
+
*
|
510
520
|
* @param theta
|
511
521
|
* rotation angle in radians
|
512
522
|
* @return itself
|
@@ -518,7 +528,7 @@ public class ColorList implements Iterable<TColor> {
|
|
518
528
|
|
519
529
|
/**
|
520
530
|
* Rotates the hues of all colors in the list by the given amount.
|
521
|
-
*
|
531
|
+
*
|
522
532
|
* @param angle
|
523
533
|
* rotation angle in degrees
|
524
534
|
* @return itself
|
@@ -527,17 +537,17 @@ public class ColorList implements Iterable<TColor> {
|
|
527
537
|
rotateImplementation(angle);
|
528
538
|
return this;
|
529
539
|
}
|
530
|
-
|
540
|
+
|
531
541
|
/**
|
532
542
|
* Rotates the hues of all colors in the list by the given amount.
|
533
|
-
*
|
543
|
+
*
|
534
544
|
* @param angle
|
535
545
|
* rotation angle in degrees
|
536
546
|
*/
|
537
547
|
private void rotateImplementation(float angle) {
|
538
|
-
|
548
|
+
colors.forEach((c) -> {
|
539
549
|
c.rotateRYB(angle);
|
540
|
-
}
|
550
|
+
});
|
541
551
|
}
|
542
552
|
|
543
553
|
/**
|
@@ -549,7 +559,7 @@ public class ColorList implements Iterable<TColor> {
|
|
549
559
|
|
550
560
|
/**
|
551
561
|
* Convenience method. Sorts the list by hue.
|
552
|
-
*
|
562
|
+
*
|
553
563
|
* @return itself
|
554
564
|
*/
|
555
565
|
public ColorList sort() {
|
@@ -558,7 +568,7 @@ public class ColorList implements Iterable<TColor> {
|
|
558
568
|
|
559
569
|
/**
|
560
570
|
* Sorts the list using the given comparator.
|
561
|
-
*
|
571
|
+
*
|
562
572
|
* @param comp
|
563
573
|
* comparator
|
564
574
|
* @param isReversed
|
@@ -576,7 +586,7 @@ public class ColorList implements Iterable<TColor> {
|
|
576
586
|
|
577
587
|
/**
|
578
588
|
* Sorts the list using the given {@link AccessCriteria}.
|
579
|
-
*
|
589
|
+
*
|
580
590
|
* @param criteria
|
581
591
|
* sort criteria
|
582
592
|
* @param isReversed
|
@@ -590,7 +600,7 @@ public class ColorList implements Iterable<TColor> {
|
|
590
600
|
/**
|
591
601
|
* Sorts the list by relative distance to each predecessor, starting with
|
592
602
|
* the darkest color in the list.
|
593
|
-
*
|
603
|
+
*
|
594
604
|
* @param isReversed
|
595
605
|
* true, if list is to be sorted in reverse.
|
596
606
|
* @return itself
|
@@ -602,7 +612,7 @@ public class ColorList implements Iterable<TColor> {
|
|
602
612
|
/**
|
603
613
|
* Sorts the list by relative distance to each predecessor, starting with
|
604
614
|
* the darkest color in the list.
|
605
|
-
*
|
615
|
+
*
|
606
616
|
* @param proxy
|
607
617
|
* @param isReversed
|
608
618
|
* true, if list is to be sorted in reverse.
|
@@ -653,7 +663,7 @@ public class ColorList implements Iterable<TColor> {
|
|
653
663
|
/**
|
654
664
|
* Sorts the list by proximity to the given target color (using RGB distance
|
655
665
|
* metrics).
|
656
|
-
*
|
666
|
+
*
|
657
667
|
* @see #sortByProximityTo(ReadonlyTColor, DistanceProxy, boolean)
|
658
668
|
* @param target
|
659
669
|
* color
|
@@ -668,7 +678,7 @@ public class ColorList implements Iterable<TColor> {
|
|
668
678
|
/**
|
669
679
|
* Sorts the list by proximity to the given target color using the given
|
670
680
|
* {@link DistanceProxy} implementation.
|
671
|
-
*
|
681
|
+
*
|
672
682
|
* @param target
|
673
683
|
* color
|
674
684
|
* @param proxy
|
@@ -685,7 +695,7 @@ public class ColorList implements Iterable<TColor> {
|
|
685
695
|
|
686
696
|
/**
|
687
697
|
* Creates an ARGB integer array of the list items.
|
688
|
-
*
|
698
|
+
*
|
689
699
|
* @return all list colors as ARGB values
|
690
700
|
*/
|
691
701
|
public int[] toARGBArray() {
|