Skip to content

ISnap #2017

@swharden

Description

@swharden

Recent snapping functionality was added using Func<T, T> (#2007) but it would be nice to have a collection of possible snap logic (e.g., snap to an array of predefined numbers) but that's hard because these functions accept and return a single value.

/// <summary>
/// This function applies snapping logic while dragging
/// </summary>
public Func<double, double> DragSnapX { get; set; } = (x) => x;

I'd like to be able to do something like this:

double[] mySnapPoints = { 1, 2, 3 };
ISnap snapper = new ScottPlot.SnapLogic.Nearest(mySnapPoints);
vline1.DragSnapX = snapper;

I'm thinking something like:

public interface ISnap
{
    double Snap(double value);
}

suggested by @Agorath in https://scottplot.net/discord/

related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions