예제 #1
0
 public SaturatedColorGenerator(FractalGenerator fractal)
 {
     // set the height range to whatever the fractal is using
     this.range = fractal.getRange();
     // setup all the rules
     setupRules();
 }
예제 #2
0
        public ActionResult Fractal2()
        {
            string email = User.Identity.Name;

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            FractalGenerator.GenereateFractal2(email).Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            byte[] bitmapData = ms.ToArray();
            return(File(bitmapData, "image/jpeg"));
        }
예제 #3
0
        public ActionResult SaveEvent(EventCategoryViewModel vm, HttpPostedFileBase file, string newItem = null)
        {
            if (SpamDetector.IsContentSpam(vm.GamingEvent.Title))
            {
                return(RedirectToAction("Index", "Post"));
            }
            //Verify whether user has neccessary data
            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }


            int idd = vm.GamingEvent.GamingEventId;

            var gameEvent = vm.GamingEvent;

            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png")
                {
                    var sourceImage = Image.FromStream(file.InputStream);

                    sourceImage = ResizeImage(sourceImage, 500, 500);

                    //Generowanie plik
                    var fileExt  = Path.GetExtension(file.FileName);
                    var filename = Guid.NewGuid() + fileExt; // Unikalny identyfikator + rozszerzenie

                    //W jakim folderze ma byc umiesczony dany plik oraz jego nazwa! Oraz zapis
                    var path = Path.Combine(Server.MapPath(AppConfig.ImagesGamingEventFolder), filename);
                    //file.SaveAs(path);
                    sourceImage.Save(path);
                    gameEvent.MainPicture = filename;
                }
            }
            else if (file == null && newItem != null && newItem != String.Empty)
            {
                var fractImg = FractalGenerator.GenereateFractal1(user.Email);
                var filename = Guid.NewGuid() + ".jpg";
                var path     = Path.Combine(Server.MapPath(AppConfig.ImagesGamingEventFolder), filename);
                fractImg.Save(path);
                gameEvent.MainPicture = filename;
            }

            gameEvent.UserId    = user.Id;
            gameEvent.Publisher = user;

            context.GamingEvents.AddOrUpdate(gameEvent);
            context.SaveChanges();

            return(RedirectToAction("Events", "Manage"));
        }
예제 #4
0
        public ActionResult SaveGame(GameCategoryViewModel vm, HttpPostedFileBase file, string newItem = null)
        {
            //Verify whether user has neccessary data
            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }
            if (user.UserInformation == null)
            {
                RedirectToAction("Index", new { errorMessage = "Proszę wypełnić swoje dane przed dodaniem gry" });
            }

            int idd = vm.Game.GameId;

            var game = vm.Game;

            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png")
                {
                    var sourceImage = Image.FromStream(file.InputStream);

                    sourceImage = ResizeImage(sourceImage, 500, 500);

                    //Generowanie plik
                    var fileExt  = Path.GetExtension(file.FileName);
                    var filename = Guid.NewGuid() + fileExt; // Unikalny identyfikator + rozszerzenie

                    //W jakim folderze ma byc umiesczony dany plik oraz jego nazwa! Oraz zapis
                    var path = Path.Combine(Server.MapPath(AppConfig.ImagesGameFolder), filename);
                    //file.SaveAs(path);
                    sourceImage.Save(path);
                    game.MainPicture = filename;
                }
            }
            else if (file == null && newItem != null && newItem != String.Empty)
            {
                var fractImg = FractalGenerator.GenereateFractal1(user.Email);
                var filename = Guid.NewGuid() + ".jpg";
                var path     = Path.Combine(Server.MapPath(AppConfig.ImagesGameFolder), filename);
                fractImg.Save(path);
                game.MainPicture = filename;
            }

            game.GamesForExchange = System.Text.RegularExpressions.Regex.Replace(game.GamesForExchange, "[^0-9a-zA-ZżźćńółęąśŻŹĆĄŚĘŁÓŃ ]+", "|");
            game.UserId           = user.Id;


            context.Games.AddOrUpdate(game);
            context.SaveChanges();

            return(RedirectToAction("Games", "Manage"));
        }
예제 #5
0
 public GenerationLayer(
     LayerMode Mode       = LayerMode.Multiply,
     ChannelFlag Channels = ChannelFlag.A | ChannelFlag.B | ChannelFlag.G | ChannelFlag.R,
     bool Visible         = true)
 {
     this.Generator = new FractalGenerator(0);
     this.Mode      = Mode;
     this.Channels  = Channels;
     this.Visible   = Visible;
 }
예제 #6
0
    public FractalGenerator Copy()
    {
        FractalGenerator copy = new FractalGenerator();

        copy.seed       = seed;
        copy.type       = type;
        copy.tiled      = tiled;
        copy.inverted   = inverted;
        copy.amplitude  = amplitude;
        copy.frequency  = frequency;
        copy.octaves    = octaves;
        copy.gain       = gain;
        copy.lacunarity = lacunarity;
        copy.min        = min;
        copy.max        = max;
        return(copy);
    }
예제 #7
0
        public void CreateScene(int width, int height, FloatColor color, bool useAntialiasing)
        {
            var renderTarget = new Framebuffer(width, height);

            renderTarget.Clear(color);
            var objects = new List <IHittable>();

            var sierpinsky = Texture.CreateFrom(FractalGenerator.SierpinskyCarpet(100, 100, Color.White, Color.Black))
                             .ToInfo();
            var reflectiveMaterial  = new ReflectiveMaterial(FloatColor.White, 0.4f, 1, 300, 1f, sierpinsky);
            var transparentMaterial = new TransparentMaterial(FloatColor.White, 0.1f, 0, 0.3f, 1.05f, 0.9f);

            var circuitryMaterial = new PbrMaterial(FloatColor.White,
                                                    Texture.LoadFrom(@"_Resources/Textures/circuitry-albedo.png").ToInfo(0.25f),
                                                    Texture.LoadFrom(@"_Resources/Textures/circuitry-emission.png").ToInfo(0.25f),
                                                    Texture.LoadFrom(@"_Resources/Textures/circuitry-smoothness.png").ToInfo(0.25f),
                                                    Texture.LoadFrom(@"_Resources/Textures/circuitry-normals.png").ToInfo(0.25f))
            {
                EmissionFactor     = 2,
                DiffuseCoefficient = 1,
                Specular           = 10,
                SpecularExponent   = 50,
                AmbientPower       = 1
            };

            var greenLavaMaterial = new PbrMaterial(FloatColor.White,
                                                    Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness-green.png").ToInfo(3),
                                                    Texture.LoadFrom(@"_Resources/Textures/lava-emission-green.png").ToInfo(3),
                                                    Texture.LoadFrom(@"_Resources/Textures/lava-albedo-smoothness.png").ToInfo(3),
                                                    Texture.LoadFrom(@"_Resources/Textures/lava-normals.png").ToInfo(3))
            {
                EmissionFactor     = 4,
                DiffuseCoefficient = 1,
                Specular           = 10,
                SpecularExponent   = 50,
                AmbientPower       = 1
            };

            var reflectiveSphere  = new Sphere(new Vector3(2f, -1f, 4), 1f, reflectiveMaterial);
            var transparentSphere = new Sphere(new Vector3(0f, -1f, 2), 1f, transparentMaterial);
            var textureSphere     = new Sphere(new Vector3(-1.5f, -1.5f, 3), 0.5f, greenLavaMaterial);

            objects.Add(reflectiveSphere);
            objects.Add(transparentSphere);
            objects.Add(textureSphere);
            objects.Add(new Plane(new Vector3(5, -2f, 0), new Vector3(0, 1, 0), circuitryMaterial));

            var sampler = new Sampler(new JitteredGenerator(0), new SquareDistributor(), 16, 32);
            var camera  = new PerspectiveCamera(renderTarget, new Vector3(0f, 0, -5), Vector3.Forward, Vector3.Up)
            {
                Sampler  = sampler,
                MaxDepth = 6,
            };

            Scene = new Scene(objects, camera,
                              new List <Light>
            {
                new PointLight
                {
                    Position = new Vector3(1, 1, 0),
                    Color    = FloatColor.White,
                },
                new PointLight
                {
                    Position = new Vector3(-1, 1, 0),
                    Color    = FloatColor.White,
                },
                new PointLight
                {
                    Position  = new Vector3(-2, 2, 15),
                    Color     = FloatColor.White,
                    Intensity = 1
                },
                new PointLight
                {
                    Position = new Vector3(1, 1f, 0),
                    Color    = FloatColor.Green,
                },
                new PointLight
                {
                    Position = new Vector3(-2, -1f, 0),
                    Color    = FloatColor.Red,
                },
            },
                              FloatColor.Black);
        }
예제 #8
0
        public ActionResult SavePost(PostCategoryViewModel vm, HttpPostedFileBase file, string newItem = null)
        {
            #region Spam Detextion
            if (SpamDetector.IsContentSpam(vm.Post.Title))
            {
                return(RedirectToAction("Index", "Post"));
            }
            #endregion

            #region GetUserAndSaveUserImage
            //Verify whether user has neccessary data
            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();
            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }


            int idd = vm.Post.PostId;

            var post = vm.Post;
            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png")
                {
                    var sourceImage = Image.FromStream(file.InputStream);

                    sourceImage = ResizeImage(sourceImage, 500, 500);

                    //Generowanie plik
                    var fileExt  = Path.GetExtension(file.FileName);
                    var filename = Guid.NewGuid() + fileExt; // Unikalny identyfikator + rozszerzenie

                    //W jakim folderze ma byc umiesczony dany plik oraz jego nazwa! Oraz zapis
                    var path = Path.Combine(Server.MapPath(AppConfig.ImagesPostFolder), filename);
                    //file.SaveAs(path);
                    sourceImage.Save(path);
                    post.MainPicture = filename;
                }
            }
            else if (file == null && newItem != null && newItem != String.Empty)
            {
                var fractImg = FractalGenerator.GenereateFractal1(user.Email);
                var filename = Guid.NewGuid() + ".jpg";
                var path     = Path.Combine(Server.MapPath(AppConfig.ImagesPostFolder), filename);
                fractImg.Save(path);
                post.MainPicture = filename;
            }

            #endregion

            #region Sentimental Analisys
            var sentimentalInt = new SentimentalInterpreter();
            var isContentHappy = sentimentalInt.IsHappy(post.Title);
            if (isContentHappy)
            {
                post.IsHappy = true;
            }
            #endregion

            post.DateOfInsert = DateTime.Now;
            post.UserId       = user.Id;
            post.User         = user;

            if (user.Posts.Where(a => a.PostId == post.PostId).Count() == 0)
            {
                user.Posts.Add(post);
            }

            context.Posts.AddOrUpdate(post);
            context.SaveChanges();



            //InsertOrUpdate(post);

            return(RedirectToAction("Post", "Manage"));
        }