This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import Particlesdrawable library from https://github.com/Doctoror/Par…
- Loading branch information
Showing
24 changed files
with
2,023 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
69 changes: 69 additions & 0 deletions
69
library/src/main/java/com/neko/particlesdrawable/CanvasParticlesView.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,69 @@ | ||
/* | ||
* Copyright (C) 2017 Yaroslav Mytkalyk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.neko.particlesdrawable; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.ColorFilter; | ||
import android.graphics.Paint; | ||
|
||
import androidx.annotation.ColorInt; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
/** | ||
* {@link IParticlesView} that draws on {@link Canvas} | ||
*/ | ||
final class CanvasParticlesView implements IParticlesView { | ||
|
||
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); | ||
|
||
@Nullable | ||
private Canvas mCanvas; | ||
|
||
void setCanvas(@Nullable final Canvas canvas) { | ||
mCanvas = canvas; | ||
} | ||
|
||
@NonNull | ||
Paint getPaint() { | ||
return mPaint; | ||
} | ||
|
||
void setColorFilter(final ColorFilter colorFilter) { | ||
mPaint.setColorFilter(colorFilter); | ||
} | ||
|
||
@Override | ||
public void drawLine(final float startX, final float startY, final float stopX, | ||
final float stopY, final float strokeWidth, @ColorInt final int color) { | ||
if (mCanvas == null) { | ||
throw new IllegalStateException("Called in wrong state"); | ||
} | ||
mPaint.setStrokeWidth(strokeWidth); | ||
mPaint.setColor(color); | ||
mCanvas.drawLine(startX, startY, stopX, stopY, mPaint); | ||
} | ||
|
||
@Override | ||
public void fillCircle(final float cx, final float cy, final float radius, | ||
@ColorInt final int color) { | ||
if (mCanvas == null) { | ||
throw new IllegalStateException("Called in wrong state"); | ||
} | ||
mPaint.setColor(color); | ||
mCanvas.drawCircle(cx, cy, radius, mPaint); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
library/src/main/java/com/neko/particlesdrawable/Defaults.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,48 @@ | ||
/* | ||
* Copyright (C) 2017 Yaroslav Mytkalyk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.neko.particlesdrawable; | ||
|
||
import android.content.res.Resources; | ||
import android.graphics.Color; | ||
import android.util.TypedValue; | ||
|
||
import androidx.annotation.ColorInt; | ||
|
||
/** | ||
* Default values are here. | ||
*/ | ||
final class Defaults { | ||
|
||
private Defaults() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
static final int DEFAULT_DOT_NUMBER = 60; | ||
static final float DEFAULT_MAX_DOT_RADIUS = TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, 3f, Resources.getSystem().getDisplayMetrics()); | ||
static final float DEFAULT_MIN_DOT_RADIUS = TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, 1f, Resources.getSystem().getDisplayMetrics()); | ||
static final float DEFAULT_LINE_THICKNESS = TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, 1, Resources.getSystem().getDisplayMetrics()); | ||
@ColorInt | ||
static final int DEFAULT_DOT_COLOR = Color.WHITE; | ||
@ColorInt | ||
static final int DEFAULT_LINE_COLOR = Color.WHITE; | ||
static final float DEFAULT_LINE_DISTANCE = TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, 86, Resources.getSystem().getDisplayMetrics()); | ||
static final float DEFAULT_STEP_MULTIPLIER = 1f; | ||
static final int DEFAULT_DELAY = 10; | ||
} |
29 changes: 29 additions & 0 deletions
29
library/src/main/java/com/neko/particlesdrawable/IParticlesView.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,29 @@ | ||
/* | ||
* Copyright (C) 2017 Yaroslav Mytkalyk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.neko.particlesdrawable; | ||
|
||
import androidx.annotation.ColorInt; | ||
|
||
/** | ||
* Particles View | ||
*/ | ||
interface IParticlesView { | ||
|
||
void drawLine(float startX, float startY, float stopX, float stopY, float strokeWidth, | ||
@ColorInt int color); | ||
|
||
void fillCircle(float cx, float cy, float radius, @ColorInt int color); | ||
} |
52 changes: 52 additions & 0 deletions
52
library/src/main/java/com/neko/particlesdrawable/Particle.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,52 @@ | ||
/* | ||
* Copyright (C) 2017 Yaroslav Mytkalyk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.neko.particlesdrawable; | ||
|
||
/** | ||
* Represents a Particle by holding x and y coordinates, travel direction and step multiplier | ||
*/ | ||
final class Particle { | ||
|
||
/** | ||
* Direction cosine | ||
*/ | ||
float dCos; | ||
|
||
/** | ||
* Direction sine | ||
*/ | ||
float dSin; | ||
|
||
/** | ||
* Current X | ||
*/ | ||
float x; | ||
|
||
/** | ||
* Current Y | ||
*/ | ||
float y; | ||
|
||
/** | ||
* Step multiplier for this dot | ||
*/ | ||
float stepMultiplier; | ||
|
||
/** | ||
* Radius multiplier for this dot | ||
*/ | ||
float radius; | ||
} |
Oops, something went wrong.