當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。