示例#1
0
        public static Bitmap Split(this Image image, int size, UIShape shape)
        {
            //截图画板
            Bitmap   result = new Bitmap(size, size);
            Graphics g      = System.Drawing.Graphics.FromImage(result);
            //创建截图路径(类似Ps里的路径)
            GraphicsPath path = new GraphicsPath();

            if (shape == UIShape.Circle)
            {
                path.AddEllipse(0, 0, size, size);//圆形
            }

            if (shape == UIShape.Square)
            {
                path.Dispose();
                path = new Rectangle(0, 0, size, size).CreateRoundedRectanglePath(5);//圆形
            }

            g.SetHighQuality();
            //设置画板的截图路径
            g.SetClip(path);
            //对图片进行截图
            g.DrawImage(image, 0, 0);
            //保存截好的图
            g.Dispose();
            path.Dispose();

            return(result);
        }
示例#2
0
        public void RenderShape(UIShape shape)
        {
            var command = GetRenderCommand <RenderUIShapeCommand>(RenderCommandType.RenderUIShape);

            command.Package(shape);
            _renderCommands.Enqueue(command);
        }
示例#3
0
        void RenderFieldMap(int chapterId)
        {
            this.ChapterId = chapterId;

            // Draw map on UI
            GameField field           = gameManager.GetField();
            Material  defaultMaterial = Resources.Load <Material>(@"common-mat");

            fieldMapRoot = this.transform.Find("FieldMap");
            string        mappingData = File.ReadAllText(@"D:\GitRoot\toneyisnow\windingtale\Resources\Remastered\Shapes\ShapePanel1\shape-mapping-1.json");
            ShapeMappings mappings    = JsonConvert.DeserializeObject <ShapeMappings>(mappingData);

            HashSet <int> missingShapes = new HashSet <int>();

            for (int x = 0; x < field.Width; x++)
            {
                for (int y = 0; y < field.Height; y++)
                {
                    int    shapeIndex  = field.Map[x, y];
                    string voxIndexStr = shapeIndex.ToString();
                    foreach (string key in mappings.mappings.Keys)
                    {
                        if (mappings.mappings[key].Contains(shapeIndex))
                        {
                            voxIndexStr = key;
                            break;
                        }
                    }

                    Int32.TryParse(voxIndexStr, out int voxIndex);

                    GameObject shapeObject = new GameObject();
                    shapeObject.name = string.Format(@"shape_{0}_{1}", x + 1, y + 1);
                    UIShape shapeCom = shapeObject.AddComponent <UIShape>();
                    shapeCom.Initialize(this, fieldMapRoot, chapterId, voxIndex, FDPosition.At(x + 1, y + 1));

                    /*
                     * GameObject shapeGO = AssetManager.Instance().InstantiateShapeGO(this.transform, chapterId, voxIndex);
                     * if (shapeGO == null)
                     * {
                     *  missingShapes.Add(shapeIndex);
                     *  continue;
                     * }
                     *
                     * shapeGO.transform.parent = fieldMapRoot;
                     * shapeGO.transform.localPosition = FieldTransform.GetShapePixelPosition(x + 1, y + 1);
                     *
                     * var box = shapeGO.AddComponent<BoxCollider>();
                     * box.size = new Vector3(2.0f, 0.5f, 2.0f);
                     * box.center = new Vector3(0f, 1f, 0f);
                     */

                    //var renderer = shapePrefab.GetComponentInChildren<MeshRenderer>();
                    //renderer.sharedMaterial = defaultMaterial;

                    // Note the the FlameDragon is counting matrix from 1, not 0
                    // GameObject go = FieldTransform.CreateShapeObject(shapePrefab, fieldMapRoot, x + 1, y + 1);
                }
            }
        }
 public void RenderShape(UIShape shape)
 {
     _openGlRenderer.RenderShape(shape);
 }
示例#5
0
 public void Package(UIShape shape)
 {
     Shape = shape;
 }