Repository: PixiEditor/PixiEditor
File: src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Image/PatternNode.cs (C#)

Code before:
    {
        var matrix = path.GetMatrixAtDistance(distance, false, PathMeasureMatrixMode.GetPositionAndTangent);
        if (matrix == null)
            return;

        if (Alignment.Value == PatternAlignment.Center)
        {
            matrix = matrix.Concat(Matrix3X3.CreateTranslation(-Fill.Value.Size.X / 2f, -Fill.Value.Size.Y / 2f));
        }
        else if (Alignment.Value == PatternAlignment.Outside)
        {
            matrix = matrix.Concat(Matrix3X3.CreateTranslation(0, -Fill.Value.Size.Y));
        }

        surface.Canvas.Save();
        surface.Canvas.SetMatrix(surface.Canvas.TotalMatrix.Concat(matrix));
        surface.Canvas.DrawImage(image, 0, 0);
        surface.Canvas.Restore();
    }

    private void PlaceStretchToFit(DrawingSurface surface, VectorPath path, float distance, float spacing,
        Paint tilePaint)
    {
        int texWidth = (int)Fill.Value.Size.X;
        int texHeight = (int)Fill.Value.Size.Y;

        // Iterate over each column of the texture (1px wide quads)
        for (int x = 0; x < texWidth; x++)
        {
            float u0 = (float)x / texWidth;
            float u1 = (float)(x + 1) / texWidth;

            float d0 = distance + u0 * spacing;
            float d1 = distance + u1 * spacing;

            var startSegment = path.GetPositionAndTangentAtDistance(d0, false);
            var endSegment = path.GetPositionAndTangentAtDistance(d1, false);

            var startNormal = new VecD(-startSegment.W, startSegment.Z).Normalize();
            var endNormal = new VecD(-endSegment.W, endSegment.Z).Normalize();

            float halfHeight = texHeight / 2f;

            VecD start = new VecD(startSegment.X, startSegment.Y);
            VecD end = new VecD(endSegment.X, endSegment.Y);

            if (Alignment.Value == PatternAlignment.Inside)
            {
                start += startNormal * halfHeight;
                end += endNormal * halfHeight;
            }

Review comment (suggestion):
The for loop is quite long, maybe you could some part like `texCoords` - `DrawVerticies` in a separate method

You could also use more `var` here since the types are pretty self explanatory

Code after:
        if (matrix == null)
            return;

        if (Alignment.Value == PatternAlignment.Center)
        {
            matrix = matrix.Concat(Matrix3X3.CreateTranslation(-Fill.Value.Size.X / 2f, -Fill.Value.Size.Y / 2f));
        }
        else if (Alignment.Value == PatternAlignment.Outside)
        {
            matrix = matrix.Concat(Matrix3X3.CreateTranslation(0, -Fill.Value.Size.Y));
        }

        surface.Save();
        surface.SetMatrix(surface.TotalMatrix.Concat(matrix));
        surface.DrawImage(image, 0, 0);
        surface.Restore();
    }

    private void PlaceStretchToFit(Canvas surface, VectorPath path, float distance, float spacing,
        Paint tilePaint)
    {
        int texWidth = Fill.Value.Size.X;
        int texHeight = Fill.Value.Size.Y;

        // Iterate over each column of the texture (1px wide quads)
        for (int x = 0; x < texWidth; x++)
        {
            float u0 = (float)x / texWidth;
            float u1 = (float)(x + 1) / texWidth;

            float d0 = distance + u0 * spacing;
            float d1 = distance + u1 * spacing;

            var startSegment = path.GetPositionAndTangentAtDistance(d0, false);
            var endSegment = path.GetPositionAndTangentAtDistance(d1, false);

            var startNormal = new VecD(-startSegment.W, startSegment.Z).Normalize();
            var endNormal = new VecD(-endSegment.W, endSegment.Z).Normalize();

            float halfHeight = texHeight / 2f;

            VecD start = new VecD(startSegment.X, startSegment.Y);
            VecD end = new VecD(endSegment.X, endSegment.Y);

            if (Alignment.Value == PatternAlignment.Inside)
            {
                start += startNormal * halfHeight;
                end += endNormal * halfHeight;
            }
            else if (Alignment.Value == PatternAlignment.Outside)
            {