private float computeMaximum(float[] offsets) { float max = (1.0F / -1.0F); foreach (var o in offsets) { max = Math.Max(o, max); } return(max); }
protected override void onPullImpl(float scaleOfLayout) { float angle; if (mRotateDrawableWhilePulling) { angle = scaleOfLayout * 90f; } else { angle = Math.Max(0f, Math.Min(180f, scaleOfLayout * 360f - 180f)); } mHeaderImageMatrix.SetRotate(angle, mRotationPivotX, mRotationPivotY); mHeaderImage.ImageMatrix = mHeaderImageMatrix; }
public override void OnChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, bool isCurrentlyActive) { var measuredsize = GetMeasuredSize(GetContainerArea(dX), viewHolder); if (measuredsize.width <= 0 || measuredsize.height <= 0) { return; } var clippedX = dX >= 0 ? Math.Min(dX, measuredsize.width) : Math.Max(dX, -measuredsize.width); if (actionState == ItemTouchHelper.ActionStateSwipe) { if (_currentSwipeState != SwipeState.Default) { if (_currentSwipeState == SwipeState.LeftOpen) { clippedX = Math.Max(clippedX, measuredsize.width); } if (_currentSwipeState == SwipeState.RightOpen) { clippedX = Math.Min(clippedX, -measuredsize.width); } base.OnChildDraw(c, recyclerView, viewHolder, clippedX, dY, actionState, isCurrentlyActive); } else { SetTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } } if (_currentSwipeState == SwipeState.Default) { base.OnChildDraw(c, recyclerView, viewHolder, clippedX, dY, actionState, isCurrentlyActive); } DrawButtons(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive, _currentSwipeState, false); }
// Expand the FAB so that it takes up the whole screen. // The argument viewContentToDisplay will be displayed as content. // The view is automatically hidden when the user clicks back. public void ExpandFabToOverlayView(View viewContentToDisplay) { Activity.Window.AddFlags(WindowManagerFlags.Fullscreen); var fabOverlayView = Activity.FindViewById <ViewGroup>(Resource.Id.fab_overlay_content); fabOverlayView.RemoveAllViews(); fabOverlayView.SetBackgroundColor(Activity.Fab.FabColor); fabOverlayView.Visibility = ViewStates.Visible; fabOverlayView.AddView(viewContentToDisplay); var cx = (Activity.Fab.Left + Activity.Fab.Right) / 2; var cy = (Activity.Fab.Top + Activity.Fab.Bottom) / 2; var finalRadius = Math.Max(fabOverlayView.Width, fabOverlayView.Height) * 1.5; var anim = XamarinViewAnimationUtils.CreateCircularReveal(fabOverlayView, cx, cy, 0, (float)finalRadius); anim.SetInterpolator(new AccelerateDecelerateInterpolator()); anim.SetDuration(750); anim.Start(); }
public void onProjectionChanged(HeadMountedDisplay hmd, EyeParams leftEye, EyeParams rightEye, float zNear, float zFar) { mHmd = new HeadMountedDisplay(hmd); mLeftEyeFov = new FieldOfView(leftEye.getFov()); mRightEyeFov = new FieldOfView(rightEye.getFov()); ScreenParams screen = mHmd.getScreen(); CardboardDeviceParams cdp = mHmd.getCardboard(); if (mProgramHolder == null) { mProgramHolder = createProgramHolder(); } EyeViewport leftEyeViewport = initViewportForEye(leftEye, 0.0F); EyeViewport rightEyeViewport = initViewportForEye(rightEye, leftEyeViewport.width); leftEye.getFov().toPerspectiveMatrix(zNear, zFar, leftEye.getTransform().GetPerspective(), 0); rightEye.getFov().toPerspectiveMatrix(zNear, zFar, rightEye.getTransform().GetPerspective(), 0); float textureWidthM = leftEyeViewport.width + rightEyeViewport.width; float textureHeightM = Math.Max(leftEyeViewport.height, rightEyeViewport.height); float xPxPerM = screen.getWidth() / screen.getWidthMeters(); float yPxPerM = screen.getHeight() / screen.getHeightMeters(); int textureWidthPx = Math.Round(textureWidthM * xPxPerM); int textureHeightPx = Math.Round(textureHeightM * yPxPerM); float xEyeOffsetMScreen = screen.getWidthMeters() / 2.0F - cdp.getInterpupillaryDistance() / 2.0F; float yEyeOffsetMScreen = cdp.getVerticalDistanceToLensCenter() - screen.getBorderSizeMeters(); mLeftEyeDistortionMesh = createDistortionMesh(leftEye, leftEyeViewport, textureWidthM, textureHeightM, xEyeOffsetMScreen, yEyeOffsetMScreen); xEyeOffsetMScreen = screen.getWidthMeters() - xEyeOffsetMScreen; mRightEyeDistortionMesh = createDistortionMesh(rightEye, rightEyeViewport, textureWidthM, textureHeightM, xEyeOffsetMScreen, yEyeOffsetMScreen); setupRenderTextureAndRenderbuffer(textureWidthPx, textureHeightPx); }
private static float clamp(float val, float min, float max) { return(Math.Max(min, Math.Min(max, val))); }