Esempio n. 1
0
    public override void _Draw()
    {
        Vector2 mPos = GetGlobalMousePosition();

        if (mouseLeftPressed || mouseRightPressed)
        {
            mousePosTemp.Add(mPos);
            if (mousePosTemp.Count > 1)
            {
                var prevPos      = mousePosTemp[mousePosTemp.Count - 2];
                var bridgeVector = prevPos - mPos;
                var unit         = bridgeVector.Normalized();
                var len          = bridgeVector.Length();
                var spacing      = 1;
                for (int n = 0; n < (int)len; n += spacing)
                {
                    var drawPoint = mPos + unit * n;
                    lastDrawObject.addPoint(drawPoint);
                    lastDrawObject.Update();
                }
            }
            else
            {
                lastDrawObject.addPoint(mPos);
            }
        }
    }
Esempio n. 2
0
    public void startToConvertSprite()
    {
        xMin                -= 64;
        yMin                -= 64;
        xMax                += 64;
        yMax                += 64;
        captureViewport      = new Viewport();
        captureViewport.Size = new Vector2(xMax - xMin, yMax - yMin);
        captureViewport.RenderTargetUpdateMode = Viewport.UpdateMode.Always;
        captureViewport.RenderTargetClearMode  = Viewport.ClearMode.Always;
        captureViewport.TransparentBg          = true;
        captureViewport.Usage = Viewport.UsageEnum.Usage2d;
        GetTree().CurrentScene.AddChild(captureViewport);
        cloneDrawObject                = new drawObject();
        cloneDrawObject.pointList      = pointList;
        cloneDrawObject.brushColor     = brushColor;
        cloneDrawObject.brushIndexList = brushIndexList;
        cloneDrawObject.drawMode       = drawMode;
        cloneDrawObject.Position      -= new Vector2(xMin, yMin);
        captureViewport.AddChild(cloneDrawObject);
        cloneDrawObject.Update();

        cloneDrawObject.Connect("first_draw_ended", this, "finalToConvertSprite");

        //GetTree().CreateTimer(0.2f).Connect("timeout",this,"finalToConvertSprite");
    }