Skip to content

Instantly share code, notes, and snippets.

Avatar
🔨
Building...

Ashish Kumar Ash-Kay

🔨
Building...
View GitHub Profile
@Ash-Kay
Ash-Kay / launch.json
Created Feb 6, 2021
VScode launch.json for Typescript
View launch.json
{
// 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",
View circleView.kt
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)
)
View customViewBasic.kt
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
}
}
View customview.kt
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 Apr 28, 2020
Spring Animation tutorial
View SpringAnimation.kt
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 Mar 25, 2019 — forked from jzayed/GlowLevels.shader
Glow Levels Shader
View GlowLevels.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)