Beispiel #1
0
        private SvgPath CreateSlotPath()
        {
            var endCapRadius   = FastenerDiameter / 2f - Constants.Kerf;
            var innerArcRadius = Constants.JigHoleSpacing - (FastenerDiameter / 2f - Constants.Kerf);

            float innerArcX = innerArcRadius * DegreeTrig.Cos(startAngle);
            float innerArcY = -innerArcRadius *DegreeTrig.Sin(startAngle);  // y's are negative b/c they are above the origin hole

            float outerArcX = outerArcRadius * DegreeTrig.Cos(startAngle);
            float outerArcY = -outerArcRadius *DegreeTrig.Sin(startAngle);

            var pointA = Points.MetricPoint(-outerArcX, outerArcY);
            var pointB = Points.MetricPoint(outerArcX, outerArcY);
            var pointC = Points.MetricPoint(innerArcX, innerArcY);
            var pointD = Points.MetricPoint(-innerArcX, innerArcY);

            var slotPath = Paths.CutPath();

            var leftEndCap  = MakeEndCap(-innerArcX, innerArcY, -outerArcX, outerArcY);
            var rightEndCap = MakeEndCap(outerArcX, outerArcY, innerArcX, innerArcY);

            slotPath.PathData.Add(new SvgMoveToSegment(pointA));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointA, outerArcRadius, SvgArcSweep.Positive, pointB));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointB, endCapRadius, SvgArcSweep.Positive, pointC));
            slotPath.PathData.Add(Arcs.SimpleSegment(pointC, innerArcRadius, SvgArcSweep.Negative, pointD)); // Negative makes the lower arc path back "into" the body of the shape
            slotPath.PathData.Add(Arcs.SimpleSegment(pointD, endCapRadius, SvgArcSweep.Positive, pointA));
            return(slotPath);
        }
Beispiel #2
0
        private SvgGroup CreateAngleText()
        {
            var group = new SvgGroup();

            var majorAngleIncrement = (float)totalProtractorAngleSweep / majorDivisions;

            for (int i = 0; i <= majorDivisions; i++)
            {
                // The angle from the horizontal, used for positioning each label
                var a = startAngle + i * majorAngleIncrement;

                // this is the angle from the vertical.  The graduation mark function uses the angle from the horizontal.
                // the letters start rotated left -60
                var textRotation = -90 + a;

                // go from -n to n
                var number = -totalProtractorAngleSweep / 2 + i * majorAngleIncrement;

                var   label = Text.EtchedText(number.ToString("#0"), textHeight);
                float x     = -textBaselineRadius *DegreeTrig.Cos(a);

                float y = -textBaselineRadius *DegreeTrig.Sin(a);

                label.Transforms.Add(new SvgTranslate(x.Px(), y.Px()));
                label.Transforms.Add(new SvgRotate(textRotation));

                group.Children.Add(label);
            }

            return(group);
        }
Beispiel #3
0
        private SvgGroup CreateAngleMarks()
        {
            var group          = new SvgGroup();
            var minorIncrement = (float)totalProtractorAngleSweep / (minorDivisions * majorDivisions);
            var doMidPoint     = minorDivisions % 2 == 0;

            // Spin through the minor divisions selecting the length of the line as we go
            for (int i = 0; i <= majorDivisions * minorDivisions; ++i)
            {
                var   a = startAngle + i * minorIncrement;
                float lineLength;

                if (i % minorDivisions == 0)          // 0, 10, 20 should draw major lines
                {
                    lineLength = majorDivisionLength; // major
                }
                else if (doMidPoint && i % (minorDivisions / 2) == 0)
                {
                    lineLength = minorDivisionLength + 1.5f; // midpoint
                }
                else
                {
                    lineLength = minorDivisionLength;
                }

                var l = Lines.EtchLine(
                    // all lines start on the edge and continue along their length
                    -bodyRadius * DegreeTrig.Cos(a),
                    -bodyRadius * DegreeTrig.Sin(a),
                    -(bodyRadius - lineLength) * DegreeTrig.Cos(a),
                    -(bodyRadius - lineLength) * DegreeTrig.Sin(a));

                group.Children.Add(l);
            }

            return(group);
        }