{"id":13396222,"url":"https://github.com/RomainPiel/Titanic","last_synced_at":"2025-03-13T22:31:55.705Z","repository":{"id":15023340,"uuid":"17749071","full_name":"romainpiel/Titanic","owner":"romainpiel","description":"(DEPRECATED) Android experiment showing a sinking TextView","archived":true,"fork":false,"pushed_at":"2016-10-10T13:29:21.000Z","size":267,"stargazers_count":1848,"open_issues_count":2,"forks_count":550,"subscribers_count":105,"default_branch":"master","last_synced_at":"2024-07-31T18:16:50.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"5peak2me/Yalantis-Series","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romainpiel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-14T14:35:28.000Z","updated_at":"2024-07-26T13:27:13.000Z","dependencies_parsed_at":"2022-09-13T03:12:25.444Z","dependency_job_id":null,"html_url":"https://github.com/romainpiel/Titanic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainpiel%2FTitanic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainpiel%2FTitanic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainpiel%2FTitanic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainpiel%2FTitanic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romainpiel","download_url":"https://codeload.github.com/romainpiel/Titanic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221417354,"owners_count":16816867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:42.630Z","updated_at":"2024-10-25T10:31:54.079Z","avatar_url":"https://github.com/romainpiel.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`","Index","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# Titanic for Android\n\nThis library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into your project, it still does its job.\n\nTitanic is an Android experiment reproducing [this effect](http://codepen.io/lbebber/pen/xrwja).\n\n![ScreenShot](titanic.gif)\n\n## How to use\n\nAdd a `TitanicTextView` to your layout:\n```xml\n\u003ccom.romainpiel.titanic.TitanicTextView\n    android:id=\"@+id/titanic_tv\"\n    android:text=\"@string/loading\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:textColor=\"#212121\"\n    android:textSize=\"70sp\"/\u003e\n```\n\nTo start the animation:\n```java\ntitanic = new Titanic();\ntitanic.start(myTitanicTextView);\n```\n\nYou may want to keep track of the titanic instance after the animation is started if you want to stop it.\n\nTo stop it:\n```java\ntitanic.cancel();\n```\n\n## How does it work?\n\n### Quick version\n\nTitanic is a simple illusion obtained by applying an animated translation on the TextView TextPaint Shader's matrix.\n\n### Less quick version\n\n#### What is a Shader?\n\nA [Shader](http://developer.android.com/reference/android/graphics/Shader.html) is a class defining spans of colors. It is installed in a [Paint](http://developer.android.com/reference/android/graphics/Paint.html). It's usually following a certain strategy, so you have LinearGradient shaders, RadialGradient shaders BitmapShader shaders, etc...\n\nShader attributes:\n- tile mode: how the shader color spans should be repeated on the x and y axis.\n- local matrix: can be used to apply transformations on the shader\n\n#### Why are you bugging me with these notions?\n\nWell because it is exaclty what we are using in this experiment.\n\nIn [`TitanicTextView`](https://github.com/RomainPiel/Titanic/blob/master/library/src/main/java/com/romainpiel/titanic/library/TitanicTextView.java), we create a BitmapShader containing a wave bitmap.\n\nWe set the tile mode to:\n- x: `TileMode.REPEAT`. The bitmap is repeated on the x-axis\n- y: `Tilemode.CLAMP`. The edge colors are repeated outside the bitmap on the y-axis\n\nWe have a `maskX` and a `maskY` variable that will define the position of the shader. So at every `onDraw()` we will take in account these values and translate the shader's local matrix at the right position.\n\nWe also have a variable `offsetY` to make the value maskY usable. So when maskY is equal to 0, the wave is at the center of the view.\n\n#### How is it animating?\n\nThe animation is based on Android Animator API. I am not going to go through that part. Go read [the documentation](http://developer.android.com/guide/topics/graphics/prop-animation.html) if you need some explanations.\n\nIn this experiment there are 2 animations.\n- One is moving the wave horizontally from 0 to 200 (the width of the wave bitmap).\n- The second one is moving the wave vertically from the bottom half to the top half.\n\nTo animate these translations, all we need is to apply an animator on `maskX` and `maskY`. The position of the shader's matrix will be updated automatically in `onDraw()`.\n\n#### I want more examples\n\nGlad you said that. Go check out [Shimmer-android](https://github.com/RomainPiel/Shimmer-android). It's based on the same concept with a `LinearGradient` shader.\n\n## Sample\n\nSee the [sample](https://github.com/RomainPiel/Titanic/tree/master/sample) for a common use of this library.\n\n## License\n```\nCopyright 2014 Romain Piel\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRomainPiel%2FTitanic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRomainPiel%2FTitanic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRomainPiel%2FTitanic/lists"}