public static Grid2 <float> ImageToGreyScaleGridWithRandomRange(Texture2D texture) { var randomX = GLRandom.Range(0, texture.width); var randomY = GLRandom.Range(0, texture.height); return(ImageToGreyScaleGrid(texture, randomX, randomY)); }
private void SetupGrid() { DestroyChildren(); var mesh = new Mesh(); var meshFilter = GetComponent <MeshFilter>(); if (meshFilter == null) { throw new Exception("Add a MeshFilter"); } meshFilter.mesh = mesh; var gridBehaviour = GetComponent <MeshGridBehaviour <TPoint> >(); if (gridBehaviour == null) { grid.Fill(() => new MeshCell(GLRandom.Range(textureWidth * textureHeight))); } else { grid.Fill(gridBehaviour.CreateCell); } GenerateMesh(mesh); cells = grid.Values.ToArray(); }
public static Grid2 <float> ImageToGreyScaleGrid(Texture2D texture) { var dimensions = new GridPoint2(texture.width, texture.height); var storageRect = new GridRect(GridPoint2.Zero, dimensions); var implicitShape = ImplicitShape.Parallelogram(dimensions); var explicitShape = implicitShape.ToExplicit(storageRect); var grid = new Grid2 <float>(explicitShape); var textureData = texture.GetPixels().Select(c => c.grayscale).ToArray(); var randomX = GLRandom.Range(0, texture.width); var randomY = GLRandom.Range(0, texture.height); grid.Fill(p => textureData[(p.X + randomX) % texture.width + (texture.width * ((p.Y + randomY) % texture.height))]); return(grid); }
public int Next() { return(GLRandom.Range(min, max)); }