Git Product home page Git Product logo

irurueta-android-gl-curl's Introduction

irurueta-android-gl-curl

A 3D page curl view

Build Status

Code Smells Coverage

Duplicated lines Lines of code

Maintainability Quality gate Reliability

Security Technical debt Vulnerabilities

Maven Central

API Documentation

Overview

This library contains views to draw pages of a book with a 3D animation when page flipping is done. Two views are available:

  • CurlGLSurfaceView: extends from GLSurfaceView, consequently the view does not belong to the normal view hierarchy preventing typical view animations or transparencies when views are composed. Because of tat, it has slightly better performance.
  • CurlTextureView: extends from GLTextureView, which belongs to the normal view hierarchy and allows normal view composition including transparencies or view animations.

Demo

Usage

Add the following dependency to your project:

implementation 'com.irurueta:irurueta-android-gl-curl:1.0.2'

The view can be added to your layout as:

    <com.irurueta.android.gl.curl.CurlTextureView
        android:id="@+id/curl_gl_surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

In order to draw something, a page provider must be provided as in the example below:

    view?.pageProvider = object : CurlTextureView.PageProvider {
        override val pageCount: Int
            get() = PAGE_COUNT

        override fun updatePage(
            page: CurlPage,
            width: Int,
            height: Int,
            index: Int,
            backIndex: Int?
        ) {
            // Load new bitmap for curl page view.
            // In real world scenario, images should be cached in memory for
            // performance reasons.
            val bitmap = loadBitmap(width, height, index)
            if (backIndex == null) {
                page.setTexture(bitmap, CurlPage.SIDE_BOTH)
            } else {
                // load bitmap for back side
                val backBitmap = loadBitmap(width, height, backIndex)
                page.setTexture(bitmap, CurlPage.SIDE_FRONT)
                page.setTexture(backBitmap, CurlPage.SIDE_BACK)
            }

            // set semi transparent white for background to get a bit of transparency
            // on back images when being flipped
            val context = view?.context ?: return
            page.setColor(
                ContextCompat.getColor(context, R.color.translucid_white),
                CurlPage.SIDE_BACK
            )
        }
    }

For more information, please refer to the demo application activity contained in the app module.

irurueta-android-gl-curl's People

Contributors

albertoirurueta avatar

Stargazers

Maulana Hanif Al Faqih Rojichan avatar

Watchers

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