This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42b9e0a
commit a9516da
Showing
37 changed files
with
1,950 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
namespace "com.flask.colorpicker" | ||
minSdkVersion 23 | ||
targetSdkVersion 33 | ||
versionCode 18 | ||
versionName "0.0.16" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/flask/Documents/android-sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
color-picker/src/androidTest/java/com/flask/colorpicker/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.flask.colorpicker; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<manifest package="com.flask.colorpicker"> | ||
|
||
<application/> | ||
|
||
</manifest> |
54 changes: 54 additions & 0 deletions
54
color-picker/src/main/java/com/flask/colorpicker/ColorCircle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.flask.colorpicker; | ||
|
||
import android.graphics.Color; | ||
|
||
public class ColorCircle { | ||
private float x, y; | ||
private float[] hsv = new float[3]; | ||
private float[] hsvClone; | ||
private int color; | ||
|
||
public ColorCircle(float x, float y, float[] hsv) { | ||
set(x, y, hsv); | ||
} | ||
|
||
public double sqDist(float x, float y) { | ||
double dx = this.x - x; | ||
double dy = this.y - y; | ||
return dx * dx + dy * dy; | ||
} | ||
|
||
public float getX() { | ||
return x; | ||
} | ||
|
||
public float getY() { | ||
return y; | ||
} | ||
|
||
public float[] getHsv() { | ||
return hsv; | ||
} | ||
|
||
public float[] getHsvWithLightness(float lightness) { | ||
if (hsvClone == null) | ||
hsvClone = hsv.clone(); | ||
hsvClone[0] = hsv[0]; | ||
hsvClone[1] = hsv[1]; | ||
hsvClone[2] = lightness; | ||
return hsvClone; | ||
} | ||
|
||
public void set(float x, float y, float[] hsv) { | ||
this.x = x; | ||
this.y = y; | ||
this.hsv[0] = hsv[0]; | ||
this.hsv[1] = hsv[1]; | ||
this.hsv[2] = hsv[2]; | ||
this.color = Color.HSVToColor(this.hsv); | ||
} | ||
|
||
public int getColor() { | ||
return color; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
color-picker/src/main/java/com/flask/colorpicker/ColorCircleDrawable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.flask.colorpicker; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.graphics.drawable.ColorDrawable; | ||
|
||
import com.flask.colorpicker.builder.PaintBuilder; | ||
|
||
public class ColorCircleDrawable extends ColorDrawable { | ||
private float strokeWidth; | ||
private Paint strokePaint = PaintBuilder.newPaint().style(Paint.Style.STROKE).stroke(strokeWidth).color(0xff9e9e9e).build(); | ||
private Paint fillPaint = PaintBuilder.newPaint().style(Paint.Style.FILL).color(0).build(); | ||
private Paint fillBackPaint = PaintBuilder.newPaint().shader(PaintBuilder.createAlphaPatternShader(26)).build(); | ||
|
||
public ColorCircleDrawable(int color) { | ||
super(color); | ||
} | ||
|
||
@Override | ||
public void draw(Canvas canvas) { | ||
canvas.drawColor(0); | ||
|
||
int width = canvas.getWidth(); | ||
float radius = width / 2f; | ||
strokeWidth = radius / 8f; | ||
|
||
this.strokePaint.setStrokeWidth(strokeWidth); | ||
this.fillPaint.setColor(getColor()); | ||
canvas.drawCircle(radius, radius, radius - strokeWidth, fillBackPaint); | ||
canvas.drawCircle(radius, radius, radius - strokeWidth, fillPaint); | ||
canvas.drawCircle(radius, radius, radius - strokeWidth, strokePaint); | ||
} | ||
|
||
@Override | ||
public void setColor(int color) { | ||
super.setColor(color); | ||
invalidateSelf(); | ||
} | ||
} |
Oops, something went wrong.