コード例 #1
0
        public SciterValue NativeGetPath(SciterValue vx, SciterValue vy, SciterValue vw, SciterValue vh, SciterValue vt, SciterValue vclosed)
        {
            double x      = vx.AsDouble();
            double y      = vy.AsDouble();
            double w      = vw.AsDouble();
            double h      = vh.AsDouble();
            double t      = vt.AsDouble();
            bool   closed = vclosed.AsBoolean();

            double[] samples = new double[6];
            double[] sx      = new double[6];
            double[] sy      = new double[6];

            double dx = w / 5.0f;

            samples[0] = (1 + Math.Sin(t * 1.2345f + Math.Cos(t * 0.33457f) * 0.44f)) * 0.5f;
            samples[1] = (1 + Math.Sin(t * 0.68363f + Math.Cos(t * 1.3f) * 1.55f)) * 0.5f;
            samples[2] = (1 + Math.Sin(t * 1.1642f + Math.Cos(t * 0.33457f) * 1.24f)) * 0.5f;
            samples[3] = (1 + Math.Sin(t * 0.56345f + Math.Cos(t * 1.63f) * 0.14f)) * 0.5f;
            samples[4] = (1 + Math.Sin(t * 1.6245f + Math.Cos(t * 0.254f) * 0.3f)) * 0.5f;
            samples[5] = (1 + Math.Sin(t * 0.345f + Math.Cos(t * 0.03f) * 0.6f)) * 0.5f;

            for (int i = 0; i < 6; i++)
            {
                sx[i] = x + i * dx;
                sy[i] = y + h * samples[i] * 0.8f;
            }

            // creating path:
            var p = SciterPath.Create();

            p.MoveTo(sx[0], sy[0], false);
            for (var i = 1; i < 6; ++i)
            {
                p.BezierCurveTo((sx[i - 1]) + dx * 0.5f, sy[i - 1], sx[i] - dx * 0.5f, sy[i], sx[i], sy[i], false);
            }

            if (closed)
            {
                p.LineTo(x + w, y + h, false);
                p.LineTo(x + 0, y + h, false);
                p.ClosePath();
            }

            return(p.ToValue()); // wrap the path into sciter::value;
        }