Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
/ LarsonScanner Public archive

Knight Rider Kitt and Battlestar Galactica Cylon inspired Larson Scanner written for Java Swing.

License

Notifications You must be signed in to change notification settings

Griefed/LarsonScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

larsonscanner

Homepage Blog Fleet GitHub DockerHub Discord


Sources, GitHub, GitLab and Mirroring and all that good stuff

Repositories on GitHub are now for issues only. I've set up my own installation of GitLab and moved all my repositories over to Git.Griefed.de. Make sure to check there first for the latest code before opening an issue on GitHub.

For questions, you can always join my Discord server and talk to me there.


LarsonScanner

GitHub Repo stars GitHub forks

This is a Larson Scanner inspired by the Cylons from Battlestart Galactica and Kitt from Knight Rider. It's basically just a red light which scrolls from left to right to left, with a nice fade-out effect along with it.

This Larson Scanner lets you customize just about everything though! To get an idea about what's possible with this Larson Scanner, make sure to take a look at the examples below!

default default_rectangle kitt_oval kitt_rectangle


Implementation

$VERSION is the version of LarsonScanner you want to use in your project. The most recent version as of me writing this is 1.0.3, however, for newer versions, make sure to check out the releases-page. More information can be found at Sonatype Maven

LarsonScanner was written using Java 8.

Using Gradle

implementation 'de.griefed:larsonscanner:$VERSION'

Using Maven

<dependency>
  <groupId>de.griefed</groupId>
  <artifactId>larsonscanner</artifactId>
  <version>$VERSION</version>
</dependency>

Usage

The quickest way is to create a new instance of LarsonScanner with the default values and just add it the the element you want to display it in.

LarsonScanner larsonScanner = new LarsonScanner();

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
larsonScanner.setPreferredSize(new Dimension(512, 128));
frame.setPreferredSize(new Dimension(512, 128));
frame.setSize(new Dimension(512, 128));
frame.add(larsonScanner);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);

larsonScanner.play();

LarsonScanner comes as a JPanel, so you can immediately add it to your Java Swing GUI.

Examples

The GIF shown just above the Implementation-chapter shows the default settings to which you can compare all the following examples to.

Alpha Values

You can set the alpha value for each element in the eye separately, allowing you to create some neat effects!

Be aware that these alpha values are only used when you use gradients! Alpha values are reset / automatically set / calculated when you change the number of elements in your configuration. So, if you plan on using custom alpha values and a custom amount of elements, make sure to update your alphas after changing the number of elements!

255,200,100,100,150 (default 100,200,255,200,100)

alphas

Interval

Every n milliseconds the position of the eye gets updated and the eye redrawn. Smaller values therefor increase the speed at wich the eye scrolls across the screen, whilst bigger values decrease it.

25ms (default 100ms)

interval

Divider

The divider determines the amount with which to increment or decrement the position of the eye each time the timer fires. Meaning: Smaller values increase the speed of the eye whilst bigger values decrease it.

5 (default 25)

divider

Number of elements

The number of elements in the eye of the Larson Scanner. Pretty self-explanatory.

21 (default 5)

elements

Fractions

Fractions for the distribution of colours along the gradients of each oval-shaped element.

0.1f, 0.7f (default 0.4f, 1.0f)

fractions

Gap divider

The gap between rectangular elements is n % of the width of one element. Meaning: A smaller divider results in smaller gaps, whilst a bigger divider results in larger gaps.

100.0f (default 25.0f)

gap

Partitioning

The total width of the available area is divided by this value, and the resulting value is the total width of the eye in which all elements will be drawn. The smaller the value, the bigger the eye and the other way around.

15.0D (default 5.0D)

partitioning

Aspect ratio enforcing

If the aspect ratio is being forced, each element will be drawn with a 1:1 aspect ratio, turning ovals into circles and rectangles into squares. The aspect ratio is being enforced by de-/increasing the height of the eye in the scanner to the width of one element, resulting in a nice and sexy 1:1 ratio.

If you plan on using different scanner and eye background colours, you should make use of this setting, otherwise the eye background colour will also prevail.

true (default false)

aspect_ratio

Animation styles

You can choose between a total of two different animation styles, Cylon-eye and Kitt-eye. If you plan on using the Kitt-eye animation, say goodbye to the alpha-setting, as it will not have any affect on the eye whatsoever when using the Kitt-style animation.

Cylon eye (default)

Oval (default)

cylon_oval

Rectangle

cylon_rectangle

Kitt eye

Oval

kitt_oval

Rectangle

kitt_rectangle

Use gradients (default true)

Whether to draw the eye using gradients. If gradients are not used, then every element in the eye will be drawn using a solid colour.

gradient_oval

gradient_rectangle

Use divider

Whether to use a divider to in-/decrement across the width of the Larson Scanner. If the divider is being used, then the position of the eye will be updated with the result of the width of the Scanner divided by the divider.

false (default true)

use_divider

Eye colours

Set the colour for each element in the eye, from left to right. If you plan on using this, make sure to check the number of elements in your eye beforehand! You must provide one colour per element.

255,0,0 - 0,255,0 - 0,0,255 - 255,255,0 - 0,255,255 (default 255,0,0 - 255,0,0 - 255,0,0 - 255,0,0 - 255,0,0)

eye_colours

Scanner background colour

The background colour of the LarsonScanner JPanel in which the eye resides in. If you plan on using this, then you are advised to use the aspect ratio enforcement, because otherwise the available area will be filled with the background colour of the eye.

0,255,255 (default 0,0,0)

scanner_background

Eye background colour

The background colour of the eye in the LarsonScanner.

255,0,255 (default 0,0,0)

eye_background

Quality settings

Changing the quality settings is only really relevant when you plan on making the LarsonScanner quite large. For smaller scanners, you can leave these on low (default) and nobody will notice.

Low (Default)

low

Medium

medium

High

high

Playground

If you want to experiment with this Larson Scanner, or find the perfect configuration for yourself, there's a class in the misc-folder in this repository, call Playground.java. It creates a GUI for you which lets you play around with all the different settings, so you can see whether this is something for you, or so you can tweak some stuff around to find the perfect settings for you and your project. Enjoy!

playground