This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SquircleDrawable.js
49 lines (44 loc) · 7.59 KB
/
SquircleDrawable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @file ModPE design library for providing squircle drawable API.
* @author Astro <[email protected]>
* @version 1.0
* @license Apache-2.0
*/
/** @namespace global */
($ => {
"use strict";
const BitmapFactory_ = android.graphics.BitmapFactory,
PorterDuff_ = android.graphics.PorterDuff,
PorterDuffColorFilter_ = android.graphics.PorterDuffColorFilter,
BitmapDrawable_ = android.graphics.drawable.BitmapDrawable,
Base64_ = android.util.Base64;
/**
* Class representing a squircle drawable.
* @since 2016-08-24
* @class
* @memberOf global
*/
function SquircleDrawable() {}
/**
* A drawable to be copied.
* @type {android.graphics.drawable.BitmapDrawable}
*/
SquircleDrawable.RESOURCE = (() => {
let bytes = Base64_.decode("iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAMAAABlApw1AAAC91BMVEUAAAD09PTw8PD+/v6lpaVvb28UFBT///8HBwcEBAQJCQkAAAABAQECAgIjIyNISEhiYmJ2dnZ4eHiLi4uWlpagoKCmpqarq6v///+wsLDFxcXQ0NDa2trh4eHh4eHo6Ojq6urs7Ozw8PDy8vLy8vL19fXz8/P09PT19fX39/f39/f4+Pj5+fm9vb3Q0NDa2trl5eXw8PD6+vr9/f36+voDAwOUlJTIyMjo6Oju7u76+vr5+fn5+fkRERFfX1+2trbY2NiwsLDn5+dfX18jIyPExMT39/fIyMgAAABMTEzLy8uDg4Pr6+ugoKDh4eHLy8vy8vLg4OBERES5ubnExMSKioqlpaW3t7f19fWCgoJxcXHl5eX////T09Ph4eHx8fG1tbX29vaampoBAQHm5uavr68dHR3q6uqnp6dxcXGOjo7Z2dlQUFC9vb2Kioqfn5/R0dH///9TU1PJycmhoaECAgJjY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vi4jTdDR4X36zJMjhmynCI/66eP7Qpb+PXT7xz8Gde45DMtDOcIS85nZ7kHrtzBn2CJfr+J6dB/85cfnY35cOnb/4V0Q4PO8aeYJFJOhEE0r1CWXwfTWYIi43Iq/u4unz2w/tv7Tj8L+7dh+7cOHy5SNHzn3ntXNHjly+fOHCsd27/j2849L+Q9vPn75YlxeRG6fA2Fcos+ilQkEXmVAkMVmMRlYRzjBMoYiLCw9PTc3NVfosNzc1NTw8Lk6hwLD6I+VGo8UkEXUZ8iuYCIWiZInEBC2BMyNrZdC4bzw/Y38rkSSL4MGCa3bNrtk1Y+1/kVFqJX5x+88AAAAASUVORK5CYII=", 0);
return new BitmapDrawable_(BitmapFactory_.decodeByteArray(bytes, 0, bytes.length));
})();
/**
* Creates a squircle drawable.
* @since 2016-08-24
* @param {Number} [color] Drawable color
* @returns {android.graphics.drawable.BitmapDrawable} Squircle drawable
*/
SquircleDrawable.create = function (color) {
let drawable = SquircleDrawable.RESOURCE;
if (color) {
drawable.getPaint().setColorFilter(new PorterDuffColorFilter_(color, PorterDuff_.Mode.SRC_ATOP));
}
return drawable;
};
$.SquircleDrawable = SquircleDrawable;
})(this);