Skip to content

Commit 9f18377

Browse files
committed
Limit size of web string
1 parent 9e01094 commit 9f18377

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/monkstone/ColorUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
package monkstone;
1515

1616
import java.util.ArrayList;
17-
import java.util.Arrays;
18-
import java.util.Collections;
1917
import java.util.List;
2018
import java.util.Random;
2119

@@ -25,6 +23,8 @@
2523
*/
2624
public class ColorUtil {
2725

26+
static final String TOO_BIG = "produces a line too long a line for code";
27+
2828
/**
2929
* Returns hex long as a positive int unless greater than Integer.MAX_VALUE
3030
* else return the complement as a negative integer or something like that
@@ -63,13 +63,14 @@ static public int[] webArray(String[] web) {
6363
}
6464

6565
/**
66-
* Return a ruby string of the form "%w(a b c)" where a, b, c are raw web
66+
* Return a ruby string of the form "%w[a b c]" where a, b, c are raw web
6767
* strings. This string can be used in ruby code.
6868
*
6969
* @param p5colors cols of p5 colors (int)
7070
* @return String for use in ruby
7171
*/
7272
static public String rubyString(int[] p5colors) {
73+
if (p5colors.length > 8){ return TOO_BIG;}
7374
StringBuilder sb = new StringBuilder("%w[");
7475
for (int p5color : p5colors) {
7576
sb.append(String.format("#%06X", (0xFFFFFF & p5color)));

0 commit comments

Comments
 (0)