Skip to content

Instantly share code, notes, and snippets.

View igalata's full-sized avatar
🎯
Focusing

Irina Galata igalata

🎯
Focusing
View GitHub Profile
// Author:
// Title:
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
bool insideTriangle(vec2 uv) {
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;
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;
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;
}
Shape.create {
shape { ShapeType.RECTANGLE }
height { 0.1f }
width { 0.1f }
bitmap { BitmapFactory.decodeResource(context.resources, R.drawable.image) }
}
enum class ShapeType {
CIRCLE, RECTANGLE, TRIANGLE, NONE
}
Shape.create {
shape { ShapeType.RECTANGLE }
height { 0.4f }
width { 0.4f }
bitmap { BitmapFactory.decodeResource(context.resources, R.drawable.circle_2) }
}
Shape.create {
shape { ShapeType.TRIANGLE }
height { 0.1f }
width { 0.1f }
color { R.color.colorAccent.rgba(context) }
}
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)
class SinInterpolator: Interpolator {
override fun getInterpolation(input: Float) = Math.sin(input.toDouble()).toFloat()
}