Giter VIP home page Giter VIP logo

nikhiljainlive / blockies_android Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 159 KB

Blockies Icon Generator: Create unique blocky-style avatars in your Android apps with this library. Customize avatar sizes and pixelation for a creative touch.

License: MIT License

Kotlin 97.89% Java 2.11%
android blockies blockies-library ethereum identicon-generator identicon-library kotlin-android blockies-android

blockies_android's Introduction

Blockies Icons Android

Blockies Icon

This project is inspired by ethereum/blockies.

Modules

1. blockiesview

The blockiesview module offers a custom view for displaying blockies icons. You can adjust the icon's size and appearance based on the view's width and height, as well as the pixel size.

Usage

<!-- app:color, app:bgColor, app:spotColor are optional -->

<com.nikhiljain.blockiesview.BlockiesIconView
    android:layout_width="200dp"
    android:layout_height="200dp"
    app:seed="0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"
    app:size="10"
    app:color="@android:color/holo_green_light"
    app:bgColor="@android:color/holo_blue_light"
    app:spotColor="@android:color/holo_orange_dark" />

2. blockiesgenerator

The blockiesgenerator module is responsible for generating blockies icon bitmaps. You can control the pixel size and image scale to produce custom icons.

Usage

val imageView = ImageView(this)
imageView.layoutParams = ViewGroup.LayoutParams(100, 100)

// Create a BlockiesIconGenerator instance
val iconGenerator = BlockiesIconGenerator(
    seed = "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359",
    size = 10,
    scale = 10,
    color = ContextCompat.getColor(context, android.R.color.holo_green_light),       // color will be generated as per the seed if not passed
    bgColor = ContextCompat.getColor(context, android.R.color.holo_blue_bright),     // bgColor will be generated as per the seed if not passed
    spotColor = ContextCompat.getColor(context, android.R.color.holo_orange_dark)    // spotColor will be generated as per the seed if not passed
)

// Generate the blockies icon bitmap
val blockiesIconBitmap = iconGenerator.generateIconBitmap()

// Set the generated bitmap to an ImageView
imageView.setImageBitmap(blockiesIconBitmap)

3. blockiesglide

The blockiesglide module requires Glide library as dependency. This module injects BlockiesGlideModule custom Glide module and loads the bitmap image from the BlockiesIconData object.

Usage

val imageView = ImageView(this)
imageView.layoutParams = ViewGroup.LayoutParams(100, 100)
Glide.with(imageView)
    .load(
        BlockiesIconData(
            seed = "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359",
            size = 10,
            color = android.R.color.holo_green_light,        // color will be generated as per the seed if not passed
            bgColor = android.R.color.holo_blue_bright,      // bgColor will be generated as per the seed if not passed
            spotColor = android.R.color.holo_orange_dark     // spotColor will be generated as per the seed if not passed
        )
    )
    .placeholder(R.drawable.ic_launcher_foreground)
    .circleCrop()
    .into(imageView)

The above code sample loads the bitmap from the BlockiesIconData object with the help of Glide library.

Getting Started

To use this library in your Android project, you need to include it as a dependency in your app module build.gradle file. Make sure you have JitPack as a repository in your project's build.gradle file.

dependencies {
    // BlockiesView dependency
    implementation 'com.github.nikhiljainlive.blockies_android:blockiesview:v0.2.0'

    // BlockiesGenerator dependency
    implementation 'com.github.nikhiljainlive.blockies_android:blockiesgenerator:v0.2.0'

    // BlockiesGlide dependency
    implementation 'com.github.nikhiljainlive.blockies_android:blockiesglide:v0.2.0'
}

And, in root project directory's build.gradle file:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
      mavenCentral()
      maven { url 'https://jitpack.io' }
    }
}

For more information and advanced usage, refer to the project's samples.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support or Contact

If you have any questions or need assistance, please feel free to create an issue in this repository.

blockies_android's People

Contributors

nikhiljainlive avatar

Stargazers

 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.