Giter Club home page Giter Club logo

letter-avatar's Introduction

LetterAvatar

A Material-Design-like avatar that displays the first letter of a user's name. Similar to those shown at inbox.google.com

Prime Example

It's SceneBuilder compatible!

  1. Clone this repository and run mvn clean install in the root of the project.
  2. Add to SceneBuilder
    1. Add to SceneBuilder Animation

Sample Usage

// The argument will determine the background color; this will always be the same color for the same input.
// This assumes you want the avatar's letter to be the first letter of the user's name.
LetterAvatar la = new LetterAvatar(user.getName());

// If you want to be explicit about which letter to use, use this constructor.
LetterAvatar la = new LetterAvatar("B", "some unique-to-the-user value");

Change Avatar Character

I designed LetterAvatar to have one character, but if you felt like it, maybe you could put two.

letterAvatar.setAvatarCharacter("Z");

Change Size

LetterAvatar changes its size based on the font size, so all you have to do is make the font a little bigger and the background circle will automatically grow.

letterAvatar.setFont(Font.font(32));

Change Background Color Pallete

LetterAvatar uses the Material Design Color Palletes.

By default I assume you want to use all of them and so the only thing left to do is to decide how dark—I call this the color number for lack of a better phrase.

Darkness

leterAvatar.setColorNumber("100");

   the gammut

You can pick

  • 50
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
  • A100
  • A200
  • A400
  • A700

*A100, A200, A400, and A700 are not available for brown, grey and blue-grey.

Font Color

If you find yourself hating the fact that at a certain darkness some colors require a white font fill and others don't,

  1. Blame JavaFX 😄

  2. In your stylesheet, override the -fx-text-fill using something like this

    .letter-avatar { -fx-text-fill: white; }

Hues

The hues are looked up from a stylesheet that LetterAvatar holds inside it. Theoretically, if you were to maintain the pattern, at runtime you could add and take away hues from letterAvatar.getHues(). This would be your stratgey if you wanted to use accent colors (because brown, grey and blue-grey don't have accent colors).

letter-avatar's People

Contributors

turekbot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.