mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-13 06:53:19 -05:00
Java formatter
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
3682b2cb7d
commit
8ea0652331
@ -36,7 +36,8 @@ public class PoppingCharactersCaptcha implements ChallengeProvider {
|
|||||||
advances.add(currX);
|
advances.add(currX);
|
||||||
currX += font.getStringBounds(String.valueOf(c), frc).getWidth();
|
currX += font.getStringBounds(String.valueOf(c), frc).getWidth();
|
||||||
currX += spacing;
|
currX += spacing;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
graphics2D.dispose();
|
graphics2D.dispose();
|
||||||
return advances.toArray(new Integer[] {});
|
return advances.toArray(new Integer[] {});
|
||||||
}
|
}
|
||||||
@ -45,7 +46,8 @@ public class PoppingCharactersCaptcha implements ChallengeProvider {
|
|||||||
final var img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
final var img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
final var graphics2D = img.createGraphics();
|
final var graphics2D = img.createGraphics();
|
||||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
graphics2D.setRenderingHint(
|
||||||
|
RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
graphics2D.setFont(font);
|
graphics2D.setFont(font);
|
||||||
f.accept(graphics2D);
|
f.accept(graphics2D);
|
||||||
graphics2D.dispose();
|
graphics2D.dispose();
|
||||||
@ -63,14 +65,25 @@ public class PoppingCharactersCaptcha implements ChallengeProvider {
|
|||||||
final var writer = new GifSequenceWriter(output, 1, 900, true);
|
final var writer = new GifSequenceWriter(output, 1, 900, true);
|
||||||
final var advances = computeOffsets(text);
|
final var advances = computeOffsets(text);
|
||||||
final var prevColor = Color.getHSBColor(0f, 0f, 0.1f);
|
final var prevColor = Color.getHSBColor(0f, 0f, 0.1f);
|
||||||
IntStream.range(0, text.length()).forEach(i -> {
|
IntStream.range(0, text.length())
|
||||||
final var color = Color.getHSBColor(HelperFunctions.randomNumber(0, 100)/100.0f, 0.6f, 1.0f);
|
.forEach(
|
||||||
|
i -> {
|
||||||
|
final var color =
|
||||||
|
Color.getHSBColor(HelperFunctions.randomNumber(0, 100) / 100.0f, 0.6f, 1.0f);
|
||||||
final var prevI = (i - 1 + text.length()) % text.length();
|
final var prevI = (i - 1 + text.length()) % text.length();
|
||||||
final var nextImage = makeImage((g) -> {
|
final var nextImage =
|
||||||
|
makeImage(
|
||||||
|
(g) -> {
|
||||||
g.setColor(prevColor);
|
g.setColor(prevColor);
|
||||||
g.drawString(String.valueOf(text.charAt(prevI)), advances[prevI] + jitter(), 45 + jitter());
|
g.drawString(
|
||||||
|
String.valueOf(text.charAt(prevI)),
|
||||||
|
advances[prevI] + jitter(),
|
||||||
|
45 + jitter());
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
g.drawString(String.valueOf(text.charAt(i)), advances[i] + jitter(), 45 + jitter());
|
g.drawString(
|
||||||
|
String.valueOf(text.charAt(i)),
|
||||||
|
advances[i] + jitter(),
|
||||||
|
45 + jitter());
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
writer.writeToSequence(nextImage);
|
writer.writeToSequence(nextImage);
|
||||||
|
Loading…
Reference in New Issue
Block a user