Beispiel #1
0
        private static int GetRgbFromHsv(double hue, double saturation, double brightness)
        {
            var saturationRatio = saturation / 100.0;
            var brightnessRatio = brightness / 100.0;
            var rgb             = ColorCalculation.GetRgbValueFromHsv(hue, saturationRatio, brightnessRatio);

            return(rgb);
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileName"></param>
 private void RunBackgroundWorkerForCalculateColorsOfMosaic(string fileName)
 {
     using (NDC.Push(MethodBase.GetCurrentMethod().Name)) {
         Color[,] averageColors;
         int w, h;
         w = (int)nudWidth.Value;
         h = (int)nudHeight.Value;
         ACalculateColors mosaicColors = new ColorCalculation(w, h);
         mosaicColors.ColorCalculated += mosaicColors_ColorCalculated;
         this.AverageImage             = mosaicColors.CalculateColors(fileName, out averageColors);
         this.pictureBox.Image         = AverageImage;
         Ctx.AverageColors             = averageColors;
         this.ActualizeProgressBar("", 0, 1);
     }
 }
    /*
     * public int height;
     * public Mesh testMesh;
     * public Texture2D testTex;
     * public bool isDebug = false;
     *
     * private void Start()
     * {
     *  if (isDebug)
     *  {
     *      BrickItConfiguration testCFG = GetTestCfg();
     *      runBrickification(testCFG);
     *  }
     * }*/

    public List <BuildingBlock> GetBuildingBlocks(BrickItConfiguration cfg)
    {
        var oldMesh = cfg.mesh.vertices;

        if (lastBricked != null)
        {
            DestroyImmediate(lastBricked);
            lastBricked = null;
        }
        BlockSelector selector = new BlockSelector(cfg.brickExtends);
        var           tex      = ColorCalculation.colorCalculate(cfg.tex, cfg.colors);
        var           voxels   = Voxelizer.Voxelize(cfg.mesh, tex, cfg.height);

        voxels            = Voxelizer.AddWidth(voxels, cfg.depth);
        lastExtends       = MeshUtils.GetBoundsPerDimension(cfg.mesh);
        cfg.mesh.vertices = oldMesh;
        cfg.mesh.RecalculateBounds();
        return(selector.calculateBlocksSpiralWithBounds(voxels));
    }
Beispiel #4
0
        private static Tuple <double, double, double> GetRealHsvFromRgb(int rgbValue)
        {
            var hsv = ColorCalculation.GetHSVFromRgbValue(rgbValue);

            return(new Tuple <double, double, double>(hsv.Item1, (hsv.Item2 * 100.0), (hsv.Item3 * 100.0)));
        }