private void DashLine(GraphicsPathFP path, LineFP line) { if (_nextDistance < 0) { _nextDistance = _dashArray[_dashIndex]; _dashIndex = (_dashIndex + 1) % _dashArray.Length; } var distance = _nextDistance; var pt = line.GetPointAtDistance(distance); while (pt != null) { if (_isEmpty) { path.AddMoveTo(pt); } else { path.AddLineTo(pt); } _isEmpty = !_isEmpty; _nextDistance += _dashArray[_dashIndex]; distance = _nextDistance; pt = line.GetPointAtDistance(distance); _dashIndex = (_dashIndex + 1) % _dashArray.Length; } if (_isEmpty) { path.AddMoveTo(line.Pt2); } else { path.AddLineTo(line.Pt2); } _nextDistance = _nextDistance - line.GetLength(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * return the dashed path, if the dash array is null, return the path * unchanged. * @return the dash path. */ public GraphicsPathFP GetDashedGraphicsPath() { if (_dashArray == null) { return(_fromPath); } var dashedPath = new GraphicsPathFP(); var lineFP = new LineFP(); var j = 0; for (var i = 0; i < _cmdsSize; i++) { switch (_cmds[i]) { case CMD_MOVETO: dashedPath.AddMoveTo(_pnts[j++]); break; case CMD_LINETO: { int pointIndex = j; lineFP.Reset(_pnts[pointIndex - 1], _pnts[pointIndex]); DashLine(dashedPath, lineFP); j++; } break; case CMD_CLOSE: dashedPath.AddClose(); break; } } return(dashedPath); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * return the dashed path, if the dash array is null, return the path * unchanged. * @return the dash path. */ public GraphicsPathFP GetDashedGraphicsPath() { if (_dashArray == null) { return _fromPath; } var dashedPath = new GraphicsPathFP(); var lineFP = new LineFP(); var j = 0; for (var i = 0; i < _cmdsSize; i++) { switch (_cmds[i]) { case CMD_MOVETO: dashedPath.AddMoveTo(_pnts[j++]); break; case CMD_LINETO: { int pointIndex = j; lineFP.Reset(_pnts[pointIndex - 1], _pnts[pointIndex]); DashLine(dashedPath, lineFP); j++; } break; case CMD_CLOSE: dashedPath.AddClose(); break; } } return dashedPath; }