BNBEffect

Objective-C

@interface BNBEffect : NSObject

/** Thread-safe. May be called from any thread */
- (nonnull NSString *)url;

/**
 * Call js method in effect. 
 * @param methodName JS global function name. Member functions are not supported.
 * @param params Function arguments.
 * @depreacted Use `evalJs` instead.
 */
- (void)callJsMethod:(nonnull NSString *)methodName
              params:(nonnull NSString *)params;

/**
 * Evaluate the `script` in effect. This method is thread safe.
 * @param sctipt JS string to execute 
 * @param js_callback Callback for result, will be called in render thread.
 */
- (void)evalJs:(nonnull NSString *)script
resultCallback:(nullable id<BNBJsCallback>)resultCallback;

/**
 * Evaluate the `script` in effect.
 * MUST be called from the render thread
 * @param sctipt JS string to execute 
 * @return JS evaluation result
 */
- (nonnull NSString *)evalJsSync:(nonnull NSString *)script;

/**
 * Reset effect state
 * MUST be called from the render thread
 */
- (void)reset;

/**
 * Update effect state (evaluate scheduled JS calls)
 * MUST be called from the render thread
 */
- (void)update;

/**
 * Deserialize effect from the provided `resoved_url`. If `configOverride` is an
 * empty string, will use `config.json` under provided `resolvedUrl`, otherwise
 * content of `configOverride` will be used.
 * 
 * Can be called from any thread.
 */
- (void)deserialize:(nonnull NSString *)resolvedUrl
     configOverride:(nonnull NSString *)configOverride;

/**
 * activate current effect
 * MUST be called from the render thread for OpenGL backends.
 */
- (void)activate:(int32_t)fxWidth
        fxHeight:(int32_t)fxHeight
    surfaceWidth:(int32_t)surfaceWidth
   surfaceHeight:(int32_t)surfaceHeight;

- (void)dumpFs:(nonnull NSString *)outDir;

- (void)dump;

- (nonnull NSString *)dumpJson;

- (BNBEffectStatus)status;

@end

Swift

class BNBEffect : NSObject

Undocumented

  • Thread-safe. May be called from any thread

    Declaration

    Objective-C

    - (nonnull NSString *)url;

    Swift

    func url() -> String
  • Call js method in effect.

    Declaration

    Objective-C

    - (void)callJsMethod:(nonnull NSString *)methodName
                  params:(nonnull NSString *)params;

    Swift

    func callJsMethod(_ methodName: String, params: String)

    Parameters

    methodName

    JS global function name. Member functions are not supported.

    params

    Function arguments. @depreacted Use evalJs instead.

  • Evaluate the script in effect. This method is thread safe.

    Declaration

    Objective-C

    - (void)evalJs:(nonnull NSString *)script
        resultCallback:(nullable id<BNBJsCallback>)resultCallback;

    Swift

    func evalJs(_ script: String, resultCallback: BNBJsCallback?)

    Parameters

    sctipt

    JS string to execute

    js_callback

    Callback for result, will be called in render thread.

  • Evaluate the script in effect. MUST be called from the render thread

    Declaration

    Objective-C

    - (nonnull NSString *)evalJsSync:(nonnull NSString *)script;

    Swift

    func evalJsSync(_ script: String) -> String

    Parameters

    sctipt

    JS string to execute

    Return Value

    JS evaluation result

  • Reset effect state MUST be called from the render thread

    Declaration

    Objective-C

    - (void)reset;

    Swift

    func reset()
  • Update effect state (evaluate scheduled JS calls) MUST be called from the render thread

    Declaration

    Objective-C

    - (void)update;

    Swift

    func update()
  • Deserialize effect from the provided resoved_url. If configOverride is an empty string, will use config.json under provided resolvedUrl, otherwise content of configOverride will be used.

    Can be called from any thread.

    Declaration

    Objective-C

    - (void)deserialize:(nonnull NSString *)resolvedUrl
         configOverride:(nonnull NSString *)configOverride;

    Swift

    func deserialize(_ resolvedUrl: String, configOverride: String)
  • activate current effect MUST be called from the render thread for OpenGL backends.

    Declaration

    Objective-C

    - (void)activate:(int32_t)fxWidth
             fxHeight:(int32_t)fxHeight
         surfaceWidth:(int32_t)surfaceWidth
        surfaceHeight:(int32_t)surfaceHeight;

    Swift

    func activate(_ fxWidth: Int32, fxHeight: Int32, surfaceWidth: Int32, surfaceHeight: Int32)
  • Undocumented

    Declaration

    Objective-C

    - (void)dumpFs:(nonnull NSString *)outDir;

    Swift

    func dumpFs(_ outDir: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)dump;

    Swift

    func dump()
  • Undocumented

    Declaration

    Objective-C

    - (nonnull NSString *)dumpJson;

    Swift

    func dumpJson() -> String
  • Undocumented

    Declaration

    Objective-C

    - (BNBEffectStatus)status;

    Swift

    func status() -> BNBEffectStatus