Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Added fourth of shape, name is GLASS. #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -16,6 +17,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 20 15:20:33 CST 2017
#Thu Mar 19 15:26:18 EET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public enum ShapeType {
TRIANGLE,
CIRCLE,
SQUARE,
RECTANGLE
RECTANGLE,
GLASS
}

public enum TriangleDirection {
Expand Down Expand Up @@ -324,6 +325,26 @@ public void onDraw(Canvas canvas) {
}
}
break;
case 4:
if (mIsRoundRectangle) {
if (borderWidth > 0) {
canvas.drawPath(roundedRect(borderWidth / 2f,0,getWidth() - borderWidth / 2f - 0.5f,getHeight() - borderWidth / 2f - 0.5f,mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mBorderPaint);
canvas.drawPath(roundedRect(borderWidth + 10,0,getWidth()-(borderWidth + 10),getHeight()-(borderWidth + 10),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWaveBgPaint);
canvas.drawPath(roundedRect(borderWidth + 10,0,getWidth()-(borderWidth + 10),getHeight()-(borderWidth + 10),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWavePaint);
} else {
canvas.drawPath(roundedRect(0,0,getWidth(),getHeight(),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWaveBgPaint);
canvas.drawPath(roundedRect(0,0,getWidth(),getHeight(),mRoundRectangleXY,mRoundRectangleXY,false,false,true,true), mWavePaint);
}
} else {
if (borderWidth > 0) {
canvas.drawRect(borderWidth / 2f, borderWidth / 2f, getWidth() - borderWidth / 2f - 0.5f, getHeight() - borderWidth / 2f - 0.5f, mWaveBgPaint);
canvas.drawRect(borderWidth / 2f, borderWidth / 2f, getWidth() - borderWidth / 2f - 0.5f, getHeight() - borderWidth / 2f - 0.5f, mWavePaint);
} else {
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mWaveBgPaint);
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mWavePaint);
}
}
break;
default:
break;
}
Expand Down Expand Up @@ -836,4 +857,56 @@ else if (direction == 3) {

return path;
}

public static Path roundedRect(
float left, float top, float right, float bottom, float rx, float ry,
boolean tl, boolean tr, boolean br, boolean bl
){
Path path = new Path();
if (rx < 0) rx = 0;
if (ry < 0) ry = 0;
float width = right - left;
float height = bottom - top;
if (rx > width / 2) rx = width / 2;
if (ry > height / 2) ry = height / 2;
float widthMinusCorners = (width - (2 * rx));
float heightMinusCorners = (height - (2 * ry));

path.moveTo(right, top + ry);
if (tr)
path.rQuadTo(0, -ry, -rx, -ry);//top-right corner
else{
path.rLineTo(0, -ry);
path.rLineTo(-rx,0);
}
path.rLineTo(-widthMinusCorners, 0);
if (tl)
path.rQuadTo(-rx, 0, -rx, ry); //top-left corner
else{
path.rLineTo(-rx, 0);
path.rLineTo(0,ry);
}
path.rLineTo(0, heightMinusCorners);

if (bl)
path.rQuadTo(0, ry, rx, ry);//bottom-left corner
else{
path.rLineTo(0, ry);
path.rLineTo(rx,0);
}

path.rLineTo(widthMinusCorners, 0);
if (br)
path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner
else{
path.rLineTo(rx,0);
path.rLineTo(0, -ry);
}

path.rLineTo(0, -heightMinusCorners);

path.close();//Given close, last lineto can be removed.

return path;
}
}