/// <summary> /// Navigate center of viewport to center of extent and change resolution /// </summary> /// <param name="extent">New extent for viewport to show</param> /// <param name="scaleMethod">Scale method to use to determine resolution</param> /// <param name="duration">Duration of animation in millisecondsScale method to use to determine resolution</param> public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit, long duration = 300) { if (extent == null) { return; } var resolution = ZoomHelper.DetermineResolution( extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod); NavigateTo(extent.Centroid, resolution, duration); }
public override void OnStateEnter() { mull.treeDistance = 2f; ZoomHelper.setUIVisibility(infoBox, false); ZoomHelper.setUIVisibility(backButton, false); camera.transform.rotation = camera.getLastRotation(); hiker.transform.rotation = hiker.GetComponent <OnHoverHiker> ().initialRotation; }
public void CalculateMatrix_StretchMode_UniformToFill() { var panelBounds = new Rect(0, 0, 300, 200); var elementBounds = new Rect(0, 0, 100, 100); var target = ZoomHelper.CalculateMatrix(panelBounds.Width, panelBounds.Height, elementBounds.Width, elementBounds.Height, StretchMode.UniformToFill); Assert.Equal(3.0, target.M11); Assert.Equal(0.0, target.M12); Assert.Equal(0.0, target.M21); Assert.Equal(3.0, target.M22); Assert.Equal(-100.0, target.M31); Assert.Equal(-100.0, target.M32); }
public override void OnStateEnter() { AudioSource correctGuessSound = guessSounds[0]; AudioSource incorrectGuessSound = guessSounds[1]; guessColour.guessedColour(); answerColour.correctColour(); if (isGaelic) { infoContainer.answerText.text = "An Fhreagairt Cheart: " + answer.headname; infoContainer.guessText.text = "Do Fhreagairt: " + guess.GetComponent <SettlementInformation> ().headname; moveOn.text = "Air aghaidh"; } else { infoContainer.answerText.text = "The correct answer: " + answer.headname; infoContainer.guessText.text = "Your answer: " + guess.GetComponent <SettlementInformation> ().headname; moveOn.text = "Continue"; } if (qc.isCorrect()) { if (isGaelic) { infoContainer.answerStatus.text = "Ceart!"; } else { infoContainer.answerStatus.text = "Correct!"; } infoContainer.answerStatus.color = Color.green; correctGuessSound.Play(); } else { if (isGaelic) { infoContainer.answerStatus.text = "Ceàrr!"; } else { infoContainer.answerStatus.text = "Wrong!"; } infoContainer.answerStatus.color = new Color32(255, 53, 53, 255); incorrectGuessSound.Play(); } ZoomHelper.setUIVisibility(answerGroup, true); }
public void ZoomToBbox(Point min, Point max) { double x, y, resolution; ZoomHelper.ZoomToBoudingbox(min.X, min.Y, max.X, max.Y, this.ActualWidth, out x, out y, out resolution); resolution = ZoomHelper.ClipToExtremes(rootLayer.Schema.Resolutions, resolution); this.Transform.Center = new Point(x, y); this.Transform.Resolution = resolution; this.toResolution = resolution; this.Refresh(); ClearBBoxDrawing(); }
private void OnChangeZoom() { //Example of scaling object //int zoom = OnlineMaps.instance.zoom; //float s = 10f / (2 << (zoom - 5)); float originalScale = 1 << defaultZoom; float currentScale = 1 << OnlineMaps.instance.zoom; ZoomHelper helper = dynamicMarker.instance.GetComponent <ZoomHelper>(); helper.SetGizmoRange(currentScale / originalScale); }
public void ZoomIn() { if (ZoomLocked) { return; } if (double.IsNaN(toResolution)) { toResolution = viewport.Resolution; } toResolution = ZoomHelper.ZoomIn(map.Resolutions, toResolution); ZoomMiddle(); }
public void ZoomOut() { if (ZoomLocked) { return; } if (!viewInitialized) { return; } viewport.Resolution = ZoomHelper.ZoomOut(map.Resolutions, viewport.Resolution); OnViewChanged(false); }
public void ZoomIn() { if (ZoomLocked) { return; } if (double.IsNaN(_toResolution)) { _toResolution = Map.Viewport.Resolution; } _toResolution = ZoomHelper.ZoomIn(_map.Resolutions, _toResolution); ZoomMiddle(); }
void MapControlMouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta > 0) { _viewport.UnitsPerPixel = ZoomHelper.ZoomIn(_tileSource.Schema.Resolutions.Select(r => r.Value.UnitsPerPixel).ToList(), _viewport.UnitsPerPixel); } else if (e.Delta < 0) { _viewport.UnitsPerPixel = ZoomHelper.ZoomOut(_tileSource.Schema.Resolutions.Select(r => r.Value.UnitsPerPixel).ToList(), _viewport.UnitsPerPixel); } _fetcher.ViewChanged(_viewport.Extent, _viewport.UnitsPerPixel); e.Handled = true; //so that the scroll event is not sent to the html page. _invalid = true; }
/// <summary> /// Navigate center of viewport to center of extent and change resolution /// </summary> /// <param name="extent">New extent for viewport to show</param> /// <param name="scaleMethod">Scale method to use to determine resolution</param> public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit) { if (extent == null) { return; } var resolution = ZoomHelper.DetermineResolution( extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod); _viewport.SetResolution(resolution); _viewport.SetCenter(extent.Centroid); Navigated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Navigate center of viewport to center of extent and change resolution /// </summary> /// <param name="extent">New extent for viewport to show</param> /// <param name="scaleMethod">Scale method to use to determin resolution</param> public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit) { if (extent == null) { return; } var resolution = ZoomHelper.DetermineResolution( extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod); _viewport.SetResolution(resolution); _viewport.SetCenter(extent.Centroid); _map.RefreshData(_viewport.Extent, _viewport.Resolution, true); }
private IObservable <T> Search(IEnvelop envelope, int zoomLevel) { var minMargin = ZoomHelper.GetMinMargin(zoomLevel); return(Observable.Create <T>(observer => { var node = Root; if (!envelope.Intersects(node.Envelope)) { observer.OnCompleted(); return Disposable.Empty; } var nodesToSearch = new Stack <RTreeNode>(); while (node != null && node.Envelope != null) { if (node.Children != null) { foreach (var child in node.Children) { var childEnvelope = child.Envelope; if (envelope.Intersects(childEnvelope)) { if (node.IsLeaf && childEnvelope.Margin >= minMargin) { observer.OnNext(child.Data); } else if (envelope.Contains(childEnvelope)) { Collect(child, minMargin, observer); } else { nodesToSearch.Push(child); } } } } node = nodesToSearch.TryPop(); } observer.OnCompleted(); return Disposable.Empty; })); }
public override void OnStateEnter() { questionController.setCurrentQuestion(); if (isGaelic) { questionText.text = questionController.getCurrentQuestion().text_gaelic; answersLeft.text = "" + questionController.questionsLeftToAnswer() + " freagairtean ceart air fhàgail"; } else { questionText.text = questionController.getCurrentQuestion().text_english; answersLeft.text = "" + questionController.questionsLeftToAnswer() + " correct answers remaining!"; } camera.transform.position = camera.getBasePosition(); ZoomHelper.setUIVisibility(questionGroup, true); ZoomHelper.setUIVisibility(answersLeftGroup, true); ZoomHelper.setUIVisibility(player, false); }
public void ZoomIn(PointF mapPosition) { // When zooming in we want the mouse position to stay above the same world coordinate. // We do that in 3 steps. // 1) Temporarily center on where the mouse is Map.Viewport.Center = Map.Viewport.ScreenToWorld(mapPosition.X, mapPosition.Y); // 2) Then zoom Map.Viewport.Resolution = ZoomHelper.ZoomIn(_map.Resolutions, Map.Viewport.Resolution); // 3) Then move the temporary center back to the mouse position Map.Viewport.Center = Map.Viewport.ScreenToWorld( Map.Viewport.Width - mapPosition.X, Map.Viewport.Height - mapPosition.Y); ViewChanged(true); Invalidate(); }
private void LoadModel(Tile tile, Model model, Func <Rule, IModelBuilder, IGameObject> func) { var zoomLevel = ZoomHelper.GetZoomLevel(tile.RenderMode); var rule = _stylesheet.GetModelRule(model, zoomLevel); if (rule.IsApplicable && ShouldUseBuilder(tile, rule, model)) { try { foreach (var modelBuilder in rule.GetModelBuilders(_customizationService)) { var gameObject = func(rule, modelBuilder); AttachBehaviours(gameObject, rule, model); } } catch (Exception ex) { Trace.Error(LogCategory, ex, Strings.UnableToLoadModel, model.ToString()); } } }
/// <inheritdoc /> public IObservable <Unit> Load(Tile tile) { var boundingBox = tile.BoundingBox; var zoomLevel = ZoomHelper.GetZoomLevel(tile.RenderMode); var filterElementVisitor = new CompositeElementVisitor( new NodeVisitor(tile, _modelLoader, _objectPool), new WayVisitor(tile, _modelLoader, _objectPool), new RelationVisitor(tile, _modelLoader, _objectPool)); _elevationProvider.SetNullPoint(tile.RelativeNullPoint); // download elevation data if necessary if (!_elevationProvider.HasElevation(tile.BoundingBox)) { _elevationProvider.Download(tile.BoundingBox).Wait(); } // prepare tile tile.Accept(tile, _modelLoader); var subject = new Subject <Unit>(); _elementSourceProvider .Get(tile.BoundingBox) .SelectMany(e => e.Get(boundingBox, zoomLevel)) .ObserveOn(Scheduler.ThreadPool) .SubscribeOn(Scheduler.ThreadPool) .Subscribe(element => element.Accept(filterElementVisitor), () => { tile.Canvas.Accept(tile, _modelLoader); subject.OnCompleted(); }); return(subject); }
private void MapControlMouseWheel(object sender, MouseWheelEventArgs e) { if (!_viewportInitialized) { return; } if (ZoomLocked) { return; } _currentMousePosition = e.GetPosition(this); //Needed for both MouseMove and MouseWheel event for mousewheel event if (double.IsNaN(_toResolution)) { _toResolution = Map.Viewport.Resolution; } if (e.Delta > Constants.Epsilon) { _toResolution = ZoomHelper.ZoomIn(_map.Resolutions, _toResolution); } else if (e.Delta < Constants.Epsilon) { _toResolution = ZoomHelper.ZoomOut(_map.Resolutions, _toResolution); } e.Handled = true; //so that the scroll event is not sent to the html page. // Some cheating for personal gain. This workaround could be ommitted if the zoom animations was on CenterX, CenterY and Resolution, not Resolution alone. Map.Viewport.Center.X += 0.000000001; Map.Viewport.Center.Y += 0.000000001; StartZoomAnimation(Map.Viewport.Resolution, _toResolution); }
/* Code happening on each frame - handling case when player moves to quiz */ public override void Tick() { if (qc.isQuizActive() && timer <= totalTime) { if (timer == 0f) { statusController.setCanDiscover(false); ZoomHelper.setUIVisibility(goingToQuizCanvas, true); } timer += Time.deltaTime; if (isGaelic) { goingToQuizText.text = "Ceistean ann an " + Math.Ceiling(totalTime - timer); } else { goingToQuizText.text = "Going to quiz in " + Math.Ceiling(totalTime - timer); } } else if (qc.isQuizActive() && timer > totalTime) { camera.SetState(new UnfocusingState(camera)); } }
public double GetResolution(int delta, IViewport viewport, IMap map) { // If the animation has ended then start from the current resolution. // The alternative is that use the previous resolution target and add an extra // level to that. if (!IsAnimating()) { _toResolution = viewport.Resolution; } if (delta > Constants.Epsilon) { _toResolution = ZoomHelper.ZoomIn(map.Resolutions, _toResolution); } else if (delta < Constants.Epsilon) { _toResolution = ZoomHelper.ZoomOut(map.Resolutions, _toResolution); } // TickCount is fast https://stackoverflow.com/a/4075602/85325 _tickCount = Environment.TickCount; return(_toResolution); }
/// <summary> /// Zoom in to the next resolution /// </summary> /// <param name="duration">Duration for animation in milliseconds.</param> /// <param name="easing">The type of easing function used to transform from begin tot end state</param> public void ZoomIn(long duration = -1, Easing?easing = default) { var resolution = ZoomHelper.ZoomIn(_map.Resolutions, _viewport.Resolution); ZoomTo(resolution, duration, easing); }
public void ZoomIn() { Map.Viewport.Resolution = ZoomHelper.ZoomIn(_map.Resolutions, Map.Viewport.Resolution); ViewChanged(true); Invalidate(); }
public void ZoomOut() { _viewport.SetResolution(ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution)); _map.RefreshData(_viewport.Extent, _viewport.Resolution, true); }
/// <summary> /// Zoom out to a given point /// </summary> /// <param name="centerOfZoom">Center to use for zoom out</param> public void ZoomOut(Point centerOfZoom) { var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution); ZoomTo(resolution, centerOfZoom); }
/// <summary> /// Zoom out to the next resolution /// </summary> public void ZoomOut() { var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution); ZoomTo(resolution); }
void Awake() { dragThreshold = 0.0000004f * Screen.width; zoomHelper = new ZoomHelper(image.rectTransform, new Vector2(imageCutRectTransform.rect.width, imageCutRectTransform.rect.height), new Vector2(2048, 2048), mainCamera, 0.00004f * Screen.width); }
public override void OnStateEnter() { ZoomHelper.setUIVisibility(infoBox, true); ZoomHelper.setUIVisibility(backButton, true); }
public override void OnStateExit() { ZoomHelper.setMarkerVisibility(true); }
/// <summary> /// Zoom out to a given point /// </summary> /// <param name="centerOfZoom">Center of zoom. This is the one point in the map that stays on the same location while zooming in. /// For instance, in mouse wheel zoom animation the position of the mouse pointer can be the center of zoom.</param> /// <param name="duration">Duration for animation in milliseconds.</param> /// <param name="easing">The type of easing function used to transform from begin tot end state</param> public void ZoomOut(MPoint centerOfZoom, long duration = -1, Easing?easing = default) { var resolution = ZoomHelper.ZoomOut(_map.Resolutions, _viewport.Resolution); ZoomTo(resolution, centerOfZoom, duration, easing); }
public void ZoomOut() { viewport.Resolution = ZoomHelper.ZoomOut(map.Resolutions, viewport.Resolution); ViewChanged(true); InvalidateMap(true); }