public ColorPicker()
        {
            Control.AttachToDocument();

            System.Console.WriteLine("colors...");

            IHTMLImage palette = new palette();


            Control.style.position = IStyle.PositionEnum.relative;
            Control.style.backgroundColor = Color.Gray;
            Control.style.SetSize(277, 262);


            var layer = new IHTMLDiv();


            layer.style.SetLocation(1, 1, 275, 260);

            palette.ToBackground(layer);

            Control.appendChild(layer);


            layer.onmousemove +=
                delegate (IEvent ev)
                {

                    System.Console.WriteLine("" + ev.OffsetPosition + ", x " + layer.Bounds);

                    // jscolor will be merged with color sometime in the future

                    if (ev.OffsetX > 260)
                    {

                        var lum = (byte)System.Math.Round((double)(240 - ev.OffsetY / 260.0 * 240));

                        System.Console.WriteLine("lum: " + lum);

                        Native.Document.body.style.backgroundColor = JSColor.FromHLS(0, lum, 0);
                    }
                    else
                    {
                        var hue = (byte)System.Math.Round((double)(ev.OffsetX / 260.0 * 240));
                        var lum = (byte)System.Math.Round((double)(240 - ev.OffsetY / 260.0 * 240));

                        var backgroundColor = JSColor.FromHLS(hue, lum, 240);

                        Console.WriteLine(new { hue, lum, backgroundColor });
                        Native.body.style.backgroundColor = backgroundColor;
                    }

                };
        }
Esempio n. 2
0
        public ColorPicker()
        {
            Control.AttachToDocument();

            System.Console.WriteLine("colors...");

            IHTMLImage palette = new palette();


            Control.style.position        = IStyle.PositionEnum.relative;
            Control.style.backgroundColor = Color.Gray;
            Control.style.SetSize(277, 262);


            var layer = new IHTMLDiv();


            layer.style.SetLocation(1, 1, 275, 260);

            palette.ToBackground(layer);

            Control.appendChild(layer);


            layer.onmousemove +=
                delegate(IEvent ev)
            {
                System.Console.WriteLine("" + ev.OffsetPosition + ", x " + layer.Bounds);

                // jscolor will be merged with color sometime in the future

                if (ev.OffsetX > 260)
                {
                    var lum = (byte)System.Math.Round((double)(240 - ev.OffsetY / 260.0 * 240));

                    System.Console.WriteLine("lum: " + lum);

                    Native.Document.body.style.backgroundColor = JSColor.FromHLS(0, lum, 0);
                }
                else
                {
                    var hue = (byte)System.Math.Round((double)(ev.OffsetX / 260.0 * 240));
                    var lum = (byte)System.Math.Round((double)(240 - ev.OffsetY / 260.0 * 240));

                    var backgroundColor = JSColor.FromHLS(hue, lum, 240);

                    Console.WriteLine(new { hue, lum, backgroundColor });
                    Native.body.style.backgroundColor = backgroundColor;
                }
            };
        }
Esempio n. 3
0
    private void select_color(Button button)
    {
        using (palette palette = new palette((Color)button.Tag))
            if (DialogResult.OK == palette.ShowDialog())
            {
                button.Tag = palette.color;

                update_image(button);
            }
            else
            {
                momiji_preferences.palette_default_colors = momiji_preferences.tpalette_default_colors;
            }
    }
Esempio n. 4
0
    void OnMouseDown()
    {
        if (Input.GetMouseButtonDown(0))            // left button down
        {
            paintobj = GameObject.Find("pallete/paint4");
            Color color = paintobj.renderer.material.color;

            GameObject   canvas       = GameObject.Find("canvas");
            drawingOnGUI canvasScript = canvas.GetComponent <drawingOnGUI>();
            canvasScript.OnColorChange(color);

            GameObject view = GameObject.Find("colorview");
            view.renderer.material.color = color;

            GameObject palobj = GameObject.Find("pallete");
            pal       = palobj.GetComponent <palette>();
            pal.check = 0;
        }
    }
Esempio n. 5
0
    public void OnCanvasDown()
    {
        paintobj = GameObject.Find("pallete/paint4");
        Color color = paintobj.renderer.material.color;

        GameObject   canvas       = GameObject.Find("canvas");
        drawingOnGUI canvasScript = canvas.GetComponent <drawingOnGUI>();

        canvasScript.OnColorChange(color);

        GameObject view = GameObject.Find("colorview");

        view.renderer.material.color = color;

        GameObject palobj = GameObject.Find("pallete");

        pal       = palobj.GetComponent <palette>();
        pal.check = 0;
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        string dataname = PlayerPrefs.GetString("art");          // Receive datafile's name

        /* If datafile's name is not empty, load datafile to wateroil scene  */
        if (PlayerPrefs.HasKey("art"))
        {
            Debug.Log("dataname : " + dataname);
            GameObject canvas  = GameObject.Find("canvas");
            GameObject pallete = GameObject.Find("pallete");

            drawingOnGUI canvasScript  = canvas.GetComponent <drawingOnGUI>();
            palette      palleteScript = pallete.GetComponent <palette>();

            palleteScript.init(dataname + ".data");
            canvasScript.init(dataname + ".buf");
        }

        PlayerPrefs.DeleteKey("art");
    }
Esempio n. 7
0
    public void OnCanvasUp()
    {
        Debug.Log("OnCanvasUp");
        mypaint_draw_end();

        // notify the change of color to palette
        palette target = GameObject.Find("pallete").GetComponent <palette>();

        target.OnPaintAdd(currentColor);

        //TODO limit maximum number of undo

        //Do deep copy
        Texture2D deepCopiedTex = Instantiate(texture) as Texture2D;

        short[] deepCopidedBuf = buffer.Clone() as short[];

        //push current canvas image to undo stack
        undoStack.Push(new CanvasSnapshot(deepCopiedTex, deepCopidedBuf));

        //clear redo stack
        redoStack.Clear();
    }
Esempio n. 8
0
 return(new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, alpha, newTint, newTintModifiers, isDecoration));
Esempio n. 9
0
    void OnMouseDown()
    {
        // file : screenshot, paint + scene, drawing data

        /* Step
         * 1. sence name
         * 2. paint
         * 3.
         */
        GameObject   canvas       = GameObject.Find("canvas");
        drawingOnGUI canvasScript = canvas.GetComponent <drawingOnGUI> ();

        if (canvasScript.isCanvasChange() == false)        // no change in canvas
        {
            return;
        }

        string galleryPath = Application.dataPath + "/galleryData/";

        string canvasID = canvasScript.getCanvasID();

        string fileName = string.Empty;

        if (canvasID == string.Empty)       // new art space
        {
            fileName = galleryPath + System.DateTime.Now.ToString("yyyyMMddHHmmss");
        }
        else                                                    // old art space
        {
            fileName = galleryPath + canvasID;
        }


        // screenshot
        int fcount = Directory.GetFiles(galleryPath, "*.png", SearchOption.AllDirectories).Length;       // Count the number of file(파일개수)

        string[] files = Directory.GetFiles(galleryPath, "*.png", SearchOption.AllDirectories);          // String array(save screenshot file)

        int limit = 6;

        // if file number reached at limit number, then delete the oldest file
        if (fcount == limit && canvasID == string.Empty)
        {
            string filename = files[0].Substring(files[0].Length - 18, 14); // 'C:\user\20140512123123.png' -> '20140512123123'

            File.Delete(files [0]);                                         // delete png

            if (File.Exists(galleryPath + filename + ".data"))
            {
                string[] data = Directory.GetFiles(galleryPath, filename + ".data", SearchOption.AllDirectories);
                string[] buf  = Directory.GetFiles(galleryPath, filename + ".buf", SearchOption.AllDirectories);

                File.Delete(data [0]);
                File.Delete(buf [0]);
            }
        }

        Application.CaptureScreenshot(fileName + ".png");

        // paint + scence
        GameObject pallete       = GameObject.Find("pallete");
        palette    palleteScript = pallete.GetComponent <palette> ();

        Color[] paintsColor = palleteScript.getPaintsColor();

        StreamWriter sw = new StreamWriter(File.Open(fileName + ".data", FileMode.Create));

        sw.WriteLine("wateroil");
        sw.WriteLine(paintsColor.Length);

        for (int i = 0; i < paintsColor.Length; i++)
        {
            sw.WriteLine(paintsColor[i].r.ToString() + " " +
                         paintsColor[i].g.ToString() + " " +
                         paintsColor[i].b.ToString() + " " +
                         paintsColor[i].a.ToString());
        }

        sw.Close();

        // drawing data

        short[] canvasBuf = canvasScript.getCanvasBuf();

        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName + ".buf", FileMode.Create))){
            foreach (short elem in canvasBuf)
            {
                writer.Write(elem);
            }
        }
        Debug.Log("working spaced saved!");
    }
Esempio n. 10
0
 return(new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, newTint, isDecoration, ignoreWorldTint));
Esempio n. 11
0
    void  Update()
    {
        //paintt1 = GetComponent<paint1>();
        //paintt1.renderer.material.color = UIColorPicker.current.value;
        Rect imgRect = new Rect(screenWidth / 3.65f, screenHeight / 2.23f, baseTex.width * zoom, baseTex.height * zoom);
        //DrawTexture하고 맞춰줘야 마우스하고  선하고 같은 위치에서 그림

        Vector2 mouse = Input.mousePosition;

        mouse.y = Screen.height - mouse.y;

        if (Input.GetKeyDown("t"))
        {
            test();
        }

        if (Input.GetKeyDown("mouse 0"))
        {
            Debug.Log(Input.mousePosition.x + " , " + Input.mousePosition.y);
            if (imgRect.Contains(mouse))
            {
                if (tool == Tool.Vector)
                {
                    var m2 = mouse - new Vector2(imgRect.x, imgRect.y);

                    m2.y = imgRect.height - m2.y;

                    var bz = new ArrayList(BezierPoints);

                    bz.Add(new BezierPoint(m2, m2 - new Vector2(50, 10), m2 + new Vector2(50, 10)));

                    BezierPoints = (BezierPoint[])bz.ToArray();

                    DrawBezier(BezierPoints, lineTool.width, col, baseTex);
                }

                dragStart = mouse - new Vector2(imgRect.x, imgRect.y);

                dragStart.y = imgRect.height - dragStart.y;

                dragStart.x = Mathf.Round(dragStart.x / zoom);

                dragStart.y = Mathf.Round(dragStart.y / zoom);

                //LineStart (mouse - Vector2 (imgRect.x,imgRect.y));

                dragEnd = mouse - new Vector2(imgRect.x, imgRect.y);

                dragEnd.x = Mathf.Clamp(dragEnd.x, 0, imgRect.width);

                dragEnd.y = imgRect.height - Mathf.Clamp(dragEnd.y, 0, imgRect.height);

                dragEnd.x = Mathf.Round(dragEnd.x / zoom);

                dragEnd.y = Mathf.Round(dragEnd.y / zoom);
            }

            else
            {
                dragStart = Vector3.zero;
            }
        }

        if (Input.GetKey("mouse 0"))
        {
            if (dragStart == Vector2.zero)
            {
                return;
            }

            dragEnd = mouse - new Vector2(imgRect.x, imgRect.y);

            dragEnd.x = Mathf.Clamp(dragEnd.x, 0, imgRect.width);

            dragEnd.y = imgRect.height - Mathf.Clamp(dragEnd.y, 0, imgRect.height);

            dragEnd.x = Mathf.Round(dragEnd.x / zoom);

            dragEnd.y = Mathf.Round(dragEnd.y / zoom);

            if (tool == Tool.Brush)
            {
                Brush(dragEnd, preDrag);
            }

            if (tool == Tool.Eraser)
            {
                Eraser(dragEnd, preDrag);
            }
        }

        if (Input.GetKeyUp("mouse 0") && dragStart != Vector2.zero)
        {
            GameObject targetobj = GameObject.Find("pallete");
            target     = targetobj.GetComponent <palette>();
            target.clr = col;
            if (tool == Tool.Line)
            {
                dragEnd = mouse - new Vector2(imgRect.x, imgRect.y);

                dragEnd.x = Mathf.Clamp(dragEnd.x, 0, imgRect.width);

                dragEnd.y = imgRect.height - Mathf.Clamp(dragEnd.y, 0, imgRect.height);

                dragEnd.x = Mathf.Round(dragEnd.x / zoom);

                dragEnd.y = Mathf.Round(dragEnd.y / zoom);

                Debug.Log("Draw Line");

                NumSamples = AntiAlias;

                if (stroke.enabled)
                {
                    baseTex = DrawLine(dragStart, dragEnd, lineTool.width, col, baseTex, true, col2, stroke.width);
                }
                else
                {
                    baseTex = DrawLine(dragStart, dragEnd, lineTool.width, col, baseTex);
                }
            }

            dragStart = Vector2.zero;

            dragEnd = Vector2.zero;
        }

        preDrag = dragEnd;
    }