MCPcopy Create free account
hub / github.com/Tencent/libpag / readKeyframes

Function readKeyframes

web/lite/src/codec/attribute-helper.ts:165–189  ·  view source on GitHub ↗
(
  byteArray: ByteArray,
  config: BaseAttribute,
  flag: AttributeFlag,
)

Source from the content-addressed store, hash-verified

163};
164
165export const readKeyframes = <T>(
166 byteArray: ByteArray,
167 config: BaseAttribute,
168 flag: AttributeFlag,
169): Array<Keyframe<T>> => {
170 const keyframes: Array<any> = [];
171 const numFrames: number = byteArray.readEncodedUint32();
172 for (let i = 0; i < numFrames; i++) {
173 let keyframe: Keyframe<T>;
174 if (config.attributeType === AttributeType.DiscreteProperty) {
175 keyframe = new Keyframe<T>();
176 } else {
177 const interpolationType = byteArray.readUBits(2) as KeyframeInterpolationType;
178 if (interpolationType === KeyframeInterpolationType.Hold) {
179 keyframe = new Keyframe<T>();
180 } else {
181 keyframe = config.newKeyframe(flag);
182 keyframe.interpolationType = interpolationType;
183 }
184 }
185 keyframes.push(keyframe);
186 }
187
188 return keyframes;
189};
190
191const readTimeAndValue = <T>(byteArray: ByteArray, keyframes: Array<Keyframe<T>>, config: BaseAttribute) => {
192 const numFrames: number = keyframes.length;

Callers 1

readPropertyFunction · 0.85

Calls 3

readEncodedUint32Method · 0.45
readUBitsMethod · 0.45
newKeyframeMethod · 0.45

Tested by

no test coverage detected