示例#1
0
        static void Main(string[] args)
        {
            try
            {
                FigureExtractor.Parse();

                var Parts = FigureExtractor.Parts;

                var figuredataReader = new FiguredataReader();
                figuredataReader.LoadFigurePalettes();
                figuredataReader.loadFigureSetTypes();
                figuredataReader.LoadFigureSets();
                figuredataReader.LoadOldFigureData();

                //string figure = "hd-180-1.hr-100-.ch-260-62.lg-275-64.ha-1008-.ea-1402-.ca-1806-73";
                string figure = "8024319001270152950823021";
                Console.WriteLine("Parsing: " + figure);
                var action  = "lay";
                var gesture = "sml";
                var item    = 2;

                var avata = new Avatar(figure, false, 0, 0, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure0-0.png", avata.Run());

                var avatar0 = new Avatar(figure, false, 1, 1, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure1-1.png", avatar0.Run());

                var avatar = new Avatar(figure, false, 2, 2, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure2-2.png", avatar.Run());

                var avatar1 = new Avatar(figure, false, 3, 3, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure3-3.png", avatar1.Run());

                var avatar2 = new Avatar(figure, false, 4, 4, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure4-4.png", avatar2.Run());

                var avatar3 = new Avatar(figure, false, 5, 5, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure5-5.png", avatar3.Run());

                var avatar4 = new Avatar(figure, false, 6, 6, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure6-6.png", avatar4.Run());

                var avatar5 = new Avatar(figure, false, 7, 7, figuredataReader, action, gesture, false, 1, item);
                File.WriteAllBytes("figure7-7.png", avatar5.Run());

                Console.WriteLine("Done");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.Read();
        }
示例#2
0
文件: Avatar.cs 项目: higoka/Avatara
        public Avatar(string figure, string size, int bodyDirection, int headDirection, FiguredataReader figuredataReader, string action = "std", string gesture = "sml", bool headOnly = false, int frame = 1, int carryDrink = 0)
        {
            Figure             = figure;
            Size               = size.ToLower();
            IsSmall            = Size != "b" && Size != "l";
            BodyDirection      = bodyDirection;
            HeadDirection      = headDirection;
            FiguredataReader   = figuredataReader;
            RenderEntireFigure = !headOnly;

            if (IsSmall)
            {
                CANVAS_WIDTH  = CANVAS_WIDTH / 2;
                CANVAS_HEIGHT = CANVAS_HEIGHT / 2;
            }

            Action  = action;
            Gesture = gesture;

            if (action == "lay")
            {
                var temp = CANVAS_HEIGHT;
                CANVAS_HEIGHT = CANVAS_WIDTH;
                CANVAS_WIDTH  = temp;
            }

            BodyCanvas  = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));
            FaceCanvas  = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));
            DrinkCanvas = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));

            Frame      = frame - 1;
            CarryDrink = carryDrink;

            if (action == "lay")
            {
                this.Gesture       = "lay";
                this.Action        = "lay";
                this.HeadDirection = this.BodyDirection;

                if (this.BodyDirection != 2 && this.BodyDirection != 4)
                {
                    this.BodyDirection = 2;
                }

                if (this.HeadDirection != 2 && this.HeadDirection != 4)
                {
                    this.HeadDirection = 2;
                }

                this.CarryDrink = 0;
            }

            TryNudify(this.Figure);
        }
示例#3
0
        public Avatar(string figure, bool isSmall, int bodyDirection, int headDirection, FiguredataReader figuredataReader, string action = "std", string gesture = "sml", bool headOnly = false, int frame = 1, int carryDrink = -1)
        {
            Figure             = figure;
            IsSmall            = isSmall;
            BodyDirection      = bodyDirection;
            HeadDirection      = headDirection;
            FiguredataReader   = figuredataReader;
            RenderEntireFigure = !headOnly;
            IsOldFigure        = Figure.Length == 25 && Regex.IsMatch(Figure, @"^\d+$");

            if (isSmall)
            {
                CANVAS_WIDTH  = CANVAS_WIDTH / 2;
                CANVAS_HEIGHT = CANVAS_HEIGHT / 2;
            }

            Action  = action;
            Gesture = gesture;

            if (action == "lay")
            {
                var temp = CANVAS_HEIGHT;
                CANVAS_HEIGHT = CANVAS_WIDTH;
                CANVAS_WIDTH  = temp;

                this.Gesture       = "lay";
                this.Action        = "lay";
                this.HeadDirection = this.BodyDirection;

                if (this.BodyDirection != 2 && this.BodyDirection != 4)
                {
                    this.BodyDirection = 2;
                }

                if (this.HeadDirection != 2 && this.HeadDirection != 4)
                {
                    this.HeadDirection = 2;
                }
            }

            BodyCanvas  = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));
            FaceCanvas  = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));
            DrinkCanvas = new Image <Rgba32>(CANVAS_WIDTH, CANVAS_HEIGHT, HexToColor("transparent"));

            Frame      = frame - 1;
            CarryDrink = Action != "lay" ? carryDrink : 0;
        }
示例#4
0
文件: Program.cs 项目: higoka/Avatara
        static void Main(string[] args)
        {
            try
            {
                FigureExtractor.Parse();
                FigureExtractor.Parse();
                FigureExtractor.Parse();

                var Parts = FigureExtractor.Parts;

                var figuredataReader = new FiguredataReader();
                figuredataReader.LoadFigurePalettes();
                figuredataReader.loadFigureSetTypes();
                figuredataReader.LoadFigureSets();

                string figure = "hd-600-7.ch-645-66.lg-720-82.sh-725-80.hr-500-45";
                //string figure = "hd-180-1.hr-100-.ch-260-62.lg-275-64.ea-1402-.ca-1806-73";
                Console.WriteLine("Parsing: " + figure);

                var avatar = new Avatar(figure, "b", 1, 1, figuredataReader, gesture: "", action: "drk", carryDrink: 3);
                File.WriteAllBytes("figure1-1-drk.png", avatar.Run());

                avatar = new Avatar(figure, "l", 2, 2, figuredataReader, gesture: "", action: "drk", carryDrink: 3);
                File.WriteAllBytes("figure2-2-drk.png", avatar.Run());

                avatar = new Avatar(figure, "b", 3, 3, figuredataReader, gesture: "", action: "drk", carryDrink: 3);
                File.WriteAllBytes("figure3-3-drk.png", avatar.Run());


                Console.WriteLine("Done");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.Read();
        }
示例#5
0
        public IActionResult Index()
        {
            string figure = "";

            if (Request.Query.ContainsKey("figure"))
            {
                Request.Query.TryGetValue("figure", out var value);
                figure = value.ToString();
            }
            if (figuredataReader == null)
            {
                FigureExtractor.Parse();

                figuredataReader = new FiguredataReader();
                figuredataReader.LoadFigurePalettes();
                figuredataReader.loadFigureSetTypes();
                figuredataReader.LoadFigureSets();
            }

            if (Regex.IsMatch(figure, @"^\d+$"))
            {
                figuredataReader.LoadOldFigureData();
            }

            bool isSmall       = false;
            int  bodyDirection = 0;
            int  headDirection = 0;

            string action   = "std";
            string gesture  = "sml";
            bool   headOnly = false;
            int    frame    = 1;



            if (Request.Query.ContainsKey("action"))
            {
                Request.Query.TryGetValue("action", out var value);
                action = value.ToString();
            }

            if (Request.Query.ContainsKey("gesture"))
            {
                Request.Query.TryGetValue("gesture", out var value);
                gesture = value.ToString();
            }

            if (Request.Query.ContainsKey("figure"))
            {
                Request.Query.TryGetValue("figure", out var value);
                figure = value.ToString();
            }

            if (Request.Query.ContainsKey("size"))
            {
                Request.Query.TryGetValue("size", out var value);

                if (value == "s")
                {
                    isSmall = true;
                }
            }

            if (Request.Query.ContainsKey("head"))
            {
                Request.Query.TryGetValue("head", out var value);
                headOnly = value.ToString() == "1" || value.ToString() == "true";
            }

            if (Request.Query.ContainsKey("direction"))
            {
                Request.Query.TryGetValue("direction", out var value);

                if (value.ToString().IsNumeric())
                {
                    bodyDirection = int.Parse(value.ToString());
                }
            }

            if (Request.Query.ContainsKey("head_direction"))
            {
                Request.Query.TryGetValue("head_direction", out var value);

                if (value.ToString().IsNumeric())
                {
                    headDirection = int.Parse(value.ToString());
                }
            }

            if (Request.Query.ContainsKey("frame"))
            {
                Request.Query.TryGetValue("frame", out var value);

                if (value.ToString().IsNumeric())
                {
                    int v = int.Parse(value.ToString());
                    frame = v < 1 ? 1 : v;
                }
            }

            if (figure != null && figure.Length > 0)
            {
                var furni = new Avatar(figure, isSmall, bodyDirection, headDirection, figuredataReader, action: action, gesture: gesture, headOnly: headOnly, frame: frame);

                return(File(furni.Run(), "image/png"));
            }

            return(null);
        }
示例#6
0
        public IActionResult Index()
        {
            if (figuredataReader == null)
            {
                FigureExtractor.Parse();

                figuredataReader = new FiguredataReader();
                figuredataReader.LoadFigurePalettes();
                figuredataReader.loadFigureSetTypes();
                figuredataReader.LoadFigureSets();
            }

            string size          = "b";
            int    bodyDirection = 2;
            int    headDirection = 2;
            string figure        = null;
            string action        = "std";
            string gesture       = "sml";
            bool   headOnly      = false;
            int    frame         = 1;
            int    carryDrink    = -1;

            if (Request.Query.ContainsKey("figure"))
            {
                Request.Query.TryGetValue("figure", out var value);
                figure = value.ToString();
            }

            if (Request.Query.ContainsKey("action"))
            {
                Request.Query.TryGetValue("action", out var value);
                action = value.ToString();
            }

            if (Request.Query.ContainsKey("gesture"))
            {
                Request.Query.TryGetValue("gesture", out var value);
                gesture = value.ToString();
            }

            if (Request.Query.ContainsKey("figure"))
            {
                Request.Query.TryGetValue("figure", out var value);
                figure = value.ToString();
            }

            if (Request.Query.ContainsKey("size"))
            {
                Request.Query.TryGetValue("size", out var value);
                size = value.ToString();
            }

            if (Request.Query.ContainsKey("head"))
            {
                Request.Query.TryGetValue("head", out var value);
                headOnly = value.ToString() == "1" || value.ToString() == "true";
            }

            if (Request.Query.ContainsKey("direction"))
            {
                Request.Query.TryGetValue("direction", out var value);

                if (value.ToString().IsNumeric())
                {
                    bodyDirection = int.Parse(value.ToString());
                }
            }

            if (Request.Query.ContainsKey("head_direction"))
            {
                Request.Query.TryGetValue("head_direction", out var value);

                if (value.ToString().IsNumeric())
                {
                    headDirection = int.Parse(value.ToString());
                }
            }

            if (Request.Query.ContainsKey("frame"))
            {
                Request.Query.TryGetValue("frame", out var value);

                if (value.ToString().IsNumeric())
                {
                    int v = int.Parse(value.ToString());
                    frame = v < 1 ? 1 : v;
                }
            }

            if (Request.Query.ContainsKey("drk"))
            {
                Request.Query.TryGetValue("drk", out var value);
                action = (value.ToString() == "1" || value.ToString() == "true") ? "drk" : action;
            }

            if (Request.Query.ContainsKey("crr"))
            {
                Request.Query.TryGetValue("crr", out var value);

                if (value.ToString().IsNumeric())
                {
                    carryDrink = int.Parse(value.ToString());
                }
            }

            if (figure != null && figure.Length > 0)
            {
                var furni = new Avatar(figure, size, bodyDirection, headDirection, figuredataReader, action: action, gesture: gesture, headOnly: headOnly, frame: frame, carryDrink: carryDrink);

                return(File(furni.Run(), "image/png"));
            }

            return(null);
        }