当前位置: 首页>>代码示例>>C#>>正文


C# Channel.findMinMax方法代码示例

本文整理汇总了C#中Procedurality.Channel.findMinMax方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.findMinMax方法的具体用法?C# Channel.findMinMax怎么用?C# Channel.findMinMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Procedurality.Channel的用法示例。


在下文中一共展示了Channel.findMinMax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Gen


//.........这里部分代码省略.........
                    for (x_block = 1, x = block_size; x_block < (1<<i) - 1; x_block++) {
                        for (y_block = 0; y_block < (1<<i); y_block+= (1<<i) - 1) {
                            y = y_block*block_size;
                            v1 = channel.getPixel(x, y);
                            v2 = channel.getPixel((x + block_size) % sizeX, y);
                            v3 = channel.getPixel(x, (y + block_size) % sizeY);
                            v4 = channel.getPixel((x + block_size) % sizeX, (y + block_size) % sizeY);
                            avr = 0.25f*(v1 + v2 + v3 + v4);
                            v5 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            channel.putPixel(x + block_size_half, y + block_size_half, v5);
                        }
                        x+= block_size;
                    }
                }
                // calculate left and bottom edge midpoints
                if (i < 2) {
                    for (x_block = 0, x = 0; x_block < (1<<i); x_block++) {
                        for (y_block = 0, y = 0; y_block < (1<<i); y_block++) {
                            v1 = channel.getPixel(x, y);
                            v5 = channel.getPixel(x + block_size_half, y + block_size_half);
                            v2 = channel.getPixel((x + block_size) % sizeX, y);
                            v3 = channel.getPixel(x, (y + block_size) % sizeY);
                            v6 = channel.getPixel(((x - block_size_half) + sizeX) % sizeX, (y + block_size_half) % sizeY);
                            v7 = channel.getPixel((x + block_size_half) % sizeX, ((y - block_size_half) + sizeY) % sizeY);
                            avr = 0.25f*(v1 + v3 + v5 + v6);
                            v8 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            avr = 0.25f*(v1 + v2 + v5 + v7);
                            v9 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            channel.putPixel(x, y + block_size_half, v8);
                            channel.putPixel(x + block_size_half, y, v9);
                            y+= block_size;
                        }
                        x+= block_size;
                    }
                } else {
                    // safe blocks
                    for (x_block = 1, x = block_size; x_block < (1<<i) - 1; x_block++) {
                        for (y_block = 1, y = block_size; y_block < (1<<i) - 1; y_block++) {
                            v1 = channel.getPixel(x, y);
                            v5 = channel.getPixel(x + block_size_half, y + block_size_half);
                            v2 = channel.getPixel(x + block_size, y);
                            v3 = channel.getPixel(x, y + block_size);
                            v6 = channel.getPixel(x - block_size_half, y + block_size_half);
                            v7 = channel.getPixel(x + block_size_half, y - block_size_half);
                            avr = 0.25f*(v1 + v3 + v5 + v6);
                            v8 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            avr = 0.25f*(v1 + v2 + v5 + v7);
                            v9 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            channel.putPixel(x, y + block_size_half, v8);
                            channel.putPixel(x + block_size_half, y, v9);
                            y+= block_size;
                        }
                        x+= block_size;
                    }
                    // left and right edge blocks
                    for (x_block = 0; x_block < (1<<i); x_block+= (1<<i) - 1) {
                        x = x_block*block_size;
                        for (y_block = 0, y = 0; y_block < (1<<i); y_block++) {
                            v1 = channel.getPixel(x, y);
                            v5 = channel.getPixel(x + block_size_half, y + block_size_half);
                            v2 = channel.getPixel((x + block_size) % sizeX, y);
                            v3 = channel.getPixel(x, (y + block_size) % sizeY);
                            v6 = channel.getPixel(((x - block_size_half) + sizeX) % sizeX, (y + block_size_half) % sizeY);
                            v7 = channel.getPixel((x + block_size_half) % sizeX, ((y - block_size_half) + sizeY) % sizeY);
                            avr = 0.25f*(v1 + v3 + v5 + v6);
                            v8 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            avr = 0.25f*(v1 + v2 + v5 + v7);
                            v9 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            channel.putPixel(x, y + block_size_half, v8);
                            channel.putPixel(x + block_size_half, y, v9);
                            y+= block_size;
                        }
                    }
                    // top and bottom edge blocks
                    for (x_block = 1, x = block_size; x_block < (1<<i) - 1; x_block++) {
                        for (y_block = 0; y_block < (1<<i); y_block+= (1<<i) - 1) {
                            y = y_block*block_size;
                            v1 = channel.getPixel(x, y);
                            v5 = channel.getPixel(x + block_size_half, y + block_size_half);
                            v2 = channel.getPixel((x + block_size) % sizeX, y);
                            v3 = channel.getPixel(x, (y + block_size) % sizeY);
                            v6 = channel.getPixel(((x - block_size_half) + sizeX) % sizeX, (y + block_size_half) % sizeY);
                            v7 = channel.getPixel((x + block_size_half) % sizeX, ((y - block_size_half) + sizeY) % sizeY);
                            avr = 0.25f*(v1 + v3 + v5 + v6);
                            v8 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            avr = 0.25f*(v1 + v2 + v5 + v7);
                            v9 = avr*(1f + (float)random.NextDouble()*amp - amp_half);
                            channel.putPixel(x, y + block_size_half, v8);
                            channel.putPixel(x + block_size_half, y, v9);
                        }
                        x+= block_size;
                    }
                }
            }
            float[] mm=channel.findMinMax();
            //Console.WriteLine("Range Mountain->[{0},{1}]",mm[0],mm[1]);
            channel.normalize();
            mm=channel.findMinMax();
            //Console.WriteLine("Range Mountain->[{0},{1}]",mm[0],mm[1]);
        }
开发者ID:N3X15,项目名称:Procedurality4NET,代码行数:101,代码来源:Mountain.cs


注:本文中的Procedurality.Channel.findMinMax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。