writePath method

int writePath(
  1. VectorGraphicsBuffer buffer,
  2. Uint8List controlTypes,
  3. Float32List controlPoints,
  4. int fillType, {
  5. bool half = false,
})

Write a new path to the buffer, returing the identifier assigned to it.

The fillType argument is either 1 for a fill or 0 for a stroke.

controlTypes is a buffer of the types of control points in order. controlPoints is a buffer of the control points in order.

If half is true, control points will be written to the buffer using half precision floating point values. This will reduce the binary size at the cost of reduced precision. This option defaults to false.

Implementation

int writePath(
  VectorGraphicsBuffer buffer,
  Uint8List controlTypes,
  Float32List controlPoints,
  int fillType, {
  bool half = false,
}) {
  buffer._checkPhase(_CurrentSection.paths);
  assert(buffer._nextPathId < kMaxId);

  final int id = buffer._nextPathId;
  buffer._nextPathId += 1;

  buffer._putUint8(half ? _pathTagHalfPrecision : _pathTag);
  buffer._putUint8(fillType);
  buffer._putUint16(id);
  buffer._putUint32(controlTypes.length);
  buffer._putUint8List(controlTypes);
  buffer._putUint32(controlPoints.length);
  if (half) {
    buffer._putUint16List(_encodeToHalfPrecision(controlPoints));
  } else {
    buffer._putFloat32List(controlPoints);
  }
  return id;
}