コード例 #1
0
    virtual public bool LineTo(float x, float y, FDrawingCursor previousCursor)
    {
        //Main line (no caps, caps are drawn on Flush, MoveTo)
        FDrawingQuad quad;

        quad = new FDrawingQuad(color);
        if (!quad.SetLineVertices(position, new Vector2(x, y), thickness, this))
        {
            return(false);
        }
        AddLineSideBorders(quad, quad);
        _quads.AddLast(quad);
        lineQuad = quad;

        lineFromValid    = true;
        lineFromPosition = position;
        position.x       = x;
        position.y       = y;

        if (previousCursor != null)
        {
            DrawJoint(previousCursor);
        }
        return(true);
    }
コード例 #2
0
    public virtual bool LineTo(float x,float y,FDrawingCursor previousCursor)
    {
        //Main line (no caps, caps are drawn on Flush, MoveTo)
        FDrawingQuad quad;
        quad=new FDrawingQuad(color);
        if (!quad.SetLineVertices(position,new Vector2(x,y),thickness,this)) {
            return false;
        }
        AddLineSideBorders(quad,quad);
        _quads.AddLast(quad);
        lineQuad=quad;
        /*
        if (color.a>=1) {
            quad=new FDrawingQuad(color);
            if (!quad.SetLineVertices(position,new Vector2(x,y),thickness,this)) {
                return false;
            }
            AddLineSideBorders(quad,quad);
            _quads.AddLast(quad);
            topQuad=quad;
            bottomQuad=null;
        } else {
            Vector2 lineTo=new Vector2(x,y);
            quad=new FDrawingQuad(color);
            if (!quad.SetLineVertices(this.position,lineTo,thickness,this)) {
                return false;
            }
            AddLineSideBorders(quad,quad);
            //split the quad in 2 parts (bottom and top)
            bottomQuad=new FDrawingQuad(color);
            bottomQuad.tlVertice=position;
            bottomQuad.blVertice=quad.blVertice;
            bottomQuad.trVertice=lineTo;
            bottomQuad.brVertice=quad.brVertice;
            //Debug
            //bottomQuad.blColor=new Color(1.0f,1.0f,1.0f,0.5f);
            //bottomQuad.tlColor=new Color(0.0f,0.0f,1.0f,0.5f);
            _quads.AddLast(bottomQuad);

            topQuad=quad;
            topQuad.blVertice=position;
            topQuad.brVertice=lineTo;
            //Debug
            //topQuad.blColor=new Color(1.0f,0.0f,0.0f,0.5f);
            //topQuad.tlColor=new Color(0.0f,0.0f,1.0f,0.5f);
            _quads.AddLast(topQuad);
        }
        */

        lineFromValid=true;
        lineFromPosition=position;
        position.x=x;
        position.y=y;

        if (previousCursor!=null) {
            DrawJoint(previousCursor);
        }
        return true;
    }
コード例 #3
0
    public virtual void DrawStartCap()
    {
        //Draw starting cap
        if (capType==FTDrawingCapStyle.SQUARE) {
            FDrawingQuad quad=new FDrawingQuad(color);
            quad.SetLineVertices(lineFromPosition-direction*thickness*0.5f,lineFromPosition,thickness,null);
            _quads.AddLast(quad);

            if ((borders!=null)&&(borders.Count>0)) {
                throw new FutileException("Cap type "+capType+" not suported with borders. "+supportedCapTypesWithBorders);
            }
        } else if (capType==FTDrawingCapStyle.TRIANGLE) {
            FDrawingQuad quad=new FDrawingQuad(color);
            Vector2 ortho=new Vector2(-direction.y,direction.x);
            quad.trVertice=lineFromPosition+ortho*thickness*0.5f;
            quad.brVertice=lineFromPosition-ortho*thickness*0.5f;
            quad.blVertice=lineFromPosition-direction*thickness*0.5f;
            quad.tlVertice=lineFromPosition-direction*thickness*0.5f;
            _quads.AddLast(quad);
            if ((borders!=null)&&(borders.Count>0)) {
                throw new FutileException("Cap type "+capType+" not suported with borders. "+supportedCapTypesWithBorders);
            }
        } else if (capType==FTDrawingCapStyle.ARROW) {
            FDrawingQuad quad;
            Vector2 ortho=new Vector2(-direction.y,direction.x);
            if (color.a>=1) {
                quad=new FDrawingQuad(color);
                quad.trVertice=lineFromPosition+ortho*thickness*1.0f+direction*thickness*0.5f;
                quad.brVertice=lineFromPosition-ortho*thickness*1.0f+direction*thickness*0.5f;;
                quad.blVertice=lineFromPosition-direction*thickness*0.5f;
                quad.tlVertice=lineFromPosition-direction*thickness*0.5f;
                _quads.AddLast(quad);
            } else {
                Vector2 A=lineFromPosition-direction*thickness*0.5f;

                quad=new FDrawingQuad(color);
                quad.tlVertice=lineFromPosition+ortho*thickness*0.5f;
                quad.blVertice=lineFromPosition+ortho*thickness*0.5f+direction*thickness*0.5f;
                quad.brVertice=lineFromPosition+ortho*thickness*1.0f+direction*thickness*0.5f;
                quad.trVertice=A;
                _quads.AddLast(quad);

                quad=new FDrawingQuad(color);
                quad.tlVertice=lineFromPosition-ortho*thickness*0.5f;
                quad.blVertice=lineFromPosition-ortho*thickness*0.5f+direction*thickness*0.5f;
                quad.brVertice=lineFromPosition-ortho*thickness*1.0f+direction*thickness*0.5f;
                quad.trVertice=A;
                _quads.AddLast(quad);

                quad=new FDrawingQuad(color);
                quad.tlVertice=lineFromPosition+ortho*thickness*0.5f;
                quad.blVertice=lineFromPosition-ortho*thickness*0.5f;
                quad.brVertice=A;
                quad.trVertice=A;
                _quads.AddLast(quad);
            }
            if ((borders!=null)&&(borders.Count>0)) {
                throw new FutileException("Cap type "+capType+" not suported with borders. "+supportedCapTypesWithBorders);
            }
        } else if (capType==FTDrawingCapStyle.ROUND) {
            Vector2 ortho=new Vector2(-direction.y,direction.x);
            int nbQuads=(int)(this.thickness*0.5f*Mathf.PI *0.5f *0.5f *0.5f)*2+2;
            float angle=0;
            //2 triangles by quads
            float deltaAngle=0.5f*Mathf.PI/nbQuads;
            for (int i=0;i<nbQuads;i++) {
                FDrawingQuad quad=new FDrawingQuad(color);
                quad.trVertice=lineFromPosition;
                quad.brVertice=lineFromPosition-ortho*thickness*0.5f*Mathf.Cos(angle)-direction*thickness*0.5f*Mathf.Sin(angle);
                angle+=deltaAngle;
                quad.blVertice=lineFromPosition-ortho*thickness*0.5f*Mathf.Cos(angle)-direction*thickness*0.5f*Mathf.Sin(angle);
                angle+=deltaAngle;
                quad.tlVertice=lineFromPosition-ortho*thickness*0.5f*Mathf.Cos(angle)-direction*thickness*0.5f*Mathf.Sin(angle);
                _quads.AddLast(quad);
            }

            if ((borders!=null)&&(borders.Count>0)) {
                throw new FutileException("Cap type "+capType+" not suported with borders. "+supportedCapTypesWithBorders);
            }
        }
    }
コード例 #4
0
ファイル: FDrawingSprite.cs プロジェクト: tanis2000/Futile
    public virtual bool LineTo(float x,float y,FDrawingCursor previousCursor)
    {
        //Main line (no caps, caps are drawn on Flush, MoveTo)
        FDrawingQuad quad;
        quad=new FDrawingQuad(color);
        if (!quad.SetLineVertices(position,new Vector2(x,y),thickness,this)) {
            return false;
        }
        AddLineSideBorders(quad,quad);
        _quads.AddLast(quad);
        lineQuad=quad;

        lineFromValid=true;
        lineFromPosition=position;
        position.x=x;
        position.y=y;

        if (previousCursor!=null) {
            DrawJoint(previousCursor);
        }
        return true;
    }
コード例 #5
0
    virtual public void DrawStartCap()
    {
        //Draw starting cap
        if (capType == FTDrawingCapStyle.SQUARE)
        {
            FDrawingQuad quad = new FDrawingQuad(color);
            quad.SetLineVertices(lineFromPosition - direction * thickness * 0.5f, lineFromPosition, thickness, null);
            _quads.AddLast(quad);

            if ((borders != null) && (borders.Count > 0))
            {
                throw new FutileException("Cap type " + capType + " not suported with borders. " + supportedCapTypesWithBorders);
            }
        }
        else if (capType == FTDrawingCapStyle.TRIANGLE)
        {
            FDrawingQuad quad  = new FDrawingQuad(color);
            Vector2      ortho = new Vector2(-direction.y, direction.x);
            quad.trVertice = lineFromPosition + ortho * thickness * 0.5f;
            quad.brVertice = lineFromPosition - ortho * thickness * 0.5f;
            quad.blVertice = lineFromPosition - direction * thickness * 0.5f;
            quad.tlVertice = lineFromPosition - direction * thickness * 0.5f;
            _quads.AddLast(quad);
            if ((borders != null) && (borders.Count > 0))
            {
                throw new FutileException("Cap type " + capType + " not suported with borders. " + supportedCapTypesWithBorders);
            }
        }
        else if (capType == FTDrawingCapStyle.ARROW)
        {
            FDrawingQuad quad;
            Vector2      ortho = new Vector2(-direction.y, direction.x);
            if (color.a >= 1)
            {
                quad           = new FDrawingQuad(color);
                quad.trVertice = lineFromPosition + ortho * thickness * 1.0f + direction * thickness * 0.5f;
                quad.brVertice = lineFromPosition - ortho * thickness * 1.0f + direction * thickness * 0.5f;;
                quad.blVertice = lineFromPosition - direction * thickness * 0.5f;
                quad.tlVertice = lineFromPosition - direction * thickness * 0.5f;
                _quads.AddLast(quad);
            }
            else
            {
                Vector2 A = lineFromPosition - direction * thickness * 0.5f;

                quad           = new FDrawingQuad(color);
                quad.tlVertice = lineFromPosition + ortho * thickness * 0.5f;
                quad.blVertice = lineFromPosition + ortho * thickness * 0.5f + direction * thickness * 0.5f;
                quad.brVertice = lineFromPosition + ortho * thickness * 1.0f + direction * thickness * 0.5f;
                quad.trVertice = A;
                _quads.AddLast(quad);

                quad           = new FDrawingQuad(color);
                quad.tlVertice = lineFromPosition - ortho * thickness * 0.5f;
                quad.blVertice = lineFromPosition - ortho * thickness * 0.5f + direction * thickness * 0.5f;
                quad.brVertice = lineFromPosition - ortho * thickness * 1.0f + direction * thickness * 0.5f;
                quad.trVertice = A;
                _quads.AddLast(quad);

                quad           = new FDrawingQuad(color);
                quad.tlVertice = lineFromPosition + ortho * thickness * 0.5f;
                quad.blVertice = lineFromPosition - ortho * thickness * 0.5f;
                quad.brVertice = A;
                quad.trVertice = A;
                _quads.AddLast(quad);
            }
            if ((borders != null) && (borders.Count > 0))
            {
                throw new FutileException("Cap type " + capType + " not suported with borders. " + supportedCapTypesWithBorders);
            }
        }
        else if (capType == FTDrawingCapStyle.ROUND)
        {
            Vector2 ortho   = new Vector2(-direction.y, direction.x);
            int     nbQuads = (int)(this.thickness * 0.5f * Mathf.PI * 0.5f * 0.5f * 0.5f) * 2 + 2;
            float   angle   = 0;
            //2 triangles by quads
            float deltaAngle = 0.5f * Mathf.PI / nbQuads;
            for (int i = 0; i < nbQuads; i++)
            {
                FDrawingQuad quad = new FDrawingQuad(color);
                quad.trVertice = lineFromPosition;
                quad.brVertice = lineFromPosition - ortho * thickness * 0.5f * Mathf.Cos(angle) - direction * thickness * 0.5f * Mathf.Sin(angle);
                angle         += deltaAngle;
                quad.blVertice = lineFromPosition - ortho * thickness * 0.5f * Mathf.Cos(angle) - direction * thickness * 0.5f * Mathf.Sin(angle);
                angle         += deltaAngle;
                quad.tlVertice = lineFromPosition - ortho * thickness * 0.5f * Mathf.Cos(angle) - direction * thickness * 0.5f * Mathf.Sin(angle);
                _quads.AddLast(quad);
            }

            if ((borders != null) && (borders.Count > 0))
            {
                throw new FutileException("Cap type " + capType + " not suported with borders. " + supportedCapTypesWithBorders);
            }
        }
    }