Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Debug.Log(QualitySettings.GetQualityLevel().ToString());
        if (QualitySettings.GetQualityLevel() >= 4)
        {
            Debug.Log("CaptureRes: 2048");
            captureResolution = 1024;
        }
        if (QualitySettings.GetQualityLevel() == 5)
        {
            Debug.Log("CaptureAA: 2");
            captureAASetting = 2;
        }
        else if (QualitySettings.GetQualityLevel() > 5)
        {
            Debug.Log("CaptureAA: 4");
            captureAASetting = 1;
        }

        _toolMenu         = GetComponent <ToolMenu>();
        captureCamera     = transform.Find("CaptureCamera").GetComponent <Camera>();
        captureTexture    = new Texture2D(captureResolution, captureResolution, TextureFormat.ARGB32, true);
        captureRenderer   = captureTarget.GetComponent <MeshRenderer>();
        renderTexturePool = new RenderTexture[2];
        for (int i = 0; i < 2; ++i)
        {
            renderTexturePool[i] = new RenderTexture(captureResolution, captureResolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
            renderTexturePool[i].antiAliasing = captureAASetting;
            renderTexturePool[i].Create();
        }


        splineTool = new SplineTool(this, _splineRenderTarget, _line, circleCursor);
        splineTool.SetSplineJaggedness(false);
        stampTool  = new StampTool(this, _stampPrefab);
        meterTool  = new MeterTool(this, _line, meterCursor);
        eraserTool = new EraserTool(this, eraserSprite, eraserCursor);


        activeTool = splineTool;
        activeTool.Activate();

        float mapWHratio  = 16.0f / 9.0f;
        int   screenWidth = Screen.width;

        screenWidth -= screenWidth / 20;
        screenWidth  = (int)Mathf.Min(captureResolution * 1.25f, screenWidth);
        int height = (int)(screenWidth / mapWHratio);

        UIImageTransform.sizeDelta = new Vector2(screenWidth, height);

        backups = new Color32[backupCount][];
        for (int i = 0; i < backupCount; ++i)
        {
            backups[i] = new Color32[captureResolution * captureResolution];
        }
    }
 public override bool ReDo()
 {
     try
     {
         StampTool stampTool = (StampTool)PocketPaintApplication.GetInstance().ToolCurrent;
         stampTool.StampPaste(_xCoordinateOnWorkingSpace, _yCoordinateOnWorkingSpace, _stampedImage);
         return(true);
     }
     catch (Exception exception)
     {
         System.Diagnostics.Debug.WriteLine(exception.StackTrace);
         return(false);
     }
 }
Exemplo n.º 3
0
        public void SwitchTool(ToolType toolType)
        {
            if (toolType != ToolType.Move && ToolWhileMoveTool != null && ToolWhileMoveTool.GetToolType() == toolType)
            {
                ToolCurrent       = ToolWhileMoveTool;
                ToolWhileMoveTool = null;
                return;
            }
            ToolWhileMoveTool = null;

            if (ToolCurrent != null)
            {
                ToolCurrent.ResetUsedElements();
            }

            switch (toolType)
            {
            case ToolType.Brush:
                ToolCurrent = new BrushTool();
                break;

            case ToolType.Crop:
                ToolCurrent = new CropTool();
                break;

            case ToolType.Cursor:
                ToolCurrent = new CursorTool();
                break;

            case ToolType.Fill:
                ToolCurrent = new FillTool();
                break;

            case ToolType.Ellipse:
                ToolCurrent = new EllipseTool();
                break;

            case ToolType.Eraser:
                ToolCurrent = new EraserTool();
                break;

            case ToolType.ImportPng:
                ToolCurrent = new ImportTool();
                break;

            case ToolType.Flip:
                ToolCurrent = new FlipTool();
                break;

            case ToolType.Line:
                ToolCurrent = new LineTool();
                break;

            case ToolType.Zoom:
                ToolCurrent = new MoveZoomTool();
                break;

            case ToolType.Move:
                ToolWhileMoveTool = ToolCurrent;
                ToolCurrent       = new MoveZoomTool(false);
                break;

            case ToolType.Pipette:
                ToolCurrent = new PipetteTool();
                break;

            case ToolType.Rotate:
                ToolCurrent = new RotateTool();
                break;

            case ToolType.Rect:
                ToolCurrent = new RectangleTool();
                break;

            case ToolType.Stamp:
                ToolCurrent = new StampTool();
                break;

            default:
                break;
            }
        }