Ejemplo n.º 1
0
    private void setHandStyle()
    {
        switch (_handStyle = (HandStyle)Rnd.Range(0, 3))
        {
        case HandStyle.Lines:
        {
            var ix = Rnd.Range(0, HourLine.Length);
            HourHand.mesh   = HourLine[ix];
            MinuteHand.mesh = MinuteLine[ix];
            break;
        }

        case HandStyle.Arrows:
        {
            var ix = Rnd.Range(0, HourArrow.Length);
            HourHand.mesh   = HourArrow[ix];
            MinuteHand.mesh = MinuteArrow[ix];
            break;
        }

        case HandStyle.Spades:
        {
            var ix = Rnd.Range(0, HourSpade.Length);
            HourHand.mesh   = HourSpade[ix];
            MinuteHand.mesh = MinuteSpade[ix];
            break;
        }
        }
        Debug.LogFormat("[The Clock #{0}] Hand style: {1}", _moduleId, _handStyle);
    }
Ejemplo n.º 2
0
        private protected HandType(HandStyle style, ShortPluralDescriptor nounText, ShortPluralDescriptor nailsText, ShortPluralDescriptor shortDesc, SimpleDescriptor singleDesc,
                                   PluralPartDescriptor <HandData> longDesc) : base(PluralHelper(shortDesc), singleDesc)
        {
            _index          = indexMaker++;
            longDescription = longDesc ?? throw new ArgumentNullException(nameof(longDesc));
            handStr         = nounText ?? throw new ArgumentNullException(nameof(nounText));
            shortPluralDesc = shortDesc;

            nailsStr  = nailsText;
            handStyle = style;
        }
Ejemplo n.º 3
0
 private void uniformRB_CheckedChanged(object sender, EventArgs e)
 {
     if (uniformRB.Checked)
     {
         _handStyle = HandStyle.Uniform;
     }
     else
     {
         _handStyle = HandStyle.Sharp;
     }
 }
Ejemplo n.º 4
0
        private static IEnumerable<VertexInfo[]> Hand(HandStyle style, int design, double thickness, double length, double depth, double elevation)
        {
            const double bevelRadiusOutward = .025;
            const double bevelRadiusDown = .01;
            const int revSteps = 45;
            double backLength = length / 6;
            const double bézierSmoothness = .001;

            PointD[] curve = null;
            switch (style)
            {
                case HandStyle.Lines:
                    curve = Ut.NewArray(
                        new[] { p(-thickness / 2, -backLength), p(thickness / 2, -backLength), p(thickness / 2, length), p(-thickness / 2, length) },
                        new[] { p(-thickness * 3 / 2, -backLength), p(thickness * 3 / 2, -backLength), p(-thickness / 100, length), p(thickness / 100, length) }
                    )[design];
                    break;

                case HandStyle.Arrows:
                    curve = Ut.NewArray(
                        new[] { p(-thickness * 2, -backLength), p(0, -backLength * 4 / 5), p(thickness * 2, -backLength), p(thickness / 5, length * .85), p(thickness * 4, length * .77), p(0, length), p(-thickness * 4, length * .77), p(-thickness / 5, length * .85) },
                        new[] { p(-thickness / 2, -backLength), p(thickness / 2, -backLength), p(thickness / 2, length * .85), p(thickness * 3, length * .85), p(0, length), p(-thickness * 3, length * .85), p(-thickness / 2, length * .85) }
                    )[design];
                    break;

                case HandStyle.Spades:
                    double spadeWidth = thickness * 3 / 2;
                    double spadeHeightF = 4;
                    curve = Ut.NewArray(
                        Enumerable.Range(0, 72).Select(i => i * (360 - 30) / 72 + 90 + 15).Select(angle => p(thickness * 3 * cos(angle), thickness * 3 * sin(angle) - backLength))
                            .Concat(SmoothBézier(p(spadeWidth, length * (1 - spadeHeightF * (1 - .91))), p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .9))), p(spadeWidth * 4, length * (1 - spadeHeightF * (1 - .91))), p(spadeWidth * 4, length * (1 - spadeHeightF * (1 - .93))), bézierSmoothness))
                            .Concat(SmoothBézier(p(spadeWidth * 4, length * (1 - spadeHeightF * (1 - .93))), p(spadeWidth * 4, length * (1 - spadeHeightF * (1 - .96))), p(spadeWidth, length * (1 - spadeHeightF * (1 - .96))), p(0, length), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(0, length), p(-spadeWidth, length * (1 - spadeHeightF * (1 - .96))), p(-spadeWidth * 4, length * (1 - spadeHeightF * (1 - .96))), p(-spadeWidth * 4, length * (1 - spadeHeightF * (1 - .93))), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(-spadeWidth * 4, length * (1 - spadeHeightF * (1 - .93))), p(-spadeWidth * 4, length * (1 - spadeHeightF * (1 - .91))), p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .9))), p(-spadeWidth, length * (1 - spadeHeightF * (1 - .91))), bézierSmoothness).Skip(1))
                            .ToArray(),
                        SmoothBézier(p(spadeWidth * 2, -backLength * 1.5), p(spadeWidth / 2, backLength), p(spadeWidth / 2, 0), p(spadeWidth / 2, length * (1 - spadeHeightF * (1 - .91))), bézierSmoothness)
                            .Concat(SmoothBézier(p(spadeWidth / 2, length * (1 - spadeHeightF * (1 - .91))), p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .91))), p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .92))), p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .93))), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .93))), p(spadeWidth * 3, length * (1 - spadeHeightF * (1 - .95))), p(spadeWidth, length * (1 - spadeHeightF * (1 - .94))), p(0, length), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(0, length), p(-spadeWidth, length * (1 - spadeHeightF * (1 - .94))), p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .95))), p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .93))), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .93))), p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .92))), p(-spadeWidth * 3, length * (1 - spadeHeightF * (1 - .91))), p(-spadeWidth / 2, length * (1 - spadeHeightF * (1 - .91))), bézierSmoothness).Skip(1))
                            .Concat(SmoothBézier(p(-spadeWidth / 2, length * (1 - spadeHeightF * (1 - .91))), p(-spadeWidth / 2, 0), p(-spadeWidth / 2, backLength), p(-spadeWidth * 2, -backLength * 1.5), bézierSmoothness))
                            .ToArray()
                    )[1 - design];
                    break;
            }

            if (curve == null)
                throw new InvalidOperationException();

            foreach (var t in new[] { curve }.Triangulate().Select(arr => arr.Select(p => pt(p.X, depth + elevation, p.Y)).ToArray()))
                yield return t.Select(p => p.WithNormal(0, 1, 0)).Reverse().ToArray();
            foreach (var b in BevelFromCurve(curve.Select(p => pt(p.X, depth, p.Y)), bevelRadiusOutward, bevelRadiusDown, revSteps, Normal.Mine))
                yield return b.Select(vi => new VertexInfo(vi.Location.Add(y: elevation), vi.Normal)).ToArray();
        }
Ejemplo n.º 5
0
 public WatchHand(HandType type, HandStyle style, float centerX, float centerY, int length)
 {
     handType  = type;
     HandStyle = style;
     _centerX  = (int)centerX;
     _centerY  = (int)centerY;
     _length   = length;
     if (string.IsNullOrEmpty(name))
     {
         name = type.ToString();
     }
     _isStartingAtCenter = style == HandStyle.CENTRIC;
     _startingRadius     = centerX;
     _endingRadius       = centerX;
 }