This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: | |
// Title: | |
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform vec2 u_resolution; | |
bool insideTriangle(vec2 uv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.ObjectAnimator; | |
import android.animation.TypeConverter; | |
import android.animation.ValueAnimator; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.ViewPropertyAnimator; | |
import android.view.animation.TranslateAnimation; | |
import android.widget.Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.ValueAnimator; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Path; | |
import android.support.annotation.Nullable; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.animation.Interpolator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MajorityElement { | |
public static void main(String[] args) { | |
System.out.println(findMajority(new int[]{3, 4, 5, 3, 5, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5})); | |
} | |
public static int findMajority(int[] array) { | |
int candidate = findCandidate(array); | |
return validate(array, candidate) ? candidate : -1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shape.create { | |
shape { ShapeType.RECTANGLE } | |
height { 0.1f } | |
width { 0.1f } | |
bitmap { BitmapFactory.decodeResource(context.resources, R.drawable.image) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class ShapeType { | |
CIRCLE, RECTANGLE, TRIANGLE, NONE | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shape.create { | |
shape { ShapeType.RECTANGLE } | |
height { 0.4f } | |
width { 0.4f } | |
bitmap { BitmapFactory.decodeResource(context.resources, R.drawable.circle_2) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shape.create { | |
shape { ShapeType.TRIANGLE } | |
height { 0.1f } | |
width { 0.1f } | |
color { R.color.colorAccent.rgba(context) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Int.rgba(context: Context) = ContextCompat.getColor(context, this).rgba() | |
fun Int.rgba(): Vec4 = Vec4( | |
Color.red(this).toFloat() / 256f, | |
Color.green(this).toFloat() / 256f, | |
Color.blue(this).toFloat() / 256f, | |
Color.alpha(this).toFloat() / 256f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SinInterpolator: Interpolator { | |
override fun getInterpolation(input: Float) = Math.sin(input.toDouble()).toFloat() | |
} |
NewerOlder