Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Chet Haase & Romain Guy: U and I

Realm
July 28, 2016

Chet Haase & Romain Guy: U and I

Presented at 360|AnDev 2016

Realm

July 28, 2016
Tweet

More Decks by Realm

Other Decks in Programming

Transcript

  1. Arc - Example LayoutParams params = (LayoutParams) arcMotionButton.getLayoutParams();
 if (mTopLeft)

    {
 params.rightToRight = R.id.parentContainer;
 params.bottomToBottom = R.id.parentContainer;
 params.leftToLeft = -1;
 params.topToBottom = -1;
 } else {
 params.leftToLeft = R.id.parentContainer;
 params.topToBottom = R.id.trajectoryGroup;
 params.rightToRight = -1;
 params.bottomToBottom = -1;
 }
 arcMotionButton.setLayoutParams(params);
 mTopLeft = !mTopLeft; Step 1: Get the current position final float oldX = arcMotionButton.getX();
 final float oldY = arcMotionButton.getY(); Step 2: Reposition views
  2. Arc - Example Step 3: Wait for layout final ViewTreeObserver

    observer = arcMotionButton.getViewTreeObserver();
 observer.addOnPreDrawListener(
 new ViewTreeObserver.OnPreDrawListener() {
 @Override
 public boolean onPreDraw() {
 observer.removeOnPreDrawListener(this); 
 // ...
 return true;
 }
 }
 ); final ViewTreeObserver observer = arcMotionButton.getViewTreeObserver();
 observer.addOnPreDrawListener(
 new ViewTreeObserver.OnPreDrawListener() {
 @Override
 public boolean onPreDraw() {
 observer.removeOnPreDrawListener(this);
 float deltaX = arcMotionButton.getX() - oldX;
 float deltaY = arcMotionButton.getY() - oldY;
 PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("translationX", -deltaX, 0);
 PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("translationY", -deltaY, 0);
 ObjectAnimator.ofPropertyValuesHolder(arcMotionButton,
 pvhX, pvhY).start();
 return true;
 }
 }
 );
 Step 3a: Animate from old to new location final ViewTreeObserver observer = arcMotionButton.getViewTreeObserver();
 observer.addOnPreDrawListener(
 new ViewTreeObserver.OnPreDrawListener() {
 @Override
 public boolean onPreDraw() {
 observer.removeOnPreDrawListener(this);
 Path path = new Path();
 path.moveTo(-deltaX, -deltaY);
 path.quadTo(-deltaX, 0, 0, 0);
 ObjectAnimator.ofFloat(arcMotionButton, "translationX", "translationY", path).start();
 return true;
 }
 }
 ); Step 3b: Make it curved!
  3. Arc - Better Example LayoutParams params = (LayoutParams) arcMotionButton.getLayoutParams();
 if

    (mTopLeft) {
 params.rightToRight = R.id.parentContainer;
 params.bottomToBottom = R.id.parentContainer;
 params.leftToLeft = -1;
 params.topToBottom = -1;
 } else {
 params.leftToLeft = R.id.parentContainer;
 params.topToBottom = R.id.trajectoryGroup;
 params.rightToRight = -1;
 params.bottomToBottom = -1;
 }
 arcMotionButton.setLayoutParams(params);
 mTopLeft = !mTopLeft; Step 1: Reposition views Step 2: Run a transition TransitionManager.beginDelayedTransition(parentContainer); ChangeBounds arcTransition = new ChangeBounds();
 arcTransition.setPathMotion(new ArcMotion());
 TransitionManager.beginDelayedTransition(parentContainer, arcTransition); Step 2: Make it curved!
  4. Other Cartoon Animation Rules Antici Straight ahead and pose-to-pose Follow-through

    and pation Squash & Stretch Exagggggggggggggggggggggggggggggggggggggggeration overlap Appeal
  5. Our visual system follows Steven’s power law The eye’s response

    is non-linear Gamma! Subjective magnitude of sensation Magnitude of stimulus
  6. The response curve of an LCD is not a gamma

    curve It is made to look like a gamma curve with hardware processing
  7. Linear Gamma Input quantized over 5 bits for visualization 50%

    of the precision allocated to the darkest 50% intensities 70% of the precision allocated to the darkest 50% intensities 11~12 bits needed 8 bits are sufficient
  8. Gamma encoding is not necessary with high precision, linear formats

    Examples: OpenEXR, PNG 16 bit, Photoshop 16 & 32 bit, RAW files
  9. // Gamma encoded colors
 int color1 = getColor1();
 int color2

    = getColor2();
 
 // Extract red and convert to linear
 float r1 = ((color2 >> 16) & 0xff) / 255.0f;
 r1 = (float) Math.pow(r1, 2.2); float r2 = // …
 
 // Do the math and gamma-encode
 float r = r1 * 0.5f + r2 * 0.5f;
 r = (float) Math.pow(r, 1.0 / 2.2);
  10. // Do not gamma-decode alpha // Alpha is *linear*! //

    Make sure the Gray profile // is set to “sGray” in // Photoshop’s color settings
  11. // OpenGL has extensions and APIs // for sRGB encoding/decoding

    and // correct, linear blending // Use them, it’s free
  12. Blurs & resizes → darker image Animations → brightness shifts

    3D lighting → hue shifts This issue affects everything
  13. What is a color? For users, it’s a visual perception

    that can be described by hue, brightness and colorfulness For developers, it’s a tuple of numbers, in a color model associated with a color space RGB(0.92,0.91,0.86) CMYK(0.5,0.3,0.6,0)
  14. It has 3 primaries It has a white point It

    has conversion functions What is a color space?
  15. float OECF_sRGB(float linear) {
 float low = linear * 12.92f;


    float high = (pow(linear, 1.0f / 2.4f) * 1.055f) - 0.055f;
 return linear <= 0.0031308f ? low : high;
 }
  16. HDTV, Rec.709 →Same primaries & white point as sRGB →Different

    OECF/EOCF, ≈gamma 2.4 UHDTV, Rec.2020 →Similar OECF/EOCF to Rec.709 Android TV