Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="playerRemapInfo"></param>
        public void Remap(ColorRemapInfo[] playerRemapInfo)
        {
            //System.Diagnostics.Debug.Assert(RemappedCopies != null, "Trying to remap a frame twice!");
            if (RemappedCopies != null)
            {
                return;
            }
            RemappedCopies = new AnimationFrame[playerRemapInfo.Length];

            for (int i = 0; i < playerRemapInfo.Length; ++i)
            {
                //System.Console.WriteLine("Remapping " + FileName + " to " + playerRemapInfo[i] + "(" + i + ")");
                RemappedCopies[i] = ColorRemapper.Remap(this, playerRemapInfo[i]);
            }

            if (Sprite != null)
            {
                System.Diagnostics.Debug.Assert(false);
                Sprite.Dispose();
                Sprite = null;
            }
            // don't dispose of the BB explicitly
            // A remapped frame may use this
            BitmapBuilder = null;
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="color"></param>
        private void PreviewColor(ColorRemapInfo color)
        {
            AnimationFrame frame = ColorRemapper.Remap(OrigFrame, color);

            Bitmap back;

            using (Bitmap bmp = new Bitmap(frame.BitmapBuilder.GetStream()))
            {
                back = new Bitmap(bmp.Width * 2, bmp.Height * 2);

                using (Graphics g = Graphics.FromImage(back))
                {
                    g.DrawImage(bmp, new Rectangle(0, 0, back.Width, back.Height),
                                new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                }
            }

            picPreviewColor.Image = back;
        }
Пример #3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            InputChecker inputChecker = new InputChecker(this);

            #region GetInputsFromCanvas

            List <Point3d> inPts     = new List <Point3d>();
            bool           canGetPts = DA.GetDataList(0, inPts);
            inputChecker.StopIfConversionIsFailed(canGetPts);

            List <Plane> inPlanes   = new List <Plane>();
            bool         canGetPlns = DA.GetDataList(1, inPlanes);
            inputChecker.StopIfConversionIsFailed(canGetPlns);
            ValuesAllocator.MatchLists(inPts, inPlanes);

            List <double> inRange     = new List <double>();
            bool          canGetRange = DA.GetDataList(2, inRange);
            inputChecker.StopIfConversionIsFailed(canGetRange);
            ValuesAllocator.MatchLists(inPts, inRange);

            List <int> inDensity     = new List <int>();
            bool       canGetDensity = DA.GetDataList(3, inDensity);
            inputChecker.StopIfConversionIsFailed(canGetDensity);
            ValuesAllocator.MatchLists(inPts, inDensity);

            Color inFirstColor   = new Color();
            bool  canGetFirstCol = DA.GetData(4, ref inFirstColor);
            inputChecker.StopIfConversionIsFailed(canGetFirstCol);

            Color inSecondColor     = new Color();
            bool  canGetSecondColor = DA.GetData(5, ref inSecondColor);
            inputChecker.StopIfConversionIsFailed(canGetSecondColor);
            #endregion

            List <Circle> crvsOut   = new List <Circle>();
            List <Color>  crvsColor = new List <Color>();

            for (int i = 0; i < inPts.Count; i++)
            {
                Plane  refPlane = inPlanes[i];
                double maxRad   = inRange[i];
                int    density  = inDensity[i] > 0 ? inDensity[i] : 1;
                double distance = maxRad / density;
                double counter  = distance;
                while (counter < maxRad)
                {
                    crvsOut.Add(new Circle(refPlane, inPts[i], counter));

                    Color color = ColorRemapper.RemappedColor(ref inFirstColor, ref inSecondColor, maxRad, distance, counter);
                    crvsColor.Add(color);

                    counter += distance;
                }
            }

            #region SendOutputsToCanvas

            DA.SetDataList(0, crvsOut);
            DA.SetDataList(1, crvsColor);

            #endregion
        }
Пример #4
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            InputChecker inputChecker = new InputChecker(this);

            #region GetInpuFromCanvas
            Surface inBaseSrf     = null;
            bool    canGetSurface = DA.GetData(0, ref inBaseSrf);
            inputChecker.StopIfConversionIsFailed(canGetSurface);
            inBaseSrf.SetDomain(0, new Interval(0.0, 1.0));
            inBaseSrf.SetDomain(1, new Interval(0.0, 1.0));

            List <double> inData     = new List <double>();
            bool          canGetData = DA.GetDataList(1, inData);
            inputChecker.StopIfConversionIsFailed(canGetData);

            List <Point3d> inBasePts     = new List <Point3d>();
            bool           canConvertPts = DA.GetDataList(2, inBasePts);
            inputChecker.StopIfConversionIsFailed(canConvertPts);
            ValuesAllocator.MatchLists(inData, inBasePts);

            Color inFirstColor = new Color();
            if (!DA.GetData(3, ref inFirstColor))
            {
                return;
            }

            Color inSecondColor = new Color();
            if (!DA.GetData(4, ref inSecondColor))
            {
                return;
            }
            #endregion

            int           lastValueIndex = inData.Count - 1;
            List <double> sortedData     = new List <double>(inData);
            sortedData.Sort();
            double refStartDomain = sortedData[0];
            double refEndDomain   = sortedData[lastValueIndex];

            List <Line>  histogramLines  = new List <Line>();
            List <Color> histogramColors = new List <Color>();

            for (int i = 0; i < inData.Count; i++)
            {
                Point3d inPt = inBasePts[i];
                double  uDir = 0.0;
                double  vDir = 0.0;
                if (!inBaseSrf.ClosestPoint(inPt, out uDir, out vDir))
                {
                    return;
                }
                Plane basePlane = new Plane();
                if (!inBaseSrf.FrameAt(uDir, vDir, out basePlane))
                {
                    return;
                }

                double dataVal = inData[i];
                Line   line    = new Line(basePlane.Origin, basePlane.ZAxis, dataVal);
                histogramLines.Add(line);

                Color color = ColorRemapper.RemappedColor(ref inFirstColor, ref inSecondColor, refEndDomain, refStartDomain, dataVal);
                histogramColors.Add(color);
            }



            #region SetOutput
            DA.SetDataList(0, histogramLines);
            DA.SetDataList(1, histogramColors);
            #endregion
        }
Пример #5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            InputChecker inputChecker = new InputChecker(this);

            #region AssignInput
            Curve inCrv     = null;
            bool  canGetCrv = DA.GetData(0, ref inCrv);
            inputChecker.StopIfConversionIsFailed(canGetCrv);
            inCrv.Domain = new Interval(0, 1);

            List <double> inData     = new List <double>();
            bool          canGetData = DA.GetDataList(1, inData);
            inputChecker.StopIfConversionIsFailed(canGetData);

            List <double> inDataOptional     = new List <double>();
            bool          canGetDataOptional = DA.GetDataList(2, inDataOptional);
            inputChecker.StopIfConversionIsFailed(canGetDataOptional);
            if (inDataOptional.Count == 0)
            {
                EqualCurveSubD(inData, inDataOptional);
            }
            ValuesAllocator.MatchLists(inData, inDataOptional);

            Color inFirstColor = new Color();
            if (!DA.GetData(3, ref inFirstColor))
            {
                return;
            }

            Color inSecondColor = new Color();
            if (!DA.GetData(4, ref inSecondColor))
            {
                return;
            }

            List <double> inRotationAngles = new List <double>();
            DA.GetDataList(5, inRotationAngles);
            ValuesAllocator.MatchLists(inData, inRotationAngles);

            #endregion

            int           lastValueIndex = inData.Count - 1;
            List <double> sortedData     = new List <double>(inData);
            sortedData.Sort();
            double refStartDomain = sortedData[0];
            double refEndDomain   = sortedData[lastValueIndex];

            List <Line>  histogramLines  = new List <Line>();
            List <Color> histogramColors = new List <Color>();

            for (int i = 0; i < inData.Count; i++)
            {
                Plane  pFrame;
                double tValue = inDataOptional[i];
                inCrv.PerpendicularFrameAt(tValue, out pFrame);

                double angle_rad = inRotationAngles[i];
                if (_useDegrees)
                {
                    angle_rad = RhinoMath.ToRadians(angle_rad);
                }
                pFrame.Rotate(angle_rad, pFrame.ZAxis);

                double dataVal = inData[i];
                Line   line    = new Line(pFrame.Origin, pFrame.YAxis, dataVal);
                histogramLines.Add(line);

                Color color = ColorRemapper.RemappedColor(ref inFirstColor, ref inSecondColor, refEndDomain, refStartDomain, dataVal);
                histogramColors.Add(color);
            }

            #region SetOutput
            DA.SetDataList(0, histogramLines);
            DA.SetDataList(1, histogramColors);
            #endregion
        }