Skip to content

Instantly share code, notes, and snippets.

View Ash-Kay's full-sized avatar
🔨
Building...

Ashish Kumar Ash-Kay

🔨
Building...
View GitHub Profile
@Ash-Kay
Ash-Kay / launch.json
Created February 6, 2021 14:36
VScode launch.json for Typescript
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug index.ts",
"type": "node",
override fun onTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_UP -> {
val touchPoint = PointF(event.x, event.y)
//Distance between two points
val distance = sqrt(
(centre.x - touchPoint.x).pow(2)
+ (centre.y - touchPoint.y).pow(2)
)
class KotlinView : View {
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
}
override fun onDraw(canvas: Canvas?) {
//Draw things here
}
}
public class CircleView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
override fun onDraw(canvas: Canvas?) {
//Draw things here
}
}
@Ash-Kay
Ash-Kay / SpringAnimation.kt
Last active April 28, 2020 11:59
Spring Animation tutorial
val stiffness = 5f
val animCircleX: SpringAnimation = SpringAnimation(circle_btn,DynamicAnimation.TRANSLATION_X)
.apply {
spring = SpringForce().setDampingRatio(SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY)
.setStiffness(stiffness)
}
animCircleX.cancel() // cancel old animation to play new animation
animCircleX.spring.finalPosition = touchPoint.x - Constants.circleSize //set final postion as touchPosition
animCircleX.start() //start new animation
@Ash-Kay
Ash-Kay / GlowLevels.shader
Created March 25, 2019 06:13 — forked from jzayed/GlowLevels.shader
Glow Levels Shader
Shader "Sprites/GlowLevels"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_AlphaIntensity_Fade_1("_AlphaIntensity_Fade_1", Range(0, 3)) = 1
_TintRGBA_Color_1("_TintRGBA_Color_1", COLOR) = (1,1,1,1)
_AlphaIntensity_Fade_2("_AlphaIntensity_Fade_2", Range(0, 3)) = 1
_TintRGBA_Color_2("_TintRGBA_Color_2", COLOR) = (1,1,1,1)