Exemplo n.º 1
0
        public override void Preroll(PrerollContext context, SKMatrix matrix)
        {
            SKRect child_paint_bounds = SKRect.Empty;

            PrerollChildren(context, matrix, ref child_paint_bounds);

            if (child_paint_bounds.IntersectsWith(clip_path_.Bounds))
            {
                set_paint_bounds(child_paint_bounds);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draw the ink strokes that are within the bounds
        /// </summary>
        /// <param name="canvas">the SkiaSharp canvas</param>
        /// <param name="strokes">the candidate strokes</param>
        /// <param name="bounds">the bounds to draw in</param>
        public static void Draw(this SKCanvas canvas, IEnumerable <XInkStroke> strokes, SKRect bounds)
        {
            if (strokes == null)
            {
                return;
            }

            foreach (var stroke in strokes)
            {
                if (!bounds.IntersectsWith(stroke.BoundingRect.ToSKRect()))
                {
                    continue;
                }

                canvas.Draw(stroke, true);
            }
        }
Exemplo n.º 3
0
        private void DrawLed(SKBitmap grphxDrawerTarget)
        {
            if (m_Body.ImagePoints != null && m_Body.ImagePoints.Length > 0 && CheckIfLedIsVissible(grphxDrawerTarget))
            {
                PointF LedPos  = m_Body.ImagePoints[LedPointIndex].point;
                SizeF  LedSize = m_Body.LedSize;

                Point  leftUp   = new Point((int)(LedPos.X - LedSize.Width / 2), (int)(LedPos.Y - LedSize.Height / 2));
                SKRect destRect = new SKRect(leftUp.X, leftUp.Y, leftUp.X + LedSize.Width, leftUp.Y + LedSize.Height);

                using (SKCanvas skcanvas = new SKCanvas(grphxDrawerTarget))
                {
                    if (destRect.IntersectsWith(skcanvas.DeviceClipBounds) && destRect.Width < skcanvas.DeviceClipBounds.Width && destRect.Height < skcanvas.DeviceClipBounds.Height)
                    {
                        skcanvas.DrawImage(skledImage, destRect);
                    }
                }
            }
        }
 private void OnCanvasTouch(object sender, View.TouchEventArgs e)
 {
     if (e.Event.Action == MotionEventActions.Down)
     {
         if (scoreButton.IntersectsWith(new SKRect(e.Event.GetX() - 5, e.Event.GetY() - 5, e.Event.GetX() + 5, e.Event.GetY() + 5)))
         {
             Intent scoreActivityIntent = new Intent(this, typeof(ScoreActivity));
             scoreActivityIntent.SetFlags(ActivityFlags.SingleTop);
             StartActivity(scoreActivityIntent);
         }
         else
         {
             Intent gameActivityIntent = new Intent(this, typeof(GameActivity));
             gameActivityIntent.SetFlags(ActivityFlags.SingleTop);
             gameActivityIntent.SetFlags(ActivityFlags.ClearTop);
             StartActivity(gameActivityIntent, ActivityOptions.MakeSceneTransitionAnimation(this).ToBundle());
         }
     }
 }
Exemplo n.º 5
0
        private int zoomGesture = 0;                     //questa variabile può avere 3 stati [ 0 se non sto zommando ], [ 1 se ho finito di zoomare*], [ 2 se non sto zoommando]
        //se ho finito di zoomare devo anche completare lo stato di movimento con variabili nulle cosi da resettare tutto

        private void canvasView_Touch(object sender, SKTouchEventArgs e)
        {
            SKRect touchRect = SKRect.Create(e.Location.X, e.Location.Y, 1, 1);

            //listener pianeti
            if (e.ActionType == SKTouchAction.Pressed && openPopUp == false && !touchRect.IntersectsWith(joyStick.GetRect()) &&
                !touchRect.IntersectsWith(switchJoyStick.GetRect()) && !noPinCam.IsVisible)
            {
                for (int i = 0; i < pl.Count; i++)                            //che pianeta ho cliccato??
                {
                    if (touchRect.IntersectsWith(pl[i].hitBox(getPlanetPoint(pl[i]).X, getPlanetPoint(pl[i]).Y, pl[i].Size, scale)))
                    {
                        sunPointer.IsVisible = false;
                        timeWasMoving        = timeIsMoving;
                        timeIsMoving         = false;
                        oldScale             = scale;
                        clickedPlanet        = true;
                        iPlanet = i;
                    }
                }
            }

            //funzioni bottoni personalizzati
            if (!openPopUp)
            {
                //clicco il pulsante per mostrare il joystick
                if (touchRect.IntersectsWith(switchJoyStick.GetRect()))
                {
                    joyStickVisible = !joyStickVisible;
                    switchJoyStick.changeStateOn();
                }

                //clicco il joystick
                if (e.ActionType == SKTouchAction.Pressed && joyStickVisible)
                {
                    if (touchRect.IntersectsWith(joyStick.getTop()))                              //tasto sopra
                    {
                        top       = true;
                        e.Handled = true;
                    }
                    if (touchRect.IntersectsWith(joyStick.getDown()))                               //sotto
                    {
                        down      = true;
                        e.Handled = true;
                    }
                    if (touchRect.IntersectsWith(joyStick.getRight()))                             //destra
                    {
                        right     = true;
                        e.Handled = true;
                    }
                    if (touchRect.IntersectsWith(joyStick.getleft()))                            //sinsitra
                    {
                        left      = true;
                        e.Handled = true;
                    }
                }
            }

            //aperto il popup se clicco fuori da essi esco dalla modalità
            if (openPopUp && touchRect.IntersectsWith(phoneRect))                         //non prende il tocco se clicco un elemento xaml
            {
                resetViewAfterPopUp();
                sunPointer.IsVisible = true;
            }

            //rilascio la pressione su un tasto del joystick
            if (e.ActionType == SKTouchAction.Released)
            {
                top       = false;
                right     = false;
                down      = false;
                left      = false;
                e.Handled = false;
            }
        }