Beispiel #1
0
        static Rect DrawMarker(P value, Vector2 startPos, Vector2 endPos, Vector2 size, Texture2D image, Color markerColor, float position = 0.75f)
        {
            Vector2 markerCenter = startPos + (endPos - startPos).normalized * position;
            float   rotation     = Util.GetAngle(endPos - startPos);
            var     markerRect   = Util.CenterRect(markerCenter, size);

            RelationDrawUtil.DrawRotatedTexture(image, markerCenter, size, rotation, markerColor);
            return(markerRect);
        }
Beispiel #2
0
        static Dictionary <Relation <T, P>, Rect> DrawSelfMarkers(IEnumerable <Relation <T, P> > edges, Vector2 circleCenter, float radius, float startAngle, float arcLength, Vector2 markerSize, Texture2D image, System.Func <P, Color> GetMarkerColor)
        {
            var markerDict = new Dictionary <Relation <T, P>, Rect>();

            if (!edges.Any())
            {
                return(markerDict);
            }

            var   edgeArray      = edges.ToArray();
            int   numEdges       = edgeArray.Length;
            float arcSegmentSize = arcLength / numEdges;

            for (int i = 0; i < numEdges; i++)
            {
                float angle    = startAngle + (i + 0.5f) * arcSegmentSize;
                var   position = Util.GetPositionOnCircle(angle) * radius + circleCenter;
                var   rotation = angle + Mathf.PI / 2;                  // circle tangent
                RelationDrawUtil.DrawRotatedTexture(image, position, markerSize, rotation, GetMarkerColor(edgeArray[i].Tag));
                var edge = edgeArray[i];
                markerDict[edge] = Util.CenterRect(position, markerSize);
            }
            return(markerDict);
        }