Repository: torryharris/Skycons
Branch: master
Commit: 8d69ad6d189e
Files: 70
Total size: 151.0 KB
Directory structure:
gitextract_79fkheb0/
├── .gitignore
├── README.md
└── Skycons/
├── .gitignore
├── SkyconDemo/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── thbs/
│ │ └── com/
│ │ └── skycons/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── thbs/
│ │ └── skycons/
│ │ ├── CloudActivity.java
│ │ ├── CloudFogActivity.java
│ │ ├── CloudHvRainActivity.java
│ │ ├── CloudMoonActivity.java
│ │ ├── CloudRainActivity.java
│ │ ├── CloudSnowActivity.java
│ │ ├── CloudSunActivity.java
│ │ ├── MainActivity.java
│ │ ├── MoonActivity.java
│ │ ├── SunActivity.java
│ │ ├── ThunderActivity.java
│ │ ├── ViewAllActivity.java
│ │ └── WindActivity.java
│ └── res/
│ ├── layout/
│ │ ├── activity_main.xml
│ │ ├── all_views.xml
│ │ ├── cloud.xml
│ │ ├── cloud_fog.xml
│ │ ├── cloud_hvrain.xml
│ │ ├── cloud_moon.xml
│ │ ├── cloud_rain.xml
│ │ ├── cloud_snow.xml
│ │ ├── cloud_sun.xml
│ │ ├── moon.xml
│ │ ├── sun.xml
│ │ ├── thunder.xml
│ │ └── wind.xml
│ ├── menu/
│ │ └── main.xml
│ ├── values/
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── values-w820dp/
│ └── dimens.xml
├── SkyconsLibrary/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── thbs/
│ │ └── skycons/
│ │ └── library/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── thbs/
│ │ └── skycons/
│ │ └── library/
│ │ ├── Cloud.java
│ │ ├── CloudFogView.java
│ │ ├── CloudHvRainView.java
│ │ ├── CloudMoonView.java
│ │ ├── CloudRainView.java
│ │ ├── CloudSnowView.java
│ │ ├── CloudSunView.java
│ │ ├── CloudThunderView.java
│ │ ├── CloudView.java
│ │ ├── MoonView.java
│ │ ├── SkyconView.java
│ │ ├── SunView.java
│ │ └── WindView.java
│ └── res/
│ ├── layout/
│ │ └── activity_main.xml
│ ├── menu/
│ │ └── main.xml
│ ├── values/
│ │ ├── attrs.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── values-w820dp/
│ └── dimens.xml
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# new gitignore for android studio projects
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
.idea
.gradle
build
*/build
*.iml
================================================
FILE: README.md
================================================
Skycons for Android [](https://android-arsenal.com/details/1/1043)
===================
We set out to create a native weather app on Xamarin but we wanted to build something unique to differentiate ourselves amongst the plethora of weather apps avaialble out there. The [DarkSky](http://darkskyapp.com) app & [Forecast](http://forecast.io) did an excellent job with their [Skycons](http://darkskyapp.github.io/skycons/).
We wanted to re-use the same icons for our app as well, however, we found that these animated icons don't exist natively on either platforms. This is currently a work-in-progress as the team is finetuning the animation & the performance itself. You can download the complete repository which also contains the sample project SkyconsDemo.
*Built with Android Studio (2.2.3)*
## Available Icons
| Icon | View |
| :------: | :---: |
| Cloud | CloudView |
| Clear Sky (Sunny) | SunView |
| Clear Night | MoonView |
| Partly Cloudy Day | CloudSunView |
| Partly Cloudy Night | CloudMoonView |
| Heavy Showers | CloudHvRainView |
| Snow | CloudSnowView |
| Light Showers | CloudRainView |
| Fog | CloudFogView |
| Wind | WindView |
| Thunder | CloudThunderView |
## How to use
- Deployment target should be API level 14 or above.
- Import 'SkyconsLibrary' as a library to your project.
## Adding icons:
1) To add a skycon(icon) through the XML:
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:isStatic = "true"
app:strokeColor = "#000000"
app:bgColor = "#ffffff"/>
where represents the particular view/icon. For example "MoonView"
2) To add a skycon(For instance, WindView) through Java code, perform following in the activity:
LinearLayout layout = new LinearLayout(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(params);
//Using these params, you can control view attributes
//attributres include boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor
WindView windView = new WindView(this,true,false, Color.parseColor("#000000"),Color.parseColor("#ffffff"));
//Using these params, you can control width & height of the icon
params.width = 200;
params.height = 200;
windView.setLayoutParams(params);
layout.addView(windView);
this.setContentView(layout);
- For a better experience, keep 'layout_width' & 'layout_height' the same.
## Customization:
| Options | Value | Description |
| :------: | :---: | :----------: |
| layout_width | 100dp (recommended min value) | Width of icon |
| layout_height | 100dp (recommended min value) | Height of the icon |
| isStatic | True / False | Boolean Value to enable on-touch animation |
| strokeColor | HEX | Customize the color of the icon |
| bgColor | HEX | Customize the background colour |
Pull Requests are welcomed. We are looking forward for your suggestions on new icons & animations.
##Demo
License
=======
Skycons for Android is being made available in public domain under similar terms like the [original](https://github.com/darkskyapp/skycons)
================================================
FILE: Skycons/.gitignore
================================================
# new gitignore for android studio projects
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
.idea
.gradle
build
*/build
*.iml
================================================
FILE: Skycons/SkyconDemo/.gitignore
================================================
/build
================================================
FILE: Skycons/SkyconDemo/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.thbs.skycons"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SkyconsLibrary')
}
================================================
FILE: Skycons/SkyconDemo/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio.app/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 *;
#}
================================================
FILE: Skycons/SkyconDemo/src/androidTest/java/thbs/com/skycons/ApplicationTest.java
================================================
package thbs.com.skycons;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* Testing Fundamentals
*/
public class ApplicationTest extends ApplicationTestCase {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/AndroidManifest.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 10/09/14.
*/
public class CloudActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudFogActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 10/09/14.
*/
public class CloudFogActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_fog);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudHvRainActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 10/09/14.
*/
public class CloudHvRainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_hvrain);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudMoonActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 11/09/14.
*/
public class CloudMoonActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_moon);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudRainActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 10/09/14.
*/
public class CloudRainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_rain);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudSnowActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 10/09/14.
*/
public class CloudSnowActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_snow);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/CloudSunActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
public class CloudSunActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud_sun);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/MainActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Button btnViewAll, btnSun, btnCloudSun,btnCloud, btnCloudRain, btnCloudHvRain, btnCloudSnow,
btnCloudFog, btnMoon, btnCloudMoon, btnWind, btnThunder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnViewAll = (Button) findViewById(R.id.all);
btnSun = (Button) findViewById(R.id.sun);
btnCloudSun = (Button) findViewById(R.id.cloud_sun);
btnCloud = (Button) findViewById(R.id.cloud);
btnCloudRain = (Button) findViewById(R.id.cloud_rain);
btnCloudHvRain = (Button) findViewById(R.id.cloud_hvrain);
btnCloudSnow = (Button) findViewById(R.id.cloud_snow);
btnCloudFog = (Button) findViewById(R.id.cloud_fog);
btnMoon = (Button) findViewById(R.id.moon);
btnCloudMoon = (Button) findViewById(R.id.cloud_moon);
btnWind = (Button) findViewById(R.id.wind);
btnThunder = (Button) findViewById(R.id.thunder);
btnViewAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, ViewAllActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnSun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, SunActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudSun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudSunActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloud.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudRain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudRainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudHvRain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudHvRainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudSnow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudSnowActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudFog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudFogActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnMoon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, MoonActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnCloudMoon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, CloudMoonActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnWind.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, WindActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
btnThunder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, ThunderActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/MoonActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 11/09/14.
*/
public class MoonActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.moon);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/SunActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
<<<<<<< HEAD
* Created by administrator on 29/09/14.
=======
* Created by administrator on 9/29/14.
>>>>>>> 31ecf11b87fdd0f58ca31eb3b2754003debca09f
*/
public class SunActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sun);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/ThunderActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by admin on 10/1/14.
*/
public class ThunderActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.thunder);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/ViewAllActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 30/09/14.
*/
public class ViewAllActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_views);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/java/com/thbs/skycons/WindActivity.java
================================================
package com.thbs.skycons;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by administrator on 15/09/14.
*/
public class WindActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wind);
}
}
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/activity_main.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/all_views.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_fog.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_hvrain.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_moon.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_rain.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_snow.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/cloud_sun.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/moon.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/sun.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/thunder.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/layout/wind.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/menu/main.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/values/dimens.xml
================================================
16dp
16dp
================================================
FILE: Skycons/SkyconDemo/src/main/res/values/strings.xml
================================================
Skycons
Hello world!
Settings
================================================
FILE: Skycons/SkyconDemo/src/main/res/values/styles.xml
================================================
================================================
FILE: Skycons/SkyconDemo/src/main/res/values-w820dp/dimens.xml
================================================
64dp
================================================
FILE: Skycons/SkyconsLibrary/.gitignore
================================================
/build
================================================
FILE: Skycons/SkyconsLibrary/build.gradle
================================================
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
================================================
FILE: Skycons/SkyconsLibrary/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio.app/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 *;
#}
================================================
FILE: Skycons/SkyconsLibrary/src/androidTest/java/com/thbs/skycons/library/ApplicationTest.java
================================================
package com.thbs.skycons.library;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* Testing Fundamentals
*/
public class ApplicationTest extends ApplicationTestCase {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/AndroidManifest.xml
================================================
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/Cloud.java
================================================
package com.thbs.skycons.library;
import android.graphics.Path;
import android.graphics.PointF;
/**
* Created by administrator on 10/1/14.
*/
public class Cloud {
Path path;
public Path getCloud(float centerX, float centerY, int dimension, double count) {
//different radius values for the cloud coordinates
path = new Path();
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
// cloud coordinates from the center of the screen
float X1 = (float) (r1 * Math.cos(Math.toRadians(0 + (0.222 * count))) + centerX); //x value of coordinate 1 at radius r1 from center of Screen and angle incremented with counter
float Y1 = ((float) (r2 * Math.sin(Math.toRadians(0 + (0.222 * count))) + centerY));//y value of coordinate 1 at radius r2 from center of Screen and angle incremented with counter
float P1X = (float) (r1 * Math.cos(Math.toRadians(80 + (0.111 * count))) + centerX);//x value of coordinate 2 at radius r1 from center of Screen and angle incremented with counter
float P1Y = ((float) (r2 * Math.sin(Math.toRadians(80 + (0.111 * count))) + centerY));//y value of coordinate 2 at radius r2 from center of Screen and angle incremented with counter
float P2X = (float) (r1 * Math.cos(Math.toRadians(120 + (0.222 * count))) + centerX);//x value of coordinate 3 at radius r1 from center of Screen and angle incremented with counter
float P2Y = ((float) ((r2 + (offset * count)) * Math.sin(Math.toRadians(120 + (0.222 * count))) + centerY));//y value of coordinate 3 at varying radius from center of Screen and angle incremented with counter
float P3X = (float) (r1 * Math.cos(Math.toRadians(200 + (0.222 * count))) + centerX);//x value of coordinate 4 at radius r1 from center of Screen and angle incremented with counter
float P3Y = ((float) (r1 * Math.sin(Math.toRadians(200 + (0.222 * count))) + centerY));//y value of coordinate 4 at radius r1 from center of Screen and angle incremented with counter
float P4X = (float) (r1 * Math.cos(Math.toRadians(280 + (0.222 * count))) + centerX);//x value of coordinate 5 at radius r1 from center of Screen and angle incremented with counter
float P4Y = ((float) (r1 * Math.sin(Math.toRadians(280 + (0.222 * count))) + centerY));//y value of coordinate 5 at radius r1 from center of Screen and angle incremented with counter
path.moveTo(X1, Y1);
// getting points in between coordinates for drawing arc between them
PointF P1c1 = calculateTriangle(X1, Y1, P1X, P1Y, true);
PointF P1c2 = calculateTriangle(X1, Y1, P1X, P1Y, false);
PointF P2c1 = calculateTriangle(P1X, P1Y, P2X, P2Y, true);
PointF P2c2 = calculateTriangle(P1X, P1Y, P2X, P2Y, false);
PointF P3c1 = calculateTriangle(P2X, P2Y, P3X, P3Y, true);
PointF P3c2 = calculateTriangle(P2X, P2Y, P3X, P3Y, false);
PointF P4c1 = calculateTriangle(P3X, P3Y, P4X, P4Y, true);
PointF P4c2 = calculateTriangle(P3X, P3Y, P4X, P4Y, false);
PointF P5c1 = calculateTriangle(P4X, P4Y, X1, Y1, true);
PointF P5c2 = calculateTriangle(P4X, P4Y, X1, Y1, false);
// drawing arcs between coordinates
path.moveTo(X1, Y1);
path.cubicTo(P1c1.x, P1c1.y, P1c2.x, P1c2.y, P1X, P1Y);
path.cubicTo(P2c1.x, P2c1.y, P2c2.x, P2c2.y, P2X, P2Y);
path.cubicTo(P3c1.x, P3c1.y, P3c2.x, P3c2.y, P3X, P3Y);
path.cubicTo(P4c1.x, P4c1.y, P4c2.x, P4c2.y, P4X, P4Y);
path.cubicTo(P5c1.x, P5c1.y, P5c2.x, P5c2.y, X1, Y1);
return path;
}
private PointF calculateTriangle(float x1, float y1, float x2,
float y2, boolean left) {
PointF result = new PointF(0, 0);
// finding center point between the coordinates
float dy = y2 - y1;
float dx = x2 - x1;
float dangle = 0;
// calculating angle and the distance between center and the two points
if (left) {
dangle = (float) ((Math.atan2(dy, dx) - Math.PI / 3f));
} else {
dangle = (float) ((Math.atan2(dy, dx) - Math.PI / 1.5f));
}
float sideDist = (float) 0.45 * (float) Math.sqrt(dx * dx + dy * dy); //square
// sideDist = sideDist + sideDist/10;
if (left) {
//point from center to the left
result.x = (int) (Math.cos(dangle) * sideDist + x1);
result.y = (int) (Math.sin(dangle) * sideDist + y1);
} else {
//point from center to the right
result.x = (int) (Math.cos(dangle) * sideDist + x2);
result.y = (int) (Math.sin(dangle) * sideDist + y2);
}
return result;
}
public PointF getP1c1(float centerX, float centerY, int dimension, double count){
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
// cloud coordinates from the center of the screen
float X1 = (float) (r1 * Math.cos(Math.toRadians(0 + (0.222 * count))) + centerX); //x value of coordinate 1 at radius r1 from center of Screen and angle incremented with counter
float Y1 = ((float) (r2 * Math.sin(Math.toRadians(0 + (0.222 * count))) + centerY));//y value of coordinate 1 at radius r2 from center of Screen and angle incremented with counter
float P1X = (float) (r1 * Math.cos(Math.toRadians(80 + (0.111 * count))) + centerX);//x value of coordinate 2 at radius r1 from center of Screen and angle incremented with counter
float P1Y = ((float) (r2 * Math.sin(Math.toRadians(80 + (0.111 * count))) + centerY));//y value of coordinate 2 at radius r2 from center of Screen and angle incremented with counter
// getting points in between coordinates for drawing arc between them
PointF P1c1 = calculateTriangle(X1, Y1, P1X, P1Y, true);
return P1c1;
}
public PointF getP1c2(float centerX, float centerY, int dimension, double count){
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
// cloud coordinates from the center of the screen
float X1 = (float) (r1 * Math.cos(Math.toRadians(0 + (0.222 * count))) + centerX); //x value of coordinate 1 at radius r1 from center of Screen and angle incremented with counter
float Y1 = ((float) (r2 * Math.sin(Math.toRadians(0 + (0.222 * count))) + centerY));//y value of coordinate 1 at radius r2 from center of Screen and angle incremented with counter
float P1X = (float) (r1 * Math.cos(Math.toRadians(80 + (0.111 * count))) + centerX);//x value of coordinate 2 at radius r1 from center of Screen and angle incremented with counter
float P1Y = ((float) (r2 * Math.sin(Math.toRadians(80 + (0.111 * count))) + centerY));//y value of coordinate 2 at radius r2 from center of Screen and angle incremented with counter
PointF P1c2 = calculateTriangle(X1, Y1, P1X, P1Y, false);
return P1c2;
}
public PointF getP2c1(float centerX, float centerY, int dimension, double count){
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
// cloud coordinates from the center of the screen
float P1X = (float) (r1 * Math.cos(Math.toRadians(80 + (0.111 * count))) + centerX);//x value of coordinate 2 at radius r1 from center of Screen and angle incremented with counter
float P1Y = ((float) (r2 * Math.sin(Math.toRadians(80 + (0.111 * count))) + centerY));//y value of coordinate 2 at radius r2 from center of Screen and angle incremented with counter
float P2X = (float) (r1 * Math.cos(Math.toRadians(120 + (0.222 * count))) + centerX);//x value of coordinate 3 at radius r1 from center of Screen and angle incremented with counter
float P2Y = ((float) ((r2 + (offset * count)) * Math.sin(Math.toRadians(120 + (0.222 * count))) + centerY));//y value of coordinate 3 at varying radius from center of Screen and angle incremented with counter
PointF P2c1 = calculateTriangle(P1X, P1Y, P2X, P2Y, true);
return P2c1;
}
public PointF getP2c2(float centerX, float centerY, int dimension, double count){
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
float P1X = (float) (r1 * Math.cos(Math.toRadians(80 + (0.111 * count))) + centerX);//x value of coordinate 2 at radius r1 from center of Screen and angle incremented with counter
float P1Y = ((float) (r2 * Math.sin(Math.toRadians(80 + (0.111 * count))) + centerY));//y value of coordinate 2 at radius r2 from center of Screen and angle incremented with counter
float P2X = (float) (r1 * Math.cos(Math.toRadians(120 + (0.222 * count))) + centerX);//x value of coordinate 3 at radius r1 from center of Screen and angle incremented with counter
float P2Y = ((float) ((r2 + (offset * count)) * Math.sin(Math.toRadians(120 + (0.222 * count))) + centerY));//y value of coordinate 3 at varying radius from center of Screen and angle incremented with counter
PointF P2c2 = calculateTriangle(P1X, P1Y, P2X, P2Y, false);
return P2c2;
}
public PointF getP5c1(float centerX, float centerY, int dimension, double count){
int r1 = (int) (0.1875 * dimension);
int r2 = (int) (0.1041667 * dimension);
double offset = 0.00023125 * dimension;
// cloud coordinates from the center of the screen
float X1 = (float) (r1 * Math.cos(Math.toRadians(0 + (0.222 * count))) + centerX); //x value of coordinate 1 at radius r1 from center of Screen and angle incremented with counter
float Y1 = ((float) (r2 * Math.sin(Math.toRadians(0 + (0.222 * count))) + centerY));//y value of coordinate 1 at radius r2 from center of Screen and angle incremented with counter
float P4X = (float) (r1 * Math.cos(Math.toRadians(280 + (0.222 * count))) + centerX);//x value of coordinate 5 at radius r1 from center of Screen and angle incremented with counter
float P4Y = ((float) (r1 * Math.sin(Math.toRadians(280 + (0.222 * count))) + centerY));//y value of coordinate 5 at radius r1 from center of Screen and angle incremented with counter
PointF P5c1 = calculateTriangle(P4X, P4Y, X1, Y1, true);
return P5c1;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudFogView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by administrator on 12/09/14.
*/
public class CloudFogView extends SkyconView {
Paint paintCloud, paintFog;
boolean expanding = false;
boolean moving = true;
float ctr = 0;
float i,j;
private int screenW, screenH;
Boolean check;
private float X, Y;
private Path path1, path2;
private double count;
Cloud cloud;
boolean compress = false;
float line1Y = 0, line2Y = 0,lineStartX, lineEndX;
public CloudFogView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudFogView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
count = 0;
i=0f;
j=(int)0.5;
check = false;
if(isStatic)
{
isAnimated = false;
}
else
{
isAnimated = true;
}
paintCloud = new Paint();
paintFog = new Paint();
//Setting paint for cloud
paintCloud.setColor(strokeColor);
paintCloud.setAntiAlias(true);
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setShadowLayer(0, 0, 0, Color.BLACK);
//Setting paint for fog
paintFog.setColor(strokeColor);
paintFog.setAntiAlias(true);
paintFog.setStrokeCap(Paint.Cap.ROUND);
paintFog.setStrokeJoin(Paint.Join.ROUND);
paintFog.setStyle(Paint.Style.FILL_AND_STROKE);
paintFog.setShadowLayer(0, 0, 0, Color.BLACK);
cloud = new Cloud();
}
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(bgColor);
paintCloud.setStrokeWidth((float)(0.02083*screenW));
paintFog.setStrokeWidth((float)(0.02083*screenW));
path1 = new Path();
path2 = new Path();
count = count+0.5;
int retval = Double.compare(count, 360.00);
if(retval == 0) {
count = 0;
}
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
PointF P1c2 = cloud.getP1c2(X,Y,screenW,count);
path1 = new Path();
path2 = new Path();
if(line1Y == 0) {
line1Y = P1c2.y + (float)(0.1042 * screenW); //Calculating Y coordinate for foglines.
line2Y = P1c2.y + (float)(0.15625 * screenW);
lineStartX = (float)(X-X*50.0/100.0); //Calculating X coordinate for foglines.
lineEndX = (float) (X+X*50.0/100);
}
float temp = (lineEndX-lineStartX)*(float)95.0/(float)100; //Calculating fogline length
path1.moveTo(lineStartX, line1Y);
path1.lineTo(lineStartX + temp, line1Y);
path2.moveTo(lineEndX, line2Y);
path2.lineTo(lineEndX-temp,line2Y);
//Code to move foglines from one point to another
if(moving&&(lineStartX+temp+ctr)<=lineEndX) {
path1.reset();
path1.moveTo(lineStartX+ctr+i,line1Y);
path1.lineTo(lineStartX+ctr+temp+i,line1Y);
path2.reset();
path2.moveTo(lineEndX-ctr+i+i,line2Y);
path2.lineTo(lineEndX-ctr-temp+i-i,line2Y);
ctr = ctr+(float)0.5;
if((lineStartX+temp+ctr)>lineEndX) {
expanding = true;
moving = false;
}
}
//Code to expand foglines
if(expanding) {
if(i<=5f) {
i=i+0.1f;
path1.reset();
path1.moveTo(lineStartX+ctr+temp+i,line1Y);
path1.lineTo(lineStartX+ctr-i,line1Y);
path2.reset();
path2.moveTo(lineEndX-ctr-temp+i,line2Y);
path2.lineTo(lineEndX-ctr-i,line2Y);
} else {
//Moving the fogline to the other end after expanding
path1.reset();
path1.moveTo(lineStartX + ctr +temp + i, line1Y);
path1.lineTo(lineStartX + ctr - i , line1Y);
path2.reset();
path2.moveTo(lineEndX-ctr-temp+i,line2Y);
path2.lineTo(lineEndX-ctr-i,line2Y);
ctr = ctr - 0.2f;
if (lineStartX + ctr <= lineStartX) {
expanding = false;
compress = true;
ctr = 0.0f;
}
}
}
//Compressing the fogline to normal length
if(compress) {
if(i>0.0f) {
i = i - 0.1f;
path1.reset();
path1.moveTo(lineStartX + ctr - i, line1Y);
path1.lineTo(lineStartX + ctr + temp + i, line1Y);
path2.reset();
path2.moveTo(lineEndX-ctr-i,line2Y);
path2.lineTo(lineEndX-ctr-temp+i,line2Y);
} else {
compress = false;
moving = true;
if(isStatic)
{
isAnimated = false;
}
}
}
canvas.drawPath(path1,paintFog);
canvas.drawPath(path2,paintFog);
if(isAnimated) {
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isStatic) {
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
isAnimated = true;
invalidate();
}
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudHvRainView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* This view draws cloud with heavy rain.
*/
public class CloudHvRainView extends SkyconView {
private static Paint paintCloud, paintRain;
private int screenW, screenH;
private float X, Y;
private Path path1, path2, path3;
int m1=0, m2=0, m3=0, x1=0, y1=0, x2=0, y2=0, x3=0, y3=0;
int count1 = 0, count2 = 0, count3 = 0, i=0;
private double count;
boolean pointsStored = false;
double radius1, radius2;
Cloud cloud;
public CloudHvRainView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudHvRainView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
count = 0;
paintCloud = new Paint();
paintRain = new Paint();
//Paint for drawing cloud
paintCloud.setColor(strokeColor);
paintCloud.setStrokeWidth(10);
paintCloud.setAntiAlias(true);
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setShadowLayer(0, 0, 0, strokeColor);
//Paint for drawing rain drops
paintRain.setColor(strokeColor);
paintRain.setAntiAlias(true);
paintRain.setStrokeCap(Paint.Cap.ROUND);
paintRain.setStyle(Paint.Style.FILL_AND_STROKE);
cloud = new Cloud();
isAnimated = true;
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
radius1 = 90;
radius2 = 50;
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
path1 = new Path();// pathCloud for drop 1
path2 = new Path();// pathCloud for drop 2
path3 = new Path();// pathCloud for drop 3
count = count+0.5;
paintCloud.setStrokeWidth((float) (0.02083 * screenW));
paintRain.setStrokeWidth((float) (0.015 * screenW));
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
} else {
//resetting counter on completion of a rotation
count = 0;
}
}
PointF P1c2 = cloud.getP1c2(X,Y,screenW,count);
PointF P2c2 = cloud.getP2c2(X,Y,screenW,count);
PointF P1c1 = cloud.getP1c1(X,Y,screenW,count);
float P1Y = ((float) ((int) (0.1041667 * screenW) * Math.sin(Math.toRadians(80 + (0.111 * count))) + Y));
// Store starting x, y coordinates of rain drops
if(!pointsStored) {
x1 = (int) P1c2.x;
x2 = (int) P2c2.x;
x3 = (x1+x2)/2;
float value = (int) P1c2.y-((P1c1.y+P1Y)/2);
y1 = y2 = y3 = (int) (P1c2.y-value/2) - 20;
pointsStored = true;
}
if(isAnimated && isStatic) { //Initial static view
int m = 95;
path1.moveTo(x1, y1 + (m - 24));
path1.lineTo(x1, y1 + m + (float)(Y*0.1));
canvas.drawPath(path1, paintRain);
path2.moveTo(x2, y2 + (m - 24));
path2.lineTo(x2, y2 + m + (float)(Y*0.1));
canvas.drawPath(path2, paintRain);
path3.moveTo(x3, y3 + ((m-50) - 24));
path3.lineTo(x3, y3 + (m-50) + (float)(Y*0.1));
canvas.drawPath(path3, paintRain);
} else { // Animating view
if(i<=2*49) {
if(i<2*25) {
//drop11 logic
if (m1 < 24) {
path1.moveTo(x1, y1);
} else {
count1 = count1 + 4;
path1.moveTo(x1, y1 + count1);
}
path1.lineTo(x1, y1 + m1 + (float)(Y*0.1));
canvas.drawPath(path1, paintRain);
m1 = m1 + 4;
if (m1 == 100) {
m1 = 0;
count1 = 0;
}
//drop21 logic
if(i>2*10) {
if(m2 < 24) {
path2.moveTo(x2, y2);
} else {
count2 = count2 + 4;
path2.moveTo(x2, y2+count2);
}
path2.lineTo(x2, y2+m2+(float)(Y*0.1));
canvas.drawPath(path2, paintRain);
m2 = m2 + 4;
if(m2 == 100) {
m2 = 0;
count2 = 0;
}
}
}
if(i>=2*25 && i<=2*49) {
// drop 3
if(m3 < 24) {
path3.moveTo(x3, y3);
} else {
count3 = count3 + 4;
path3.moveTo(x3, y3+count3);
}
path3.lineTo(x3, y3+m3+(float)(Y*0.1));
canvas.drawPath(path3, paintRain);
m3 = m3 + 4;
if(m3 == 100) {
m3 = 0;
count3 = 0;
}
// drop21
if(i<2*36) {
if(m2 < 24) {
path2.moveTo(x2, y2);
} else {
count2 = count2 + 4;
path2.moveTo(x2, y2+count2);
}
path2.lineTo(x2, y2+m2+(float)(Y*0.1));
canvas.drawPath(path2, paintRain);
m2 = m2 + 4;
if(m2 == 100) {
m2 = 0;
count2 = 0;
}
}
}
}
i+=2;
if(i == 2*50) {
i = 0;
}
}
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
if(!isStatic || !isAnimated) {
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudMoonView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* This view draws cloud with Moon.
*/
public class CloudMoonView extends SkyconView {
Paint paintCloud, paintMoon;
Path pathMoon;
private int screenW, screenH;
private float X, Y, X2, Y2;
PathPoints[] pathPoints;
float m = 0;
float radius;
boolean clockwise = false;
float a=0, b=0, c=0, d=0;
private double count;
Cloud cloud;
public CloudMoonView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudMoonView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
//Paint for drawing cloud
paintCloud = new Paint();
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setAntiAlias(true);
paintCloud.setShadowLayer(0, 0, 0, strokeColor);
//Paint for drawing Moon
paintMoon = new Paint();
paintMoon.setColor(strokeColor);
paintMoon.setAntiAlias(true);
paintMoon.setStrokeCap(Paint.Cap.ROUND);
paintMoon.setStyle(Paint.Style.STROKE);
count = 0;
cloud = new Cloud();
isAnimated = true;
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
paintCloud.setStrokeWidth((float)(0.02083*screenW));
paintMoon.setStrokeWidth((float)(0.02083*screenW));
count = count+0.5;
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
} else {
//resetting counter on completion of a rotation
count = 0;
}
}
// Moon shape
pathMoon = new Path();
RectF rectF1 = new RectF();
PointF P5c1 = cloud.getP5c1(X,Y,screenW,count);
if(X2 == 0) {
X2 = P5c1.x;
Y2 = P5c1.y + (int)(0.042 * screenW);
radius = (int)(0.1042 * screenW);
}
if(!clockwise) { //Anticlockwise rotation
// First arc of the Moon.
rectF1.set(X2-radius, Y2-radius, X2+radius, Y2+radius);
pathMoon.addArc(rectF1, 65 - (m / 2), 275);
pathPoints = getPoints(pathMoon);
a = pathPoints[999].getX();
b = pathPoints[999].getY();
c = pathPoints[0].getX();
d = pathPoints[0].getY();
PointF p1 = cubic2Points(a, b, c, d, true);
PointF p2 = cubic2Points(a, b, c, d, false);
// Second arc of the Moon in opposite face.
pathMoon.moveTo(a, b);
pathMoon.cubicTo(p1.x, p1.y, p2.x, p2.y, c, d);
canvas.drawPath(pathMoon, paintMoon);
m = m + 0.5f;
if(m == 100) {
m = 0;
clockwise = !clockwise;
}
} else { //Clockwise rotation
// First arc of the Moon.
rectF1.set(X2-radius, Y2-radius, X2+radius, Y2+radius);
pathMoon.addArc(rectF1, 15 + (m / 2), 275);
pathPoints = getPoints(pathMoon);
a = pathPoints[999].getX();
b = pathPoints[999].getY();
c = pathPoints[0].getX();
d = pathPoints[0].getY();
PointF p1 = cubic2Points(a, b, c, d, true);
PointF p2 = cubic2Points(a, b, c, d, false);
// Second arc of the Moon in opposite face.
pathMoon.moveTo(a, b);
pathMoon.cubicTo(p1.x, p1.y, p2.x, p2.y, c, d);
canvas.drawPath(pathMoon, paintMoon);
m = m + 0.5f;
if(m == 100) {
m = 0;
clockwise = !clockwise;
}
}
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
if(!isStatic || !isAnimated) {
invalidate();
}
}
// Used to get cubic 2 points between staring & end coordinates.
private PointF cubic2Points(float x1, float y1, float x2,
float y2, boolean left) {
PointF result = new PointF(0,0);
// finding center point between the coordinates
float dy = y2 - y1;
float dx = x2 - x1;
// calculating angle and the distance between center and the two points
float dangle = (float) ((Math.atan2(dy, dx) - Math.PI /2f));
float sideDist = (float) - 0.5 * (float) Math.sqrt(dx * dx + dy * dy); //square
if (left){
//point from center to the left
result.x = (int) (Math.cos(dangle) * sideDist + x1);
result.y = (int) (Math.sin(dangle) * sideDist + y1);
} else {
//point from center to the right
result.x = (int) (Math.cos(dangle) * sideDist + x2);
result.y = (int) (Math.sin(dangle) * sideDist + y2);
}
return result;
}
// Used to fetch points from given path.
private PathPoints[] getPoints(Path path) {
//Size of 1000 indicates that, 1000 points
// would be extracted from the path
PathPoints[] pointArray = new PathPoints[1000];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / 1000;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < 1000)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
// Class for fetching path coordinates.
class PathPoints {
float x, y;
public PathPoints(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudRainView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* This view draws cloud with rain.
*/
public class CloudRainView extends SkyconView {
private static Paint paintCloud, paintRain;
private int screenW, screenH;
private float X, Y;
private Path pathRain;
int x1=0, y1=0, x2=0, y2=0, x3=0, y3=0;
float m = 0;
boolean drop1 = true, drop2 = false, drop3 = false;
private double count;
Cloud cloud;
public CloudRainView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudRainView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
count = 0;
paintCloud = new Paint();
paintRain = new Paint();
//Paint for drawing cloud
paintCloud.setColor(strokeColor);
paintCloud.setStrokeWidth(10);
paintCloud.setAntiAlias(true);
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setShadowLayer(0, 0, 0, strokeColor);
//Paint for drawing rain drops
paintRain.setColor(strokeColor);
paintRain.setAntiAlias(true);
paintRain.setStrokeCap(Paint.Cap.ROUND);
paintRain.setStyle(Paint.Style.FILL);
cloud = new Cloud();
isAnimated = true;
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
paintCloud.setStrokeWidth((float)(0.02083*screenW));
paintRain.setStrokeWidth((float)(0.015*screenW));
pathRain = new Path(); // pathCloud for drop
count = count+0.5;
//comparison to check 360 degrees rotation
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
} else {
//resetting counter on completion of a rotation
count = 0;
}
}
PointF P1c2 = cloud.getP1c2(X,Y,screenW,count);
PointF P1c1 = cloud.getP1c2(X,Y,screenW,count);
float P1Y = ((float) ((int) (0.1041667 * screenW) *
Math.sin(Math.toRadians(80 + (0.111 * count))) + Y));
PointF P2c2 = cloud.getP2c2(X,Y,screenW,count);
PointF P2c1 = cloud.getP2c2(X,Y,screenW,count);
float P2Y = ((float) (((int) (0.1041667 * screenW) + ((0.00023125 * screenW) * count))
* Math.sin(Math.toRadians(120 + (0.222 * count))) + Y));
if(isAnimated && isStatic) { //Initial static view
pathRain = new Path();
// 1st drop
if(x1==0) {
x1 = (int) P1c2.x;
}
if(y1==0) {
float value = (int) P1c2.y-((P1c1.y+P1Y)/2);
y1 = (int) (P1c2.y-value/2);
}
m = 95;
// Shape for rain drop
pathRain.moveTo(x1, y1);
pathRain.addArc(new RectF(x1 - 5, (y1 - 5) + m, x1 + 5, y1 + 5 + m), 180, -180);
pathRain.lineTo(x1, (y1 - 10) + m);
pathRain.close();
// 2nd drop
if(x2==0) {
x2 = (int) P2c2.x;
}
if(y2==0) {
float value = (int) P2c2.y-((P2c1.y+P2Y)/2);
y2 = (int) (P2c2.y-value/2);
}
pathRain.moveTo(x2, y2);
pathRain.addArc(new RectF(x2 - 5, (y2 - 5) + m, x2 + 5, y2 + 5 + m), 180, -180);
pathRain.lineTo(x2, (y2 - 10) + m);
pathRain.close();
// 3rd drop
if(x3==0) {
x3 = (x1+x2)/2;
}
if(y3==0) {
y3 = (y1+y2)/2;
}
pathRain.moveTo(x3, y3);
pathRain.addArc(new RectF(x3 - 5, (y3 - 5) + m/2, x3 + 5, y3 + 5 + m/2), 180, -180);
pathRain.lineTo(x3, (y3 - 10) + m/2);
pathRain.close();
} else { // Animating view
if(drop1) { // Drop 1 of the rain
pathRain = new Path();
if(x1==0) {
x1 = (int) P1c2.x;
}
if(y1==0) {
float value = (int) P1c2.y-((P1c1.y+P1Y)/2);
y1 = (int) (P1c2.y-value/2);
}
// Shape for rain drop
pathRain.moveTo(x1, y1);
pathRain.addArc(new RectF(x1 - 5, (y1 - 5) + m, x1 + 5, y1 + 5 + m), 180, -180);
pathRain.lineTo(x1, (y1 - 10) + m);
pathRain.close();
if(m==100) {
m=0;
pathRain.reset();
pathRain.moveTo(0, 0);
drop2 = true;
drop1 = false;
}
}
if(drop2) { // Drop 2 of the rain
pathRain = new Path();
if(x2==0) {
x2 = (int) P2c2.x;
}
if(y2==0) {
float value = (int) P2c2.y-((P2c1.y+P2Y)/2);
y2 = (int) (P2c2.y-value/2);
}
pathRain.moveTo(x2, y2);
pathRain.addArc(new RectF(x2 - 5, (y2 - 5) + m, x2 + 5, y2 + 5 + m), 180, -180);
pathRain.lineTo(x2, (y2 - 10) + m);
pathRain.close();
if(m==100) {
m=0;
pathRain.reset();
pathRain.moveTo(0, 0);
drop2 = false;
drop3 = true;
}
}
if(drop3) { // Drop 3 of the rain
pathRain = new Path();
if(x3==0) {
x3 = (x1+x2)/2;
}
if(y3==0) {
y3 = (y1+y2)/2;
}
pathRain.moveTo(x3, y3);
pathRain.addArc(new RectF(x3 - 5, (y3 - 5) + m, x3 + 5, y3 + 5 + m), 180, -180);
pathRain.lineTo(x3, (y3 - 10) + m);
pathRain.close();
if(m==100) {
m=0;
pathRain.reset();
pathRain.moveTo(0, 0);
// animate = false;
drop3 = false;
drop1 = true;
}
}
}
// First fill the shape with paint
paintRain.setStyle(Paint.Style.FILL);
canvas.drawPath(pathRain, paintRain);
// Then, draw the same pathCloud with paint stroke
paintRain.setStyle(Paint.Style.STROKE);
canvas.drawPath(pathRain, paintRain);
m = m+2.5f;
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
if(!isStatic || !isAnimated) {
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudSnowView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* This view draws cloud with snow.
*/
public class CloudSnowView extends SkyconView {
private Paint paintCloud, paintSnow;
PathPoints[] pathPoints11, pathPoints12, pathPoints21, pathPoints22,
pointsCircle11, pointsCircle12, pointsCircle21, pointsCircle22;
private int screenW, screenH;
private float X, Y;
private Path path11, path12, path13,
path21, path22, path23, //visible drawn paths
cubicPath11, cubicPath12,
cubicPath21, cubicPath22, //Invisible paths for drop movement
pathCircle1, pathCircle2; //Invisible paths for rotate operation
int m=0, n=0, x1=0, y1=0, x2=0, y2=0;
boolean drop11 = true, drop12 = false, drop21 = false,
drop22 = false, pointsStored = false;
private double count;
Cloud cloud;
// Initial declaration of the coordinates.
public CloudSnowView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
// Initial declaration of the coordinates.
public CloudSnowView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
count = 0;
paintCloud = new Paint();
paintSnow = new Paint();
paintCloud.setColor(strokeColor);
paintCloud.setAntiAlias(true);
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setShadowLayer(0, 0, 0, strokeColor);
paintSnow.setColor(strokeColor);
paintSnow.setAntiAlias(true);
paintSnow.setStrokeCap(Paint.Cap.ROUND);
paintSnow.setStyle(Paint.Style.STROKE);
cloud = new Cloud();
pathCircle1 = new Path();
isAnimated = true;
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
count = count+0.5;
paintCloud.setStrokeWidth((float)(0.02083*screenW));
paintSnow.setStrokeWidth((float) (0.01*screenW));
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
} else {
//resetting counter on completion of a rotation
count = 0;
}
}
PointF P1c1 = cloud.getP1c1(X,Y,screenW,count);
PointF P1c2 = cloud.getP1c2(X,Y,screenW,count);
PointF P2c1 = cloud.getP2c1(X,Y,screenW,count);
PointF P2c2 = cloud.getP2c2(X,Y,screenW,count);
float P1Y = ((float) ((int) (0.1041667 * screenW) * Math.sin(Math.toRadians(80 + (0.111 * count))) + Y));
float P2Y = ((float) (((int) (0.1041667 * screenW) + ((0.00023125 * screenW) * count))
* Math.sin(Math.toRadians(120 + (0.222 * count))) + Y));
if(x1==0) {
x1 = (int) P1c2.x + 10;
}
if(y1==0) {
float value = (int) P1c2.y-((P1c1.y+P1Y)/2);
y1 = (int) (P1c2.y-value/2);
}
if(x2==0) {
x2 = (int) P2c2.x + 10;
}
if(y2==0) {
float value = (int) P2c2.y-((P2c1.y+P2Y)/2);
y2 = (int) (P2c2.y-value/2);
}
if(!pointsStored) {
// Store path coordinates for snow fall 1
cubicPath11 = new Path();
int height = screenH - y1;
cubicPath11.moveTo(x1, y1);
cubicPath11.cubicTo(x1-screenW*0.06f, y1+height*0.3f, x1-screenW*0.12f,
y1+height*0.7f, x1-screenW*0.18f, y1+height*1.1f);
pathPoints11 = getPoints(cubicPath11);
// Store path coordinates for snow fall 2
cubicPath12 = new Path();
int x = x1-5;
cubicPath12.moveTo(x, y1);
cubicPath12.cubicTo(x+screenW*0.06f, y1+height*0.3f, x+screenW*0.1f,
y1+height*0.7f, x-screenW*0.03f, y1+height*1.1f);
pathPoints12 = getPoints(cubicPath12);
// Store path coordinates for snow fall 3
cubicPath21 = new Path();
cubicPath21.moveTo(x2, y2);
cubicPath21.cubicTo(x2+screenW*0.06f, y2+height*0.3f, x2+screenW*0.12f,
y2+height*0.7f, x2+screenW*0.18f, y2+height*1.1f);
pathPoints21 = getPoints(cubicPath21);
// Store path coordinates for snow fall 4
cubicPath22 = new Path();
int xx= x2+5;
cubicPath22.moveTo(xx, y2);
cubicPath22.cubicTo(xx-screenW*0.06f, y2+height*0.3f, xx-screenW*0.1f,
y2+height*0.6f, xx+screenW*0.03f, y2+height*1.1f);
pathPoints22 = getPoints(cubicPath22);
pointsStored = true;
}
if(isAnimated && isStatic) { //Initial static view
int x = 55;
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints12[x].getX(), pathPoints12[x].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle12 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
int a = (25+x/5) >= 100 ? 25+x/5 - 100 : 25+x/5;
int b = (8+x/5) >= 100 ? 8+x/5 - 100 : 8+x/5;
int c = (40+x/5) >= 100 ? 40+x/5 - 100 : 40+x/5;
path21.moveTo(pointsCircle12[a].getX(), pointsCircle12[a].getY());
path22.moveTo(pointsCircle12[b].getX(), pointsCircle12[b].getY());
path23.moveTo(pointsCircle12[c].getX(), pointsCircle12[c].getY());
a = (75+x/5) >= 100 ? 75+x/5 - 100 : 75+x/5;
b = (59+x/5) >= 100 ? 59+x/5 - 100 : 59+x/5;
c = (90+x/5) >= 100 ? 90+x/5 - 100 : 90+x/5;
path21.lineTo(pointsCircle12[a].getX(), (pointsCircle12[a].getY()));
path22.lineTo(pointsCircle12[b].getX(), (pointsCircle12[b].getY()));
path23.lineTo(pointsCircle12[c].getX(), (pointsCircle12[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
int y = 35;
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints22[y].getX(), pathPoints22[y].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle22 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
a = (25+y/5) >= 100 ? 25+y/5 - 100 : 25+y/5;
b = (8+y/5) >= 100 ? 8+y/5 - 100 : 8+y/5;
c = (40+y/5) >= 100 ? 40+y/5 - 100 : 40+y/5;
path21.moveTo(pointsCircle22[a].getX(), pointsCircle22[a].getY());
path22.moveTo(pointsCircle22[b].getX(), pointsCircle22[b].getY());
path23.moveTo(pointsCircle22[c].getX(), pointsCircle22[c].getY());
a = (75+y/5) >= 100 ? 75+y/5 - 100 : 75+y/5;
b = (59+y/5) >= 100 ? 59+y/5 - 100 : 59+y/5;
c = (90+y/5) >= 100 ? 90+y/5 - 100 : 90+y/5;
path21.lineTo(pointsCircle22[a].getX(), (pointsCircle22[a].getY()));
path22.lineTo(pointsCircle22[b].getX(), (pointsCircle22[b].getY()));
path23.lineTo(pointsCircle22[c].getX(), (pointsCircle22[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
} else { // Animating view
if(drop11) {
pathCircle1 = new Path();
pathCircle1.addCircle(pathPoints11[m].getX(), pathPoints11[m].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle11 = getPoints(pathCircle1);
//1st drop
path11 = new Path();
path12 = new Path();
path13 = new Path();
int a = (25+m/5) >= 100 ? 25+m/5 - 100 : 25+m/5;
int b = (8+m/5) >= 100 ? 8+m/5 - 100 : 8+m/5;
int c = (40+m/5) >= 100 ? 40+m/5 - 100 : 40+m/5;
path11.moveTo(pointsCircle11[a].getX(), pointsCircle11[a].getY());
path12.moveTo(pointsCircle11[b].getX(), pointsCircle11[b].getY());
path13.moveTo(pointsCircle11[c].getX(), pointsCircle11[c].getY());
a = (75+m/5) >= 100 ? 75+m/5 - 100 : 75+m/5;
b = (59+m/5) >= 100 ? 59+m/5 - 100 : 59+m/5;
c = (90+m/5) >= 100 ? 90+m/5 - 100 : 90+m/5;
path11.lineTo(pointsCircle11[a].getX(), (pointsCircle11[a].getY()));
path12.lineTo(pointsCircle11[b].getX(), (pointsCircle11[b].getY()));
path13.lineTo(pointsCircle11[c].getX(), (pointsCircle11[c].getY()));
canvas.drawPath(path11, paintSnow);
canvas.drawPath(path12, paintSnow);
canvas.drawPath(path13, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
m = m+1;
if(m > 75) {
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints12[n].getX(), pathPoints12[n].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle12 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
a = (25+n/5) >= 100 ? 25+n/5 - 100 : 25+n/5;
b = (8+n/5) >= 100 ? 8+n/5 - 100 : 8+n/5;
c = (40+n/5) >= 100 ? 40+n/5 - 100 : 40+n/5;
path21.moveTo(pointsCircle12[a].getX(), pointsCircle12[a].getY());
path22.moveTo(pointsCircle12[b].getX(), pointsCircle12[b].getY());
path23.moveTo(pointsCircle12[c].getX(), pointsCircle12[c].getY());
a = (75+n/5) >= 100 ? 75+n/5 - 100 : 75+n/5;
b = (59+n/5) >= 100 ? 59+n/5 - 100 : 59+n/5;
c = (90+n/5) >= 100 ? 90+n/5 - 100 : 90+n/5;
path21.lineTo(pointsCircle12[a].getX(), (pointsCircle12[a].getY()));
path22.lineTo(pointsCircle12[b].getX(), (pointsCircle12[b].getY()));
path23.lineTo(pointsCircle12[c].getX(), (pointsCircle12[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
n = n+1;
}
if(m==100) {
m=0;
path11.reset();
path11.moveTo(0, 0);
path12.reset();
path12.moveTo(0, 0);
path13.reset();
path13.moveTo(0, 0);
x1=0;
y1=0;
x2=0;
y2=0;
drop12 = true;
drop11 = false;
}
}
if(drop12) {
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints12[n].getX(), pathPoints12[n].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle12 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
int a = (25+n/5) >= 100 ? 25+n/5 - 100 : 25+n/5;
int b = (8+n/5) >= 100 ? 8+n/5 - 100 : 8+n/5;
int c = (40+n/5) >= 100 ? 40+n/5 - 100 : 40+n/5;
path21.moveTo(pointsCircle12[a].getX(), pointsCircle12[a].getY());
path22.moveTo(pointsCircle12[b].getX(), pointsCircle12[b].getY());
path23.moveTo(pointsCircle12[c].getX(), pointsCircle12[c].getY());
a = (75+n/5) >= 100 ? 75+n/5 - 100 : 75+n/5;
b = (59+n/5) >= 100 ? 59+n/5 - 100 : 59+n/5;
c = (90+n/5) >= 100 ? 90+n/5 - 100 : 90+n/5;
path21.lineTo(pointsCircle12[a].getX(), (pointsCircle12[a].getY()));
path22.lineTo(pointsCircle12[b].getX(), (pointsCircle12[b].getY()));
path23.lineTo(pointsCircle12[c].getX(), (pointsCircle12[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
n = n+1;
if(n==100) {
m=0;
n=0;
path21.reset();
path21.moveTo(0, 0);
path22.reset();
path22.moveTo(0, 0);
path23.reset();
path23.moveTo(0, 0);
x1=0;
y1=0;
drop21 = true;
drop11 = false;
drop12 = false;
}
}
if(drop21) {
pathCircle1 = new Path();
pathCircle1.addCircle(pathPoints21[m].getX(), pathPoints21[m].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle21 = getPoints(pathCircle1);
//1st drop
path11 = new Path();
path12 = new Path();
path13 = new Path();
int a = (25+m/5) >= 100 ? 25+m/5 - 100 : 25+m/5;
int b = (8+m/5) >= 100 ? 8+m/5 - 100 : 8+m/5;
int c = (40+m/5) >= 100 ? 40+m/5 - 100 : 40+m/5;
path11.moveTo(pointsCircle21[a].getX(), pointsCircle21[a].getY());
path12.moveTo(pointsCircle21[b].getX(), pointsCircle21[b].getY());
path13.moveTo(pointsCircle21[c].getX(), pointsCircle21[c].getY());
a = (75+m/5) >= 100 ? 75+m/5 - 100 : 75+m/5;
b = (59+m/5) >= 100 ? 59+m/5 - 100 : 59+m/5;
c = (90+m/5) >= 100 ? 90+m/5 - 100 : 90+m/5;
path11.lineTo(pointsCircle21[a].getX(), (pointsCircle21[a].getY()));
path12.lineTo(pointsCircle21[b].getX(), (pointsCircle21[b].getY()));
path13.lineTo(pointsCircle21[c].getX(), (pointsCircle21[c].getY()));
canvas.drawPath(path11, paintSnow);
canvas.drawPath(path12, paintSnow);
canvas.drawPath(path13, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
m = m+1;
if(m > 75) {
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints22[n].getX(), pathPoints22[n].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle22 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
a = (25+n/5) >= 100 ? 25+n/5 - 100 : 25+n/5;
b = (8+n/5) >= 100 ? 8+n/5 - 100 : 8+n/5;
c = (40+n/5) >= 100 ? 40+n/5 - 100 : 40+n/5;
path21.moveTo(pointsCircle22[a].getX(), pointsCircle22[a].getY());
path22.moveTo(pointsCircle22[b].getX(), pointsCircle22[b].getY());
path23.moveTo(pointsCircle22[c].getX(), pointsCircle22[c].getY());
a = (75+n/5) >= 100 ? 75+n/5 - 100 : 75+n/5;
b = (59+n/5) >= 100 ? 59+n/5 - 100 : 59+n/5;
c = (90+n/5) >= 100 ? 90+n/5 - 100 : 90+n/5;
path21.lineTo(pointsCircle22[a].getX(), (pointsCircle22[a].getY()));
path22.lineTo(pointsCircle22[b].getX(), (pointsCircle22[b].getY()));
path23.lineTo(pointsCircle22[c].getX(), (pointsCircle22[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
n = n+1;
}
if(m==100) {
m=0;
path11.reset();
path11.moveTo(0, 0);
path12.reset();
path12.moveTo(0, 0);
path13.reset();
path13.moveTo(0, 0);
x1=0;
y1=0;
drop22 = true;
drop21 = false;
}
}
if(drop22) {
pathCircle2 = new Path();
pathCircle2.addCircle(pathPoints22[n].getX(), pathPoints22[n].getY(),
screenW*0.03f, Path.Direction.CW);
pointsCircle22 = getPoints(pathCircle2);
//2nd drop
path21 = new Path();
path22 = new Path();
path23 = new Path();
int a = (25+n/5) >= 100 ? 25+n/5 - 100 : 25+n/5;
int b = (8+n/5) >= 100 ? 8+n/5 - 100 : 8+n/5;
int c = (40+n/5) >= 100 ? 40+n/5 - 100 : 40+n/5;
path21.moveTo(pointsCircle22[a].getX(), pointsCircle22[a].getY());
path22.moveTo(pointsCircle22[b].getX(), pointsCircle22[b].getY());
path23.moveTo(pointsCircle22[c].getX(), pointsCircle22[c].getY());
a = (75+n/5) >= 100 ? 75+n/5 - 100 : 75+n/5;
b = (59+n/5) >= 100 ? 59+n/5 - 100 : 59+n/5;
c = (90+n/5) >= 100 ? 90+n/5 - 100 : 90+n/5;
path21.lineTo(pointsCircle22[a].getX(), (pointsCircle22[a].getY()));
path22.lineTo(pointsCircle22[b].getX(), (pointsCircle22[b].getY()));
path23.lineTo(pointsCircle22[c].getX(), (pointsCircle22[c].getY()));
canvas.drawPath(path21, paintSnow);
canvas.drawPath(path22, paintSnow);
canvas.drawPath(path23, paintSnow);
// drawing cloud with fill
paintCloud.setColor(bgColor);
paintCloud.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
// drawing cloud with stroke
paintCloud.setColor(strokeColor);
paintCloud.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
n = n+1;
if(n==100) {
m=0;
n=0;
path21.reset();
path21.moveTo(0, 0);
path22.reset();
path22.moveTo(0, 0);
path23.reset();
path23.moveTo(0, 0);
x1=0;
y1=0;
drop11 = true;
drop12 = false;
drop21 = false;
drop22 = false;
}
}
}
if(!isStatic || !isAnimated) {
invalidate();
}
}
// Used to fetch points from given path.
private PathPoints[] getPoints(Path path) {
//Size of 100 indicates that, 100 points
// would be extracted from the path
PathPoints[] pointArray = new PathPoints[100];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / 100;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < 100)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
// Class for fetching path coordinates.
class PathPoints {
float x, y;
public PathPoints(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudSunView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class CloudSunView extends SkyconView {
private static Paint paint;
private int screenW, screenH;
private float X,Y,XSun,YSun;
private Path path, path1;
private double count;
int degrees;
float startAngle;
float sweepAngle;
Cloud cloud;
public CloudSunView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudSunView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
// initialize default values
degrees = 0;
count = 0;
startAngle = 45;
sweepAngle = 165;
isAnimated = true;
paint = new Paint();
paint.setColor(strokeColor);
paint.setStrokeWidth(10);
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStyle(Paint.Style.STROKE);
paint.setShadowLayer(0, 0, 0, Color.BLACK);
cloud = new Cloud();
}
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w; //getting Screen Width
screenH = h;// getting Screen Height
// center point of Screen
X = screenW/2;
Y = (screenH/2);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
// set stroke width
paint.setStrokeWidth((float) (0.02083 * screenW));
// initializing paths
path = new Path();
path1 = new Path();
// positioning Sun with respect to cloud
PointF P5c1 = cloud.getP5c1(X,Y,screenW,count);
if(XSun==0) {
// center point for Sun
XSun = P5c1.x;
YSun = P5c1.y + (int)(0.042 * screenW);
}
//incrementing counter for rotation
count = count+0.5;
//comparison to check 360 degrees rotation
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated){
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
}else {
//resetting counter on completion of a rotation
count = 0;
}
}
// drawing center circle
path.addCircle(XSun,YSun, (int)(0.083 * screenW), Path.Direction.CW);
// drawing arms of sun
for(int i=0;i<360;i+=45){
path1.moveTo(XSun,YSun);
float x1 = (float)((int)(0.1146 * screenW) * Math.cos(Math.toRadians(i+count/4))+XSun); //arm pointX at radius 50 with incrementing angle from center of sun
float y1 = (float)((int)(0.1146 * screenW) * Math.sin(Math.toRadians(i+count/4))+YSun);//arm pointY at radius 50 with incrementing angle from center of sun
float X2 = (float)((int)(0.1563 * screenW) * Math.cos(Math.toRadians(i+count/4))+XSun);//arm pointX at radius 65 with incrementing angle from center of sun
float Y2 = (float)((int)(0.1563 * screenW) * Math.sin(Math.toRadians(i+count/4))+YSun);//arm pointY at radius 65 with incrementing angle from center of sun
path1.moveTo(x1,y1); // draw arms of sun
path1.lineTo(X2,Y2);
}
// drawing sun
canvas.drawPath(path, paint);
canvas.drawPath(path1, paint);
// drawing cloud with fill
paint.setColor(bgColor);
paint.setStyle(Paint.Style.FILL);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paint);
// drawing cloud with stroke
paint.setColor(strokeColor);
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paint);
if(!isStatic || !isAnimated) {
// invalidate if not static or not animating
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudThunderView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class CloudThunderView extends SkyconView {
int ctr = 0;
int ctr2 = 0;
float thHeight;
PathPoints[] leftPoints;
Boolean check;
private Paint paintCloud,paintThunder;
private int screenW, screenH;
private float X, Y;
private Path thPath,thFillPath;
private double count;
Cloud cloud;
public CloudThunderView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudThunderView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w; //getting Screen Width
screenH = h; // getting Screen Height
// center point of Screen
X = screenW/2;
Y = (screenH/2);
}
private void init() {
count = 0;
check = false;
thHeight = 0;
thPath = new Path();
thFillPath = new Path();
if(isStatic)
{
isAnimated=false;
}
else
{
isAnimated = true;
}
paintCloud = new Paint();
paintCloud.setColor(strokeColor);
paintCloud.setStrokeWidth((screenW / 25));
paintCloud.setAntiAlias(true);
paintCloud.setStrokeCap(Paint.Cap.ROUND);
paintCloud.setStrokeJoin(Paint.Join.ROUND);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setShadowLayer(0, 0, 0, Color.BLACK);
paintThunder = new Paint();
paintThunder.setColor(strokeColor);
paintThunder.setStrokeWidth(10);
paintThunder.setAntiAlias(true);
paintThunder.setStrokeCap(Paint.Cap.ROUND);
paintThunder.setStrokeJoin(Paint.Join.ROUND);
paintThunder.setStyle(Paint.Style.STROKE);
paintThunder.setShadowLayer(0, 0, 0, Color.BLACK);
cloud = new Cloud();
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(bgColor);
paintCloud.setStrokeWidth((float) (0.02083 * screenW));
paintThunder.setStrokeWidth((float)(0.02083*screenW));
//incrementing counter for rotation
count = count+0.5;
//comparison to check 360 degrees rotation
int retval = Double.compare(count, 360.00);
if(retval == 0) {
//resetting counter on completion of a rotation
count = 0;
}
PointF P2c1 = cloud.getP2c1(X,Y,screenW,count);
//Setting up the height of thunder from the cloud
if(thHeight==0)
{
thHeight = P2c1.y;
}
float startHeight = thHeight-(thHeight*0.1f);
//Setting up X coordinates of thunder
float path2StartX = X+(X*0.04f);
//Calculating coordinates of thunder
thPath.moveTo(path2StartX, startHeight);
thPath.lineTo(X - (X * 0.1f), startHeight + (startHeight * 0.2f)); //1
thPath.lineTo(X + (X * 0.03f), startHeight + (startHeight * 0.15f));
thPath.lineTo(X - (X * 0.08f), startHeight + (startHeight * 0.3f));
leftPoints = getPoints(thPath);
if(ctr<=98) {
if(check==false) {
thFillPath.moveTo(leftPoints[ctr].getX(),leftPoints[ctr].getY());
thFillPath.lineTo(leftPoints[ctr + 1].getX(), leftPoints[ctr + 1].getY());
}
else
{
//Once filled, erasing the fill from top to bottom
thFillPath.reset();
thFillPath.moveTo(leftPoints[ctr].getX(), leftPoints[ctr].getY());
for(int i=ctr+1;i< leftPoints.length-1;i++)
{
thFillPath.lineTo(leftPoints[i].getX(), leftPoints[i].getY());
}
}
ctr = ctr+1;
}
else
{
if(isStatic) {
if (ctr2 == 2) {
isAnimated = false;
ctr2 = 0;
}
ctr2++;
}
ctr=0;
if(check==false)
{
check=true;
}
else
{
check=false;
}
}
if(!isAnimated)
{
thFillPath.reset();
thFillPath.moveTo(leftPoints[0].getX(), leftPoints[0].getY());
for(int i=ctr+1;i< leftPoints.length-1;i++)
{
thFillPath.lineTo(leftPoints[i].getX(), leftPoints[i].getY());
}
}
canvas.drawPath(thFillPath,paintThunder);
paintCloud.setStyle(Paint.Style.FILL);
paintCloud.setColor(Color.WHITE);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
paintCloud.setStyle(Paint.Style.STROKE);
paintCloud.setColor(Color.BLACK);
canvas.drawPath(cloud.getCloud(X,Y,screenW,count), paintCloud);
if(isAnimated) {
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(isStatic)
{
switch (event.getAction())
{
case MotionEvent.ACTION_UP:
isAnimated = true;
invalidate();
break;
}
}
return true;
}
private PathPoints[] getPoints(Path path) {
PathPoints[] pointArray = new PathPoints[100];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / 100;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < 100)) {
// get point from the pathMoon
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
class PathPoints {
float x, y;
public PathPoints(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/CloudView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class CloudView extends SkyconView {
private Paint paint;
private int screenW, screenH;
private float X, Y;
private double count;
Cloud c;
public CloudView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public CloudView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w; //getting Screen Width
screenH = h; // getting Screen Height
// center point of Screen
X = screenW/2;
Y = (screenH/2);
c = new Cloud();
}
private void init() {
// initialize default values
count = 0;
isAnimated = true;
paint = new Paint();
paint.setColor(strokeColor);
paint.setStrokeWidth((screenW/25));
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStyle(Paint.Style.STROKE);
paint.setShadowLayer(0, 0, 0, Color.BLACK);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
// set stroke width
paint.setStrokeWidth((float)(0.02083*screenW));
//incrementing counter for rotation
count = count+0.5;
//comparison to check 360 degrees rotation
int retval = Double.compare(count, 360.00);
if(retval == 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
} else {
//resetting counter on completion of a rotation
count = 0;
}
}
// draw cloud
canvas.drawPath(c.getCloud(X,Y,screenW,count), paint);
if(!isStatic || !isAnimated) {
// invalidate if not static or not animating
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/MoonView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* This view draws the Moon.
*/
public class MoonView extends SkyconView {
Paint paint;
Path path;
private int screenW, screenH;
private float X, Y;
PathPoints[] pathPoints;
float m = 0;
float radius;
boolean clockwise = false;
float a=0, b=0, c=0, d=0;
int count = 0; //counter for stopping animation
public MoonView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public MoonView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
//Paint for drawing Moon
paint = new Paint();
paint.setColor(strokeColor);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
isAnimated = true;
}
// Initial declaration of the coordinates.
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = screenW/2;
Y = (screenH/2);
radius = (int)(0.1458 * screenW);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
paint.setStrokeWidth((float) (0.02083 * screenW));
path = new Path();
RectF rectF1 = new RectF();
if(!clockwise) {//Anticlockwise rotation
// First arc of the Moon.
rectF1.set(X-radius, Y-radius, X+radius, Y+radius);
path.addArc(rectF1, 65-(m/2), 275);
pathPoints = getPoints(path);
a = pathPoints[999].getX();
b = pathPoints[999].getY();
c = pathPoints[0].getX();
d = pathPoints[0].getY();
PointF P1c1 = cubic2Points(a, b, c, d, true);
PointF P1c2 = cubic2Points(a, b, c, d, false);
// Second arc of the Moon in opposite face.
path.moveTo(a, b);
path.cubicTo(P1c1.x, P1c1.y, P1c2.x, P1c2.y, c, d);
canvas.drawPath(path, paint);
m = m + 0.5f;
if(m == 100) {
m = 0;
clockwise = !clockwise;
}
} else {//Clockwise rotation
// First arc of the Moon.
rectF1.set(X-radius, Y-radius, X+radius, Y+radius);
path.addArc(rectF1, 15+(m/2), 275);
pathPoints = getPoints(path);
a = pathPoints[999].getX();
b = pathPoints[999].getY();
c = pathPoints[0].getX();
d = pathPoints[0].getY();
PointF P1c1 = cubic2Points(a, b , c, d, true);
PointF P1c2 = cubic2Points(a, b, c, d, false);
// Second arc of the Moon in opposite face.
path.moveTo(a, b);
path.cubicTo(P1c1.x, P1c1.y, P1c2.x, P1c2.y, c, d);
canvas.drawPath(path, paint);
m = m + 0.5f;
if(m == 100) {
m = 0;
clockwise = !clockwise;
if(!isAnimated) {
count ++;
}
}
}
if(!isStatic || !isAnimated) {
if(count < 3) {
// invalidate if not static or not animating
invalidate();
} else {
count = 0;
}
}
}
// Used to fetch points from given path.
private PathPoints[] getPoints(Path path) {
//Size of 1000 indicates that, 1000 points
// would be extracted from the path
PathPoints[] pointArray = new PathPoints[1000];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / 1000;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < 1000)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
// Class for fetching path coordinates.
class PathPoints {
float x, y;
public PathPoints(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
private PointF cubic2Points(float x1, float y1, float x2, float y2, boolean left) {
PointF result = new PointF(0,0);
// finding center point between the coordinates
float dy = y2 - y1;
float dx = x2 - x1;
// calculating angle and the distance between center and the two points
float dangle = (float) ((Math.atan2(dy, dx) - Math.PI /2f));
float sideDist = (float) - 0.6 * (float) Math.sqrt(dx * dx + dy * dy); //square
if (left){
//point from center to the left
result.x = (int) (Math.cos(dangle) * sideDist + x1);
result.y = (int) (Math.sin(dangle) * sideDist + y1);
} else {
//point from center to the right
result.x = (int) (Math.cos(dangle) * sideDist + x2);
result.y = (int) (Math.sin(dangle) * sideDist + y2);
}
return result;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/SkyconView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
public class SkyconView extends View {
protected boolean isStatic =false;
boolean isAnimated = false;
int strokeColor = Color.parseColor("#000000");
int bgColor = Color.parseColor("#ffffff");
public SkyconView(Context context) {
super(context);
// extractAttributes(context);
}
public SkyconView(Context context, AttributeSet attrs) {
super(context, attrs);
extractAttributes(context,attrs);
}
private void extractAttributes(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.custom_view);
// get attributes from layout
isStatic = a.getBoolean(R.styleable.custom_view_isStatic, this.isStatic);
strokeColor = a.getColor(R.styleable.custom_view_strokeColor, this.strokeColor);
if(strokeColor == 0){
strokeColor = Color.BLACK;
}
bgColor = a.getColor(R.styleable.custom_view_bgColor, this.bgColor);
if(bgColor == 0) {
bgColor = Color.WHITE;
}
a.recycle();
}
public boolean isStatic() {
return isStatic;
}
public void setIsStatic(boolean isStatic) {
this.isStatic = isStatic;
}
public boolean isAnimated() {
return isAnimated;
}
public void setIsAnimated(boolean isAnimated) {
this.isAnimated = isAnimated;
}
public int getStrokeColor() {
return strokeColor;
}
public void setStrokeColor(int strokeColor) {
Log.e("strokecolor",""+strokeColor);
this.strokeColor = strokeColor;
}
public int getBgColor() {
return bgColor;
}
public void setBgColor(int bgColor) {
this.bgColor = bgColor;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/SunView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class SunView extends SkyconView {
private static Paint paint;
private int screenW, screenH;
private float X, Y;
private Path path, path1;
private double count;
public SunView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public SunView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
private void init() {
// initialize default values
count = 0;
paint = new Paint();
paint.setColor(strokeColor);
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStyle(Paint.Style.STROKE);
paint.setShadowLayer(0, 0, 0, strokeColor);
path= new Path();
isAnimated = true;
}
@Override
public void onSizeChanged (int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w; //getting Screen Width
screenH = h;// getting Screen Height
// center point of Screen
X = screenW/2;
Y = (screenH/2);
path.moveTo(X, Y);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
// initializing paths
path = new Path();
path1 = new Path();
// set stroke width
paint.setStrokeWidth((float) (0.02083 * screenW));
//incrementing counter for rotation
count = count+0.1;
//comparison to check 360 degrees rotation
int retval = Double.compare(count, 360.00);
if(retval > 0) {
if(!isAnimated) {
// mark completion of animation
isAnimated = true;
//resetting counter on completion of a rotation
count = 0;
}else {
//resetting counter on completion of a rotation
count = 0;
}
}
// drawing center circle
path.addCircle(X,Y, (int)(0.1042 * screenW), Path.Direction.CW);
// drawing arms of sun
for(int i=0;i<360;i+=45){
path1.moveTo(X,Y);
float x1 = (float)((int)(0.1458 * screenW) * Math.cos(Math.toRadians(i+count))+X); //arm pointX at radius 50 with incrementing angle from center of sun
float y1 = (float)((int)(0.1458 * screenW) * Math.sin(Math.toRadians(i+count))+Y);//arm pointY at radius 50 with incrementing angle from center of sun
float X2 = (float)((int)(0.1875 * screenW) * Math.cos(Math.toRadians(i+count))+X);//arm pointX at radius 65 with incrementing angle from center of sun
float Y2 = (float)((int)(0.1875 * screenW) * Math.sin(Math.toRadians(i+count))+Y);//arm pointY at radius 65 with incrementing angle from center of sun
path1.moveTo(x1,y1); // draw arms of sun
path1.lineTo(X2,Y2);
}
// drawing paths on canvas
canvas.drawPath(path, paint);
canvas.drawPath(path1, paint);
if(!isStatic || !isAnimated) {
// invalidate if not static or not animating
invalidate();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
// start animation if it is not animating
if(isStatic && isAnimated) {
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/java/com/thbs/skycons/library/WindView.java
================================================
package com.thbs.skycons.library;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by administrator on 18/09/14.
*/
public class WindView extends SkyconView {
private static Paint paint;
private int screenW, screenH;
private float X, Y, X2, Y2, X11, Y11, Y21, X21, Xc, Yc;
private Path tracePath, windPath, leafPath;
private double count;
int degrees;
boolean isFirstPath;
PathPoints[] points;
boolean isFirst;
public WindView(Context context,boolean isStatic,boolean isAnimated, int strokeColor , int backgroundColor) {
super(context);
this.isStatic = isStatic;
this.isAnimated = isAnimated;
this.strokeColor = strokeColor;
this.bgColor = backgroundColor;
init();
}
public WindView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
// initialize default values
isFirstPath = true;
windPath = new Path();
leafPath = new Path();
tracePath = new Path();
count = 0;
degrees = 200;
isAnimated = true;
isFirst = true;
paint = new Paint();
paint.setColor(strokeColor);
paint.setStrokeWidth(screenW/25);
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStyle(Paint.Style.STROKE);
}
@Override
public void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
screenW = w;
screenH = h;
X = 0;
Y = (float) (screenH / 1.5);
tracePath.moveTo(X, Y);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// set canvas background color
canvas.drawColor(bgColor);
// set stroke width
paint.setStrokeWidth((float)(0.02083*screenW));
//initializing the paths
windPath = new Path();
leafPath = new Path();
int retval;
//comparison to check 360 degrees rotation
retval = Double.compare(count, 310.00);
if (retval > 0) {
//resetting counter and initializing values on completion of a rotation
tracePath = new Path(); //reinitializing tracepath
count = 0; //resetting counter
degrees = 200;//resetting leaf's starting angle
isFirstPath = !isFirstPath;//resetting path flag
}
if (isFirstPath) {
int retval1 = Double.compare(count, 130.00);
if (retval1 == 0) {
if(!isAnimated) {
if(!isFirst){
// mark completion of animation
isAnimated =true;
} else{
// mark continuation of animation
isFirst = false;
isAnimated = false;
}
}
}
if(isStatic && isAnimated) {
// center position if static
count =130;
} else {
//incrementing counter for rotation
count += 1;
}
// trace for first path
X = 0;
Y = (float) (screenH / 1.5);
X2 = (float) (screenW + 50);
Y2 = (float) (screenH/4);
tracePath.moveTo(X,Y);
PointF P1c1 = calculateTriangle(X, Y, X2, Y2, true, 0.2,"CCW");
PointF P1c2 = calculateTriangle(X, Y, X2, Y2, false, 0.2,"CCW");
tracePath.cubicTo(P1c1.x, P1c1.y, P1c2.x, P1c2.y, X2, Y2);
//getting points from the trace path
points = getPoints(tracePath);
} else {
if (count < 150) {
//incrementing counter faster
count += 1.5;
} else {
//incrementing counter slower
count += 1;
}
// trace for second path
X = 0;
Y = (float) (screenH / 1.5);
X2 = (float) (screenW / 2);
Y2 = (float) (screenH / 3);
Xc = (float) (screenW + 10);
Yc = (float) (screenH / 2);
tracePath.moveTo(X - 5, Y);
tracePath.cubicTo(X + (screenW/3.2f), Y + (screenW/12), X + (screenW/2.0f), Y - (screenW/3.2f), X + (screenW/2.5f), Y - (screenW/2.8235f));
tracePath.cubicTo(X + (screenW/2.7f), Y - (screenW/2.7428f), X + (screenW/3.2f), Y - (screenW/3f), X + (screenW/3.0f), Y - (screenW/3.6923f));
tracePath.cubicTo(X + (screenW/2.6f), Y - (screenW/6), X + (screenW/1.5f), Y - (screenW/9.6f), screenW+50, Y - (screenW/2.4f));
//getting points from the trace path
points = getPoints(tracePath);
}
if (count <= 20) {
// draw nothing
} else if ((count >20)&&(count <= 60)) {
// draw initial path of length 60
for (int i = 0; i < (count - 20); i++) {
windPath.moveTo(points[i].getX(), points[i].getY());
windPath.lineTo(points[i + 1].getX(), points[i + 1].getY());
}
} else if (count >= 249) {
// draw path of decrementing length from last
for (int i = (int)count - 60 ; i <= 248; i++) {
windPath.moveTo(points[i].getX(), points[i].getY());
windPath.lineTo(points[i + 1].getX(), points[i + 1].getY());
}
} else {
// move initial path of length 60
for (int i = (int) (count - 60); i < (count - 20); i++) {
windPath.moveTo(points[i].getX(), points[i].getY());
windPath.lineTo(points[i + 1].getX(), points[i + 1].getY());
}
}
// draw windpath
canvas.drawPath(windPath, paint);
if((int) count <250 ) {
// initialize coordinates for leaf
Xc = points[(int) (count)].getX();
Yc = points[(int) (count)].getY();
X11 = (float) (((screenW * 4) / 100) * Math.cos(Math.toRadians
((degrees + count) - 30)) + Xc);
Y11 = (float) (((screenW * 4) / 100) * Math.sin(Math.toRadians((degrees + count) - 30)) + Yc);
X21 = (float) (((screenW * 12) / 100) * Math.cos(Math.toRadians((degrees + count))) + Xc);
Y21 = (float) (((screenW * 12) / 100) * Math.sin(Math.toRadians((degrees + count))) + Yc);
// getting points in between coordinates for leaf shape
PointF P11c1 = calculateTriangle(Xc, Yc, X21, Y21, true, 0.7,"CW");
PointF P11c2 = calculateTriangle(Xc, Yc, X21, Y21, false, 0.7,"CW");
PointF P21c1 = calculateTriangle(X21, Y21, X11, Y11, true, 0.8,"CW");
PointF P21c2 = calculateTriangle(X21, Y21, X11, Y11, false, 0.8,"CW");
PointF P31c1 = calculateTriangle(X11, Y11, Xc, Yc, true, 0.2,"CCW");
PointF P31c2 = calculateTriangle(X11, Y11, Xc, Yc, false, 0.2,"CCW");
// drawing arcs between coordinates
leafPath.moveTo(Xc, Yc);
leafPath.cubicTo(P11c1.x, P11c1.y, P11c2.x, P11c2.y, X21, Y21);
leafPath.cubicTo(P21c1.x, P21c1.y, P21c2.x, P21c2.y, X11, Y11);
leafPath.cubicTo(P31c1.x, P31c1.y, P31c2.x, P31c2.y, Xc, Yc);
// drawing leaf on canvas
paint.setColor(bgColor);
paint.setStyle(Paint.Style.FILL);
canvas.drawPath(leafPath, paint);
paint.setStyle(Paint.Style.STROKE);
paint.setColor(strokeColor);
canvas.drawPath(leafPath, paint);
}
if(!isStatic || !isAnimated) {
// invalidate if not static or not animating
invalidate();
}
}
private PathPoints[] getPoints(Path path) {
// getting points from path
PathPoints[] pointArray = new PathPoints[250]; // initialize array of length 250
PathMeasure pm = new PathMeasure(path, false);// measure path size
float length = pm.getLength();// get length
float distance = 0f;
float speed = length / 250;// to get 250 points
int counter = 0;
float[] aCoordinates = new float[2];
// iterate through path for points
while ((distance < length) && (counter < 250)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
class PathPoints {
// class to hold coordinates
float x, y;
public PathPoints(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
private PointF calculateTriangle(float x1, float y1, float x2, float y2, boolean left, double distOffset,String dir) {
PointF result = new PointF(0, 0);
// finding center point between the coordinates
float dy = y2 - y1;
float dx = x2 - x1;
float dangle = 0;
float sideDist = 0;
// calculating angle and the distance between center and the two points with direction
if (dir == "CW") {
dangle = (float) ((Math.atan2(dy, dx) - Math.PI / 2f));
sideDist = (float) distOffset * (float) Math.sqrt(dx * dx + dy * dy); //square
} else if (dir == "CCW") {
dangle = (float) ((Math.atan2(dy, dx) + Math.PI / 2f));
sideDist = (float) distOffset * (float) Math.sqrt(dx * dx + dy * dy); //square
}
if (left) {
//point from center to the left
result.x = (int) (Math.cos(dangle) * sideDist + x1);
result.y = (int) (Math.sin(dangle) * sideDist + y1);
} else {
//point from center to the right
result.x = (int) (Math.cos(dangle) * sideDist + x2);
result.y = (int) (Math.sin(dangle) * sideDist + y2);
}
return result;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// nothing to do
return true;
case MotionEvent.ACTION_MOVE:
// nothing to do
break ;
case MotionEvent.ACTION_UP:
if(isStatic && isAnimated) {
// start animation if it is not animating
isFirst = true;
isAnimated = false;
}
break;
default:
return false;
}
// Schedules a repaint.
if(!isAnimated) {
invalidate();
}
return true;
}
}
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/layout/activity_main.xml
================================================
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/menu/main.xml
================================================
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/values/attrs.xml
================================================
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/values/dimens.xml
================================================
16dp
16dp
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/values/strings.xml
================================================
SkyconsLibrary
Hello world!
Settings
================================================
FILE: Skycons/SkyconsLibrary/src/main/res/values-w820dp/dimens.xml
================================================
64dp
================================================
FILE: Skycons/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
================================================
FILE: Skycons/gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Aug 09 14:54:47 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
================================================
FILE: Skycons/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: Skycons/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: Skycons/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: Skycons/settings.gradle
================================================
include ':SkyconDemo', ':SkyconsLibrary'