Jump to content

How does Paint.Net draw the little lines for a selection that moves?


Recommended Posts

If you select a rectangle with your mouse, how does Paint.Net programmatically make the selection look like it rotates? You can't tell from the still image screenshot, but every second or sol, the rectangle appears to rotate clockwise.

 

This is a programming under the hood question, not a usage of Paint.Net. I am pretty proficient in standard Usage as after 10 years this is still my favorite graphics program.

 

Thanks if this is something anyone knows.

Selection.png

Edited by DataJuggler
Link to comment
Share on other sites

They are often called marching ants. See https://en.wikipedia.org/wiki/Marching_ants (I'm not sure that paint.net uses that exact method).

Link to comment
Share on other sites

I reproduced this in C# WPF:

https://gifyu.com/image/7DxN

 

XAML code:

<Window x:Class="Selection.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        UseLayoutRounding="True" Background="#202020"
        Title="MainWindow" Height="400" Width="500">
    <Path HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="White" StrokeDashArray="4 4" Data="m 198.73776,137.33043 c -2.13029,-6.61847 -5.55828,-13.73825 -9.47632,-19.68196 -4.51441,-6.84837 -11.16453,-13.69694 -18.29337,-18.839301 -15.02419,-10.837574 -35.78316,-17.365351 -62.28334,-19.58534 -7.86371,-0.658767 -12.370705,-0.81841 -23.022229,-0.81559 -10.101,0.0016 -14.897444,0.148643 -23.805574,0.724301 -1.900568,0.122779 -3.50171,0.177203 -3.558091,0.120753 -0.0564,-0.0564 0.128637,-1.199274 0.411114,-2.53979 0.938716,-4.454545 1.221905,-7.249366 1.236317,-12.201165 0.01418,-4.83636 -0.139606,-6.469363 -1.023391,-10.874221 C 57.53971,46.744326 54.109,39.360682 49.362643,33.062352 43.133647,24.796556 33.853443,17.103768 22.017162,10.394363 16.843206,7.4615101 8.8385361,3.6330271 2.7479208,1.1782161 L 0,0.07069913 l 66.247143,-0.05173 c 36.435927,-0.02851 66.274387,-0.02446 66.307687,0.0093 0.0333,0.03334 0.30152,1.20189097 0.59605,2.59687797 2.63248,12.4680849 7.70932,20.1944649 15.80856,24.0588629 3.18829,1.521225 5.72738,2.181862 13.03344,3.391061 6.99761,1.158171 9.61588,1.42227 14.21684,1.434018 4.82572,0.01091 6.28516,-0.261964 7.4929,-1.408153 0.6035,-0.57276 0.71269,-0.868208 1.1085,-2.999229 0.52258,-2.813549 0.76643,-5.501063 1.06308,-11.716673 0.12137,-2.543763 0.31406,-5.318749 0.42815,-6.1666699 0.22851,-1.698335 0.77403,-3.864117 1.01005,-4.010002 0.0831,-0.05111 0.25539,0.436846 0.38307,1.084753 0.39025,1.980539 2.40596,9.9071199 3.00606,11.8211279 0.44774,1.427988 0.63531,1.783423 0.89945,1.704536 2.71678,-0.811337 12.95629,-0.811337 15.67303,0 0.26418,0.07884 0.45174,-0.276548 0.89946,-1.704536 0.60012,-1.914008 2.61583,-9.8405889 3.00609,-11.8211279 0.12761,-0.647907 0.30003,-1.136046 0.38304,-1.084753 0.23602,0.145838 0.78155,2.311667 1.01004,4.010002 0.11421,0.8479209 0.30678,3.6229069 0.42819,6.1666699 0.29663,6.21561 0.54047,8.903124 1.06308,11.716673 0.3958,2.131021 0.50498,2.426469 1.10848,2.999229 1.20775,1.146189 2.6672,1.420462 7.4929,1.408153 4.60096,-0.01091 7.21923,-0.275847 14.21684,-1.434018 7.30605,-1.209199 9.84515,-1.869836 13.03343,-3.391061 8.09925,-3.864398 13.17608,-11.590778 15.80858,-24.0588629 0.29455,-1.394987 0.56274,-2.56356597 0.59604,-2.59687797 0.0333,-0.03334 29.87176,-0.03724 66.30769,-0.0093 l 66.24712,0.05173 -2.74789,1.10754797 c -6.09062,2.454811 -14.09532,6.283294 -19.26926,9.2161469 -11.83629,6.709405 -21.11649,14.402193 -27.34548,22.667989 -4.74637,6.29833 -8.17707,13.681974 -9.56023,20.575765 -0.88379,4.404858 -1.03749,6.037861 -1.02339,10.874221 0.014,4.951799 0.29761,7.74662 1.23632,12.201166 0.28249,1.340516 0.46748,2.483417 0.41112,2.539789 -0.0564,0.0564 -1.65752,0.0016 -3.5581,-0.120753 -8.90813,-0.575673 -13.70458,-0.721605 -23.80559,-0.724301 -10.65151,-0.0031 -15.15852,0.156855 -23.02221,0.815591 -26.50018,2.219988 -47.25913,8.747765 -62.28332,19.585339 -7.12885,5.14236 -13.77898,11.99093 -18.29339,18.8393 -3.91806,5.94371 -7.34603,13.06349 -9.47632,19.68196 -0.31842,0.98923 -0.63331,1.79862 -0.69975,1.79862 -0.0665,0 -0.38133,-0.80939 -0.69974,-1.79862 z">
        <Path.Triggers>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation To="-8" Duration="0:0:0.500" RepeatBehavior="Forever" By="1" Storyboard.TargetProperty="StrokeDashOffset"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Path.Triggers>
    </Path>
</Window>

 

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...