Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
add mix colors for new palette
Browse files Browse the repository at this point in the history
  • Loading branch information
exoad committed Jul 11, 2023
1 parent 86d0dbe commit 48f5632
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
28 changes: 28 additions & 0 deletions pkg/src/com/jackmeng/prismix/stl/extend_stl_Colors.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import java.awt.color.ColorSpace;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import com.jackmeng.prismix._1const;
import com.jackmeng.stl.stl_Colors;
Expand Down Expand Up @@ -149,6 +153,30 @@ public static float[][] shades(final float[] ir, final int n)
return generatedTints;
}

public static float[][] awt_ran_gen(Color mix, int n)
{
assert mix != null;
assert n > 0;

float[][] blends = new float[n][3];

for (int i = 0; i < n; i++)
{
blends[i][0] = (float) (_1const.RNG.nextFloat(256) + mix.getRed()) / 2;
blends[i][1] = (float) (_1const.RNG.nextFloat(256) + mix.getGreen()) / 2;
blends[i][2] = (float) (_1const.RNG.nextFloat(256) + mix.getBlue()) / 2;
}

for (int i = 0; i < n; i++)
{
blends[i][0] = (float) (_1const.RNG.nextFloat(256) + blends[i][0]) / 2;
blends[i][1] = (float) (_1const.RNG.nextFloat(256) + blends[i][1]) / 2;
blends[i][2] = (float) (_1const.RNG.nextFloat(256) + blends[i][2]) / 2;
}

return blends;
}

public static float[][] tones(final float[] ir, final int n)
{
float[][] tones = new float[n][3];
Expand Down
18 changes: 11 additions & 7 deletions pkg/src/com/jackmeng/prismix/ux/ui_ColorPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public synchronized void _update(float[][] e)

}

final transient Base_Palette tones, tints, shades, complementary;
final transient Base_Palette tones, tints, shades, complementary, mix;

public CPick_SuggestionsList()
{
Expand All @@ -478,14 +478,16 @@ public CPick_SuggestionsList()
contentWrapper.setBorder(BorderFactory.createEmptyBorder());
contentWrapper.setLayout(new BoxLayout(contentWrapper, BoxLayout.X_AXIS));

tones = new Base_Palette("Tones", 10, 15);
tints = new Base_Palette("Tints", 10, 15);
shades = new Base_Palette("Shades", 10, 15);
complementary = new Base_Palette("Complementary", 8, 13);
tones = new Base_Palette("Tones", 15, 10);
tints = new Base_Palette("Tints", 15, 10);
shades = new Base_Palette("Shades", 15, 10);
mix = new Base_Palette("Mixed", 15, 10);
complementary = new Base_Palette("Complementary", 5, 3);

contentWrapper.add(tones.component);
contentWrapper.add(tints.component);
contentWrapper.add(shades.component);
contentWrapper.add(tones.component);
contentWrapper.add(mix.component);
contentWrapper.add(complementary.component);

mainViewport.setView(contentWrapper);
Expand Down Expand Up @@ -642,6 +644,7 @@ public CPick_SuggestionsList()
this.tints.rows * this.tints.cols);
float[][] gen_shades = extend_stl_Colors.shades(extend_stl_Colors.awt_strip_rgba(arg0.first),
this.shades.cols * this.shades.rows);
float[][] gen_mix = extend_stl_Colors.awt_ran_gen(arg0.first, this.mix.cols * this.mix.rows);

if (use_sorted)
{
Expand All @@ -665,7 +668,8 @@ public CPick_SuggestionsList()
this.tints._update(gen_tints);
this.shades._update(gen_shades);
this.complementary._update(gen_complements);
this.tones._update(gen_complements);
this.tones._update(gen_tones);
this.mix._update(gen_mix);
});

});
Expand Down

0 comments on commit 48f5632

Please sign in to comment.