Coder Social home page Coder Social logo

vineshchauhan24 / android-glitch-text-effect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from irshu355/android-glitch-text-effect

0.0 0.0 0.0 6.66 MB

An Android library to add a glitch effect into a string, inspired by https://codepen.io/ihatetomatoes/pen/8a16e11e6d6206f5eb1ed7a37fbbe1dc. Gist for this library is here: https://gist.github.com/irshuLx/138c1dc0af5262e3ca0c5f5db014d7ef

License: Apache License 2.0

Java 100.00%

android-glitch-text-effect's Introduction

Download

Android-Glitch-Text-Effect

An Android library to add a glitch effect into a string. This project was inspired by the codepen, https://codepen.io/ihatetomatoes/pen/8a16e11e6d6206f5eb1ed7a37fbbe1dc.

Demo screen below was captured at a limited 25fps

captured at 25fps    captured at 25fps

Download

gradle:

compile 'com.github.irshulx:glitch-text-effect:1.0.1'

or maven:

<dependency>
  <groupId>com.github.irshulx</groupId>
  <artifactId>glitch-text-effect</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

A gist of this library is available at https://gist.github.com/irshuLx/138c1dc0af5262e3ca0c5f5db014d7ef

Usage

<com.github.irshulx.glitchtext.GlitchTextEffect
    android:layout_width="match_parent"
    app:text="PURGE"
    app:noise="7"
    app:textColors="@array/glitch_colors"
    app:textSize="27"
app:speed="70"
    android:layout_height="match_parent" />

or programmatically:

List<Integer> colors = new ArrayList<>();
    colors.add(R.color.colorPrimaryDark);
    colors.add(R.color.colorPink);
    colors.add(R.color.colorLightBlue);
    colors.add(R.color.colorFront);
    
    GlitchTextEffect effect = new GlitchTextEffect(this,colors,"PURGE");
    effect.setTextSize(60);
effect.setSpeed(70); //duration of a single cycle animation
    effect.setNoise(6); //the noise quotient of the effect
    effect.start();     // required to call for programmatic initiation
    layout.addView(effect);

The logic is to stack textviews on a FrameLayout and animate their positions in opposite directions. The no. of textviews added is proportional to the number of colors in the array.

enter image description here

API

void setTextSize(int size);    // set the textsize in sp

void setNoise(int level);     // set the noise level, recommended between 5-10

void setFontFile(String fileName); // set the font to be used, eg: "fonts/Poppins-Black.ttf"

void setSpeed(int speed); // speed in ms, recommends 50-200

##License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-glitch-text-effect's People

Contributors

irshu355 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.