Skip to content

Tutorial_9(en US)

MikiraSora edited this page Jan 4, 2024 · 1 revision

Introduction & Principle

This SVG object is mainly divided into two types, one is an object based on .svg file (SvgImageFilePrefab); the other is an object that generates SVG objects based on text content (SvgStringPrefab).

  1. Get SVG content
  2. Parse the SVG content and get the SVG line segments their infomation about color
  3. Filter out inappropriate colors + corresponding line segments through object parameters
  4. For each group of line segments and corresponding line segments:
  • 4.1 Map this color to the corresponding lane type through object parameters
  • 4.2 Use different CurveInterpolaterFactory to generate line segment interpolators through object parameters, plug the line segment data into the interpolator, and obtain a series of straight lines from the latter
  • 4.3 Use the above series of straight lines to generate a lane set corresponding to the lane type
  1. Add the output to the fumen for display

Instructions

SvgImageFilePrefab:
1
SvgStringPrefab:
1

Explanation of some parameters

SvgPrefab general parameters:

  • ColorSimilar: Maps the original color of the SVG object to the color that the lane can display, then this parameter indicates the fault tolerance of the color mapping. The lower the parameter value, the less content that can be converted into a lane but the more precise it is.
  • CurveInterpolaterFactory: When generating lanes and outputting them to the editor, it is necessary to convert a series of (curved) line segments of the SVG object into straight lane objects. Then this parameter option will control how the editor generates lane objects. For example, the default implementation is to directly interpolate SVG objects and then directly convert them into corresponding objects for output; if you want to implement your own custom operations (such as limiting those points The abscissas are all integer values), you can implement a plug-in containing the ICurveInterpolaterFactory by yourself
  • EnableColorfulLaneSimilar: Whether to support ColorfulLane lane when color lane mapping. If unchecked, only red, green and blue lanes will be considered.
  • Opacity: Transparency, only used to assist the display of SVG objects, and will not affect the lane output function.
  • ShowOriginColor: Whether to display the SVG object color instead of the color after color mapping.
  • Tolerance: It can be simply understood as the degree of simplification of SVG line segments. The lower the value, the closer it is to the original appearance of the SVG object. The more lane objects are generated, the longer it takes to generate lane output.

SvgStringPrefab parameters:

  • TypefaceName: font name, for example "Consolas"
  • FontSize: There is no substantial difference between font size and Scale. FontSize is used when generating SVG objects, and Scale is used for direct scaling after generating SVG.

SvgImageFilePrefab parameters:

  • SvgFile: Need to provide a formal .svg file
Clone this wiki locally