mirror of
https://github.com/rive-app/rive-ios.git
synced 2026-01-18 17:11:28 +01:00
Initial commit of the iOS runtime
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,8 @@
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
.DS_Store
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
|
||||
BIN
Example-iOS/Assets/bird.riv
Normal file
BIN
Example-iOS/Assets/bird.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/blend.riv
Normal file
BIN
Example-iOS/Assets/blend.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/funtime.riv
Normal file
BIN
Example-iOS/Assets/funtime.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/juice.riv
Normal file
BIN
Example-iOS/Assets/juice.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/simple.riv
Normal file
BIN
Example-iOS/Assets/simple.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/truck.riv
Normal file
BIN
Example-iOS/Assets/truck.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/van.riv
Normal file
BIN
Example-iOS/Assets/van.riv
Normal file
Binary file not shown.
472
Example-iOS/RiveExample.xcodeproj/project.pbxproj
Normal file
472
Example-iOS/RiveExample.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,472 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
C9696B1224FC704A0041502A /* juice.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9696B1124FC704A0041502A /* juice.riv */; };
|
||||
C9696B1524FC71CE0041502A /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9696B1424FC71CE0041502A /* Utilities.swift */; };
|
||||
C970484A250822F300CB3AB3 /* simple.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9704847250822F300CB3AB3 /* simple.riv */; };
|
||||
C98F298B2513FD8C0076E802 /* blend.riv in Resources */ = {isa = PBXBuildFile; fileRef = C98F29882513FD8C0076E802 /* blend.riv */; };
|
||||
C9927C1B250986BF009F17F5 /* truck.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9927C18250986BF009F17F5 /* truck.riv */; };
|
||||
C99E2FE3251E8DB4009227CA /* van.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE0251E8DB4009227CA /* van.riv */; };
|
||||
C99E2FE8251E8E35009227CA /* bird.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE6251E8E35009227CA /* bird.riv */; };
|
||||
C99E2FE9251E8E35009227CA /* funtime.riv in Resources */ = {isa = PBXBuildFile; fileRef = C99E2FE7251E8E35009227CA /* funtime.riv */; };
|
||||
C9C73E9824FC471E00EF9516 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9724FC471E00EF9516 /* AppDelegate.swift */; };
|
||||
C9C73E9A24FC471E00EF9516 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */; };
|
||||
C9C73E9C24FC471E00EF9516 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9C73E9B24FC471E00EF9516 /* ContentView.swift */; };
|
||||
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9C73E9D24FC471E00EF9516 /* Assets.xcassets */; };
|
||||
C9C73EA124FC471E00EF9516 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9C73EA024FC471E00EF9516 /* Preview Assets.xcassets */; };
|
||||
C9C73EA424FC471E00EF9516 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9C73EA224FC471E00EF9516 /* LaunchScreen.storyboard */; };
|
||||
C9E1AA45251E957F00BD52EC /* RiveRuntime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */; };
|
||||
C9E1AA46251E957F00BD52EC /* RiveRuntime.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
C9E1AA3D251E94CC00BD52EC /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = C9C73ED124FC478800EF9516;
|
||||
remoteInfo = RiveRuntime;
|
||||
};
|
||||
C9E1AA3F251E94CC00BD52EC /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = C9C73EDA24FC478900EF9516;
|
||||
remoteInfo = RiveRuntimeTests;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
C9C7420224FC53CF00EF9516 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
C9E1AA46251E957F00BD52EC /* RiveRuntime.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
C9696B1124FC704A0041502A /* juice.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = juice.riv; sourceTree = "<group>"; };
|
||||
C9696B1424FC71CE0041502A /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = "<group>"; };
|
||||
C9704847250822F300CB3AB3 /* simple.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = simple.riv; sourceTree = "<group>"; };
|
||||
C98F29882513FD8C0076E802 /* blend.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = blend.riv; sourceTree = "<group>"; };
|
||||
C9927C18250986BF009F17F5 /* truck.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = truck.riv; sourceTree = "<group>"; };
|
||||
C99E2FE0251E8DB4009227CA /* van.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = van.riv; sourceTree = "<group>"; };
|
||||
C99E2FE6251E8E35009227CA /* bird.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = bird.riv; sourceTree = "<group>"; };
|
||||
C99E2FE7251E8E35009227CA /* funtime.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = funtime.riv; sourceTree = "<group>"; };
|
||||
C9C73E9424FC471E00EF9516 /* RiveExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RiveExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C9C73E9724FC471E00EF9516 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
C9C73E9B24FC471E00EF9516 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
C9C73E9D24FC471E00EF9516 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
C9C73EA024FC471E00EF9516 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
C9C73EA324FC471E00EF9516 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
C9C73EA524FC471E00EF9516 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RiveRuntime.xcodeproj; path = ../RiveRuntime.xcodeproj; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
C9C73E9124FC471E00EF9516 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C9E1AA45251E957F00BD52EC /* RiveRuntime.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
C9696B0E24FC6FD10041502A /* Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C99E2FE6251E8E35009227CA /* bird.riv */,
|
||||
C99E2FE7251E8E35009227CA /* funtime.riv */,
|
||||
C99E2FE0251E8DB4009227CA /* van.riv */,
|
||||
C98F29882513FD8C0076E802 /* blend.riv */,
|
||||
C9927C18250986BF009F17F5 /* truck.riv */,
|
||||
C9704847250822F300CB3AB3 /* simple.riv */,
|
||||
C9696B1124FC704A0041502A /* juice.riv */,
|
||||
);
|
||||
path = Assets;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9696B1324FC71B80041502A /* Helpers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9696B1424FC71CE0041502A /* Utilities.swift */,
|
||||
);
|
||||
path = Helpers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9C73E8B24FC471E00EF9516 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */,
|
||||
C9696B0E24FC6FD10041502A /* Assets */,
|
||||
C9C73E9624FC471E00EF9516 /* Source */,
|
||||
C9C73E9524FC471E00EF9516 /* Products */,
|
||||
C9C741FF24FC53CF00EF9516 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9C73E9524FC471E00EF9516 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9C73E9424FC471E00EF9516 /* RiveExample.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9C73E9624FC471E00EF9516 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9696B1324FC71B80041502A /* Helpers */,
|
||||
C9C73E9724FC471E00EF9516 /* AppDelegate.swift */,
|
||||
C9C73E9924FC471E00EF9516 /* SceneDelegate.swift */,
|
||||
C9C73E9B24FC471E00EF9516 /* ContentView.swift */,
|
||||
C9C73E9D24FC471E00EF9516 /* Assets.xcassets */,
|
||||
C9C73EA224FC471E00EF9516 /* LaunchScreen.storyboard */,
|
||||
C9C73EA524FC471E00EF9516 /* Info.plist */,
|
||||
C9C73E9F24FC471E00EF9516 /* Preview Content */,
|
||||
);
|
||||
path = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9C73E9F24FC471E00EF9516 /* Preview Content */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9C73EA024FC471E00EF9516 /* Preview Assets.xcassets */,
|
||||
);
|
||||
path = "Preview Content";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9C741FF24FC53CF00EF9516 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C9E1AA39251E94CC00BD52EC /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */,
|
||||
C9E1AA40251E94CC00BD52EC /* RiveRuntimeTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
C9C73E9324FC471E00EF9516 /* RiveExample */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C9C73EBE24FC471E00EF9516 /* Build configuration list for PBXNativeTarget "RiveExample" */;
|
||||
buildPhases = (
|
||||
C9C73E9024FC471E00EF9516 /* Sources */,
|
||||
C9C73E9124FC471E00EF9516 /* Frameworks */,
|
||||
C9C73E9224FC471E00EF9516 /* Resources */,
|
||||
C9C7420224FC53CF00EF9516 /* Embed Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = RiveExample;
|
||||
productName = RiveExample;
|
||||
productReference = C9C73E9424FC471E00EF9516 /* RiveExample.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
C9C73E8C24FC471E00EF9516 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1160;
|
||||
LastUpgradeCheck = 1200;
|
||||
ORGANIZATIONNAME = Rive;
|
||||
TargetAttributes = {
|
||||
C9C73E9324FC471E00EF9516 = {
|
||||
CreatedOnToolsVersion = 11.6;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = C9C73E8F24FC471E00EF9516 /* Build configuration list for PBXProject "RiveExample" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = C9C73E8B24FC471E00EF9516;
|
||||
productRefGroup = C9C73E9524FC471E00EF9516 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = C9E1AA39251E94CC00BD52EC /* Products */;
|
||||
ProjectRef = C9E1AA38251E94CC00BD52EC /* RiveRuntime.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
C9C73E9324FC471E00EF9516 /* RiveExample */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
C9E1AA3E251E94CC00BD52EC /* RiveRuntime.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = RiveRuntime.framework;
|
||||
remoteRef = C9E1AA3D251E94CC00BD52EC /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
C9E1AA40251E94CC00BD52EC /* RiveRuntimeTests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = RiveRuntimeTests.xctest;
|
||||
remoteRef = C9E1AA3F251E94CC00BD52EC /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
C9C73E9224FC471E00EF9516 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C99E2FE9251E8E35009227CA /* funtime.riv in Resources */,
|
||||
C98F298B2513FD8C0076E802 /* blend.riv in Resources */,
|
||||
C9696B1224FC704A0041502A /* juice.riv in Resources */,
|
||||
C9C73EA424FC471E00EF9516 /* LaunchScreen.storyboard in Resources */,
|
||||
C99E2FE3251E8DB4009227CA /* van.riv in Resources */,
|
||||
C99E2FE8251E8E35009227CA /* bird.riv in Resources */,
|
||||
C9C73EA124FC471E00EF9516 /* Preview Assets.xcassets in Resources */,
|
||||
C970484A250822F300CB3AB3 /* simple.riv in Resources */,
|
||||
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */,
|
||||
C9927C1B250986BF009F17F5 /* truck.riv in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C9C73E9024FC471E00EF9516 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C9C73E9824FC471E00EF9516 /* AppDelegate.swift in Sources */,
|
||||
C9C73E9A24FC471E00EF9516 /* SceneDelegate.swift in Sources */,
|
||||
C9696B1524FC71CE0041502A /* Utilities.swift in Sources */,
|
||||
C9C73E9C24FC471E00EF9516 /* ContentView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
C9C73EA224FC471E00EF9516 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
C9C73EA324FC471E00EF9516 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C9C73EBC24FC471E00EF9516 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C9C73EBD24FC471E00EF9516 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C9C73EBF24FC471E00EF9516 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Source/Preview Content\"";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = Source/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = rive.app.ios.runtime.example.RiveExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C9C73EC024FC471E00EF9516 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Source/Preview Content\"";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = Source/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = rive.app.ios.runtime.example.RiveExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C9C73E8F24FC471E00EF9516 /* Build configuration list for PBXProject "RiveExample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C9C73EBC24FC471E00EF9516 /* Debug */,
|
||||
C9C73EBD24FC471E00EF9516 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C9C73EBE24FC471E00EF9516 /* Build configuration list for PBXNativeTarget "RiveExample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C9C73EBF24FC471E00EF9516 /* Debug */,
|
||||
C9C73EC024FC471E00EF9516 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = C9C73E8C24FC471E00EF9516 /* Project object */;
|
||||
}
|
||||
7
Example-iOS/RiveExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
Example-iOS/RiveExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:RiveExample.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
37
Example-iOS/Source/AppDelegate.swift
Normal file
37
Example-iOS/Source/AppDelegate.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
6
Example-iOS/Source/Assets.xcassets/Contents.json
Normal file
6
Example-iOS/Source/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
25
Example-iOS/Source/Base.lproj/LaunchScreen.storyboard
Normal file
25
Example-iOS/Source/Base.lproj/LaunchScreen.storyboard
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
25
Example-iOS/Source/ContentView.swift
Normal file
25
Example-iOS/Source/ContentView.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import RiveRuntime
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
// Text("Hello, World!")
|
||||
MyRive()
|
||||
}
|
||||
}
|
||||
|
||||
struct MyRive: UIViewControllerRepresentable {
|
||||
func makeUIViewController(context: Context) -> RiveViewController {
|
||||
return RiveViewController(resource: "truck", withExtension: "riv")
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: RiveViewController, context: Context) {}
|
||||
}
|
||||
31
Example-iOS/Source/Helpers/Utilities.swift
Normal file
31
Example-iOS/Source/Helpers/Utilities.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Utilities.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
func loadBytesFromFile(forResource res: String, withExtension ext: String) -> Data?
|
||||
{
|
||||
guard let fileURL = Bundle.main.url(forResource: res, withExtension: ext) else {
|
||||
print("Failed to create URL for file.")
|
||||
return nil
|
||||
}
|
||||
do {
|
||||
let data = try Data(contentsOf: fileURL)
|
||||
return data
|
||||
}
|
||||
catch {
|
||||
print("Error opening file: \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension Data {
|
||||
var bytes : [UInt8]{
|
||||
return [UInt8](self)
|
||||
}
|
||||
}
|
||||
60
Example-iOS/Source/Info.plist
Normal file
60
Example-iOS/Source/Info.plist
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
64
Example-iOS/Source/SceneDelegate.swift
Normal file
64
Example-iOS/Source/SceneDelegate.swift
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// SceneDelegate.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
import RiveRuntime
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
// Create the SwiftUI view that provides the window contents.
|
||||
let contentView = ContentView()
|
||||
|
||||
// Use a UIHostingController as window root view controller.
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = UIHostingController(rootView: contentView)
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1638
RiveRuntime.xcodeproj/project.pbxproj
Normal file
1638
RiveRuntime.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
7
RiveRuntime.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
RiveRuntime.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:RiveRuntime.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
22
RiveRuntimeTests/Info.plist
Normal file
22
RiveRuntimeTests/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
37
RiveRuntimeTests/RiveRuntimeTests.m
Normal file
37
RiveRuntimeTests/RiveRuntimeTests.m
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RiveRuntimeTests.m
|
||||
// RiveRuntimeTests
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface RiveRuntimeTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation RiveRuntimeTests
|
||||
|
||||
- (void)setUp {
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
- (void)testExample {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
- (void)testPerformanceExample {
|
||||
// This is an example of a performance test case.
|
||||
[self measureBlock:^{
|
||||
// Put the code you want to measure the time of here.
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
22
Source/Info.plist
Normal file
22
Source/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
97
Source/RiveKit/Rive.h
Normal file
97
Source/RiveKit/Rive.h
Normal file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// RiveFile.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Different fits for rendering a Rive animation in a View
|
||||
typedef NS_ENUM(NSInteger, Fit) {
|
||||
Fill,
|
||||
Contain,
|
||||
Cover,
|
||||
FitHeight,
|
||||
FitWidth,
|
||||
ScaleDown,
|
||||
None
|
||||
};
|
||||
|
||||
// Different alignments for rendering a Rive animation in a View
|
||||
typedef NS_ENUM(NSInteger, Alignment) {
|
||||
TopLeft,
|
||||
TopCenter,
|
||||
TopRight,
|
||||
CenterLeft,
|
||||
Center,
|
||||
CenterRight,
|
||||
BottomLeft,
|
||||
BottomCenter,
|
||||
BottomRight
|
||||
};
|
||||
|
||||
// Result of file importing
|
||||
typedef NS_ENUM(NSInteger, ImportResult) {
|
||||
success,
|
||||
unsupportedVersion,
|
||||
malformed
|
||||
};
|
||||
|
||||
@class RiveArtboard;
|
||||
|
||||
// Linear animation instance wrapper
|
||||
@interface RiveLinearAnimationInstance : NSObject
|
||||
|
||||
-(void) applyTo:(RiveArtboard*) artboard;
|
||||
-(void) advanceBy:(double)elapsedSeconds;
|
||||
|
||||
@end
|
||||
|
||||
// Animation wrapper
|
||||
@interface RiveAnimation : NSObject
|
||||
|
||||
- (NSString *) name;
|
||||
-(RiveLinearAnimationInstance *) instance;
|
||||
|
||||
@end
|
||||
|
||||
// Render wrapper
|
||||
@interface RiveRenderer : NSObject
|
||||
|
||||
-(instancetype) initWithContext:(nonnull CGContextRef) context;
|
||||
-(void) alignWithRect:(CGRect)rect withContentRect:(CGRect)contentRect withAlignment:(Alignment)alignment withFit:(Fit)fit;
|
||||
|
||||
@end
|
||||
|
||||
// Artboard wrapper
|
||||
@interface RiveArtboard : NSObject
|
||||
|
||||
-(NSString *) name;
|
||||
-(CGRect) bounds;
|
||||
-(NSInteger) animationCount;
|
||||
-(RiveAnimation *) animationAt:(NSInteger)index;
|
||||
-(void) advanceBy:(double)elapsedSeconds;
|
||||
-(void) draw:(RiveRenderer *)renderer;
|
||||
|
||||
@end
|
||||
|
||||
// File wrapper
|
||||
@interface RiveFile : NSObject
|
||||
|
||||
@property (class, readonly) uint majorVersion;
|
||||
@property (class, readonly) uint minorVersion;
|
||||
|
||||
+ (ImportResult) import:(nonnull UInt8*)bytes bytesLength:(UInt64)length toFile:(nonnull RiveFile*)riveFile;
|
||||
|
||||
// Wraps: Artboard* artboard() const;
|
||||
- (RiveArtboard *) artboard;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
243
Source/RiveKit/Rive.mm
Normal file
243
Source/RiveKit/Rive.mm
Normal file
@@ -0,0 +1,243 @@
|
||||
//
|
||||
// RiveFile.m
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Rive.h"
|
||||
#import "RiveRenderer.hpp"
|
||||
|
||||
#import "file.hpp"
|
||||
#import "artboard.hpp"
|
||||
#import "animation.hpp"
|
||||
#import "linear_animation.hpp"
|
||||
#import "linear_animation_instance.hpp"
|
||||
|
||||
|
||||
@interface RiveLinearAnimationInstance()
|
||||
-(instancetype) initWithAnimation:(rive::Animation *) riveAnimation;
|
||||
@end
|
||||
|
||||
@interface RiveAnimation ()
|
||||
-(instancetype) initWithAnimation:(rive::Animation *) riveAnimation;
|
||||
@end
|
||||
|
||||
@interface RiveArtboard ()
|
||||
@property (nonatomic, readonly) rive::Artboard* artboard;
|
||||
-(instancetype) initWithArtboard:(rive::Artboard *) riveArtboard;
|
||||
@end
|
||||
|
||||
@interface RiveRenderer ()
|
||||
@property (nonatomic, readonly) rive::Renderer* renderer;
|
||||
-(rive::Renderer *) renderer;
|
||||
@end
|
||||
|
||||
// RIVE RENDERER
|
||||
|
||||
@implementation RiveRenderer
|
||||
|
||||
CGContextRef ctx;
|
||||
|
||||
-(instancetype) initWithContext:(CGContextRef) context {
|
||||
if (self = [super init]) {
|
||||
ctx = context;
|
||||
_renderer = new rive::NewRiveRenderer(context);
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) alignWithRect:(CGRect)rect withContentRect:(CGRect)contentRect withAlignment:(Alignment)alignment withFit:(Fit)fit {
|
||||
// NSLog(@"Rect in align %@", NSStringFromCGRect(rect));
|
||||
|
||||
// Calculate the AABBs
|
||||
rive::AABB frame = rive::AABB(rect.origin.x, rect.origin.y, rect.size.width + rect.origin.x, rect.size.height + rect.origin.y);
|
||||
rive::AABB content = rive::AABB(contentRect.origin.x, contentRect.origin.y, contentRect.size.width + contentRect.origin.x, rect.size.height + rect.origin.y);
|
||||
|
||||
// Work out the fit
|
||||
rive::Fit riveFit;
|
||||
switch(fit) {
|
||||
case Fill:
|
||||
riveFit = rive::Fit::fill;
|
||||
break;
|
||||
case Contain:
|
||||
riveFit = rive::Fit::contain;
|
||||
break;
|
||||
case Cover:
|
||||
riveFit = rive::Fit::cover;
|
||||
break;
|
||||
case FitHeight:
|
||||
riveFit = rive::Fit::fitHeight;
|
||||
break;
|
||||
case FitWidth:
|
||||
riveFit = rive::Fit::fitWidth;
|
||||
break;
|
||||
case ScaleDown:
|
||||
riveFit = rive::Fit::scaleDown;
|
||||
break;
|
||||
case None:
|
||||
riveFit = rive::Fit::none;
|
||||
break;
|
||||
}
|
||||
|
||||
// Work out the alignment
|
||||
rive::Alignment riveAlignment = rive::Alignment(.0, .0);
|
||||
switch(alignment) {
|
||||
case TopLeft:
|
||||
riveAlignment = rive::Alignment::topLeft;
|
||||
break;
|
||||
case TopCenter:
|
||||
riveAlignment = rive::Alignment::topCenter;
|
||||
break;
|
||||
case TopRight:
|
||||
riveAlignment = rive::Alignment::topRight;
|
||||
break;
|
||||
case CenterLeft:
|
||||
riveAlignment = rive::Alignment::centerLeft;
|
||||
break;
|
||||
case Center:
|
||||
riveAlignment = rive::Alignment::center;
|
||||
break;
|
||||
case CenterRight:
|
||||
riveAlignment = rive::Alignment::centerRight;
|
||||
break;
|
||||
case BottomLeft:
|
||||
riveAlignment = rive::Alignment::bottomLeft;
|
||||
break;
|
||||
case BottomCenter:
|
||||
riveAlignment = rive::Alignment::bottomCenter;
|
||||
break;
|
||||
case BottomRight:
|
||||
riveAlignment = rive::Alignment::bottomRight;
|
||||
break;
|
||||
}
|
||||
|
||||
_renderer->align(riveFit, riveAlignment, frame, content);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// RIVE FILE
|
||||
|
||||
@implementation RiveFile
|
||||
|
||||
rive::File *file;
|
||||
|
||||
+ (uint) majorVersion { return UInt8(rive::File::majorVersion); }
|
||||
+ (uint) minorVersion { return UInt8(rive::File::minorVersion); }
|
||||
|
||||
// Imports a Rive file, through a parameter reference
|
||||
+ (ImportResult) import:(nonnull UInt8 *)bytes bytesLength:(UInt64)length toFile:(nonnull RiveFile *)riveFile {
|
||||
rive::BinaryReader reader = rive::BinaryReader(bytes, length);
|
||||
rive::ImportResult result = rive::File::import(reader, &file);
|
||||
if (result == rive::ImportResult::success) {
|
||||
return success;
|
||||
}
|
||||
return malformed;
|
||||
}
|
||||
|
||||
- (RiveArtboard *) artboard {
|
||||
return [[RiveArtboard alloc] initWithArtboard: file->artboard()];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// RIVE ARTBOARD
|
||||
|
||||
@implementation RiveArtboard
|
||||
|
||||
// rive::Artboard *artboard;
|
||||
|
||||
-(instancetype) initWithArtboard:(rive::Artboard *) riveArtboard {
|
||||
if (self = [super init]) {
|
||||
_artboard = riveArtboard;
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger) animationCount {
|
||||
return _artboard->animationCount();
|
||||
}
|
||||
|
||||
-(RiveAnimation *) animationAt:(NSInteger) index {
|
||||
if (index >= [self animationCount]) {
|
||||
return nil;
|
||||
}
|
||||
return [[RiveAnimation alloc] initWithAnimation: _artboard->animation(index)];
|
||||
}
|
||||
|
||||
-(void) advanceBy:(double) elapsedSeconds {
|
||||
_artboard->advance(elapsedSeconds);
|
||||
}
|
||||
|
||||
-(void) draw:(RiveRenderer *) renderer {
|
||||
_artboard->draw([renderer renderer]);
|
||||
}
|
||||
|
||||
-(NSString *) name {
|
||||
return [NSString stringWithUTF8String:_artboard->name().c_str()];
|
||||
}
|
||||
|
||||
-(CGRect) bounds {
|
||||
rive::AABB aabb = _artboard->bounds();
|
||||
return CGRectMake(aabb.minX, aabb.minY, aabb.width(), aabb.height());
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// RIVE ANIMATION
|
||||
|
||||
@implementation RiveAnimation
|
||||
|
||||
rive::Animation *animation;
|
||||
|
||||
-(instancetype) initWithAnimation:(rive::Animation *) riveAnimation {
|
||||
if (self = [super init]) {
|
||||
animation = riveAnimation;
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) name {
|
||||
std::string str = animation->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
-(RiveLinearAnimationInstance *) instance {
|
||||
return [[RiveLinearAnimationInstance alloc] initWithAnimation: animation];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// RIVE LINEAR ANIMATION INSTANCE
|
||||
|
||||
@implementation RiveLinearAnimationInstance
|
||||
|
||||
rive::LinearAnimationInstance *instance;
|
||||
|
||||
-(instancetype) initWithAnimation:(rive::Animation *) riveAnimation {
|
||||
if (self = [super init]) {
|
||||
|
||||
instance = new rive::LinearAnimationInstance(reinterpret_cast<rive::LinearAnimation *>(riveAnimation));
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) applyTo:(RiveArtboard*) artboard {
|
||||
instance->apply(artboard.artboard);
|
||||
}
|
||||
|
||||
-(void) advanceBy:(double)elapsedSeconds {
|
||||
instance->advance(elapsedSeconds);
|
||||
}
|
||||
|
||||
@end
|
||||
162
Source/RiveKit/RiveRenderer.hpp
Normal file
162
Source/RiveKit/RiveRenderer.hpp
Normal file
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// RiveRenderer.hpp
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef rive_renderer_hpp
|
||||
#define rive_renderer_hpp
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <vector>
|
||||
|
||||
#import "renderer.hpp"
|
||||
|
||||
namespace rive
|
||||
{
|
||||
|
||||
enum class RiveGradient
|
||||
{
|
||||
None,
|
||||
Linear,
|
||||
Radial
|
||||
};
|
||||
|
||||
enum class RivePaintStyle
|
||||
{
|
||||
None,
|
||||
Stroke,
|
||||
Fill
|
||||
};
|
||||
|
||||
enum class RiveStrokeJoin
|
||||
{
|
||||
None,
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
};
|
||||
|
||||
enum class RiveStrokeCap
|
||||
{
|
||||
None,
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
};
|
||||
|
||||
enum class RiveBlendMode : unsigned int
|
||||
{
|
||||
None = 0,
|
||||
SrcOver = static_cast<int>(BlendMode::srcOver),
|
||||
Screen = static_cast<int>(BlendMode::screen),
|
||||
Overlay = static_cast<int>(BlendMode::overlay),
|
||||
Darken = static_cast<int>(BlendMode::darken),
|
||||
Lighten = static_cast<int>(BlendMode::lighten),
|
||||
ColorDodge = static_cast<int>(BlendMode::colorDodge),
|
||||
ColorBurn = static_cast<int>(BlendMode::colorBurn),
|
||||
HardLight = static_cast<int>(BlendMode::hardLight),
|
||||
SoftLight = static_cast<int>(BlendMode::softLight),
|
||||
Difference = static_cast<int>(BlendMode::difference),
|
||||
Exclusion = static_cast<int>(BlendMode::exclusion),
|
||||
Multiply = static_cast<int>(BlendMode::multiply),
|
||||
Hue = static_cast<int>(BlendMode::hue),
|
||||
Saturation = static_cast<int>(BlendMode::saturation),
|
||||
Color = static_cast<int>(BlendMode::color),
|
||||
Luminosity = static_cast<int>(BlendMode::luminosity)
|
||||
};
|
||||
|
||||
|
||||
class RiveRenderPaint : public RenderPaint
|
||||
{
|
||||
private:
|
||||
public:
|
||||
CGColorRef cgColor = NULL;
|
||||
RivePaintStyle paintStyle = RivePaintStyle::None;
|
||||
RiveStrokeJoin strokeJoin = RiveStrokeJoin::None;
|
||||
RiveStrokeCap strokeCap = RiveStrokeCap::None;
|
||||
RiveBlendMode currentBlendMode;
|
||||
float paintThickness;
|
||||
|
||||
// Gradient
|
||||
RiveGradient gradient = RiveGradient::None;
|
||||
CGPoint gradientStart;
|
||||
CGPoint gradientEnd;
|
||||
std::vector<CGFloat> colorStops;
|
||||
std::vector<CGFloat> stops;
|
||||
|
||||
|
||||
RiveRenderPaint();
|
||||
|
||||
void color(unsigned int value) override;
|
||||
void style(RenderPaintStyle value) override;
|
||||
void thickness(float value) override;
|
||||
void join(StrokeJoin value) override;
|
||||
void cap(StrokeCap value) override;
|
||||
void blendMode(BlendMode value) override;
|
||||
void linearGradient(float sx, float sy, float ex, float ey) override;
|
||||
void radialGradient(float sx, float sy, float ex, float ey) override;
|
||||
void addStop(unsigned int color, float stop) override;
|
||||
void completeGradient() override;
|
||||
};
|
||||
|
||||
enum class RivePathCommandType
|
||||
{
|
||||
MoveTo,
|
||||
LineTo,
|
||||
CubicTo,
|
||||
Reset,
|
||||
Close
|
||||
};
|
||||
|
||||
struct RivePathCommand
|
||||
{
|
||||
RivePathCommandType command;
|
||||
float x;
|
||||
float y;
|
||||
float inX;
|
||||
float inY;
|
||||
float outX;
|
||||
float outY;
|
||||
};
|
||||
|
||||
class RiveRenderPath : public RenderPath
|
||||
{
|
||||
private:
|
||||
UIBezierPath *path;
|
||||
FillRule m_FillRule;
|
||||
|
||||
public:
|
||||
RiveRenderPath();
|
||||
UIBezierPath *getBezierPath() { return path; }
|
||||
FillRule getFillRule() { return m_FillRule; }
|
||||
|
||||
void reset() override;
|
||||
void addPath(CommandPath *path, const Mat2D &transform) override;
|
||||
void fillRule(FillRule value) override;
|
||||
void moveTo(float x, float y) override;
|
||||
void lineTo(float x, float y) override;
|
||||
void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
|
||||
void close() override;
|
||||
};
|
||||
|
||||
class NewRiveRenderer : public Renderer
|
||||
{
|
||||
private:
|
||||
CGContextRef ctx;
|
||||
|
||||
public:
|
||||
NewRiveRenderer(CGContextRef context) : ctx(context) {}
|
||||
|
||||
void save() override;
|
||||
void restore() override;
|
||||
void transform(const Mat2D &transform) override;
|
||||
void drawPath(RenderPath *path, RenderPaint *paint) override;
|
||||
void clipPath(RenderPath *path) override;
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif /* rive_renderer_hpp */
|
||||
451
Source/RiveKit/RiveRenderer.mm
Normal file
451
Source/RiveKit/RiveRenderer.mm
Normal file
@@ -0,0 +1,451 @@
|
||||
//
|
||||
// RiveRenderer.m
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include "RiveRenderer.hpp"
|
||||
#include "renderer.hpp"
|
||||
|
||||
// Creates a UIColor from an RGBA int value
|
||||
#define UIColorFromRGB(rgbValue) \
|
||||
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/0xFF \
|
||||
green:((float)((rgbValue & 0xFF00) >> 8))/0xFF \
|
||||
blue:((float)(rgbValue & 0xFF))/0xFF \
|
||||
alpha:((float)((rgbValue & 0xFF000000) >> 24))/0xFF]
|
||||
|
||||
#define opacityFromARGB(rgbValue) ((float)((rgbValue & 0xFF000000) >> 24))/0xFF
|
||||
|
||||
using namespace rive;
|
||||
|
||||
// Base color space used throughout the renderer
|
||||
const CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB();
|
||||
|
||||
/*
|
||||
* Render paint
|
||||
*/
|
||||
|
||||
RiveRenderPaint::RiveRenderPaint() {
|
||||
// NSLog(@"INITIALIZING A NEW RENDER PAINT");
|
||||
}
|
||||
|
||||
void RiveRenderPaint::style(RenderPaintStyle value) {
|
||||
// NSLog(@" --- RenderPaint::style");
|
||||
switch(value) {
|
||||
case RenderPaintStyle::fill:
|
||||
paintStyle = RivePaintStyle::Fill;
|
||||
break;
|
||||
case RenderPaintStyle::stroke:
|
||||
// NSLog(@"Ask for stroke");
|
||||
paintStyle = RivePaintStyle::Stroke;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RiveRenderPaint::color(unsigned int value) {
|
||||
// NSLog(@" --- RenderPaint::color -> %u", value);
|
||||
CGFloat color [] = {
|
||||
((float)((value & 0xFF0000) >> 16))/0xFF,
|
||||
((float)((value & 0xFF00) >> 8))/0xFF,
|
||||
((float)(value & 0xFF))/0xFF,
|
||||
((float)((value & 0xFF000000) >> 24))/0xFF
|
||||
};
|
||||
cgColor = CGColorCreate(baseSpace, color);
|
||||
}
|
||||
|
||||
void RiveRenderPaint::thickness(float value) {
|
||||
// NSLog(@" --- RenderPaint::thickness %.1f", value);
|
||||
paintThickness = value;
|
||||
}
|
||||
|
||||
void RiveRenderPaint::join(StrokeJoin value) {
|
||||
// NSLog(@" --- RenderPaint::join");
|
||||
switch(value) {
|
||||
case StrokeJoin::miter:
|
||||
strokeJoin = RiveStrokeJoin::Miter;
|
||||
break;
|
||||
case StrokeJoin::round:
|
||||
strokeJoin = RiveStrokeJoin::Round;
|
||||
break;
|
||||
case StrokeJoin::bevel:
|
||||
strokeJoin = RiveStrokeJoin::Bevel;
|
||||
break;
|
||||
default:
|
||||
strokeJoin = RiveStrokeJoin::None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RiveRenderPaint::cap(StrokeCap value) {
|
||||
// NSLog(@" --- RenderPaint::cap");
|
||||
switch (value) {
|
||||
case StrokeCap::butt:
|
||||
strokeCap = RiveStrokeCap::Butt;
|
||||
break;
|
||||
case StrokeCap::round:
|
||||
strokeCap = RiveStrokeCap::Round;
|
||||
break;
|
||||
case StrokeCap::square:
|
||||
strokeCap = RiveStrokeCap::Square;
|
||||
break;
|
||||
default:
|
||||
strokeCap = RiveStrokeCap::None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RiveRenderPaint::blendMode(BlendMode value) {
|
||||
// NSLog(@" --- RenderPaint::blendMode -> %d", value);
|
||||
switch (value) {
|
||||
case BlendMode::srcOver:
|
||||
currentBlendMode = RiveBlendMode::SrcOver;
|
||||
break;
|
||||
case BlendMode::screen:
|
||||
currentBlendMode = RiveBlendMode::Screen;
|
||||
break;
|
||||
case BlendMode::overlay:
|
||||
currentBlendMode = RiveBlendMode::Overlay;
|
||||
break;
|
||||
case BlendMode::darken:
|
||||
currentBlendMode = RiveBlendMode::Darken;
|
||||
break;
|
||||
case BlendMode::lighten:
|
||||
currentBlendMode = RiveBlendMode::Lighten;
|
||||
break;
|
||||
case BlendMode::colorDodge:
|
||||
currentBlendMode = RiveBlendMode::ColorDodge;
|
||||
break;
|
||||
case BlendMode::colorBurn:
|
||||
currentBlendMode = RiveBlendMode::ColorBurn;
|
||||
break;
|
||||
case BlendMode::hardLight:
|
||||
currentBlendMode = RiveBlendMode::HardLight;
|
||||
break;
|
||||
case BlendMode::softLight:
|
||||
currentBlendMode = RiveBlendMode::SoftLight;
|
||||
break;
|
||||
case BlendMode::difference:
|
||||
currentBlendMode = RiveBlendMode::Difference;
|
||||
break;
|
||||
case BlendMode::exclusion:
|
||||
currentBlendMode = RiveBlendMode::Exclusion;
|
||||
break;
|
||||
case BlendMode::multiply:
|
||||
currentBlendMode = RiveBlendMode::Multiply;
|
||||
break;
|
||||
case BlendMode::hue:
|
||||
currentBlendMode = RiveBlendMode::Hue;
|
||||
break;
|
||||
case BlendMode::saturation:
|
||||
currentBlendMode = RiveBlendMode::Saturation;
|
||||
break;
|
||||
case BlendMode::color:
|
||||
currentBlendMode = RiveBlendMode::Color;
|
||||
break;
|
||||
case BlendMode::luminosity:
|
||||
currentBlendMode = RiveBlendMode::Luminosity;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RiveRenderPaint::linearGradient(float sx, float sy, float ex, float ey) {
|
||||
// NSLog(@" --- RenderPaint::linearGradient (%.1f,%.1f), (%.1f,%.1f)", sx, sy, ex, ey);
|
||||
gradient = RiveGradient::Linear;
|
||||
gradientStart = CGPointMake(sx, sy);
|
||||
gradientEnd = CGPointMake(ex, ey);
|
||||
|
||||
}
|
||||
void RiveRenderPaint::radialGradient(float sx, float sy, float ex, float ey) {
|
||||
// NSLog(@" --- RenderPaint::radialGradient");
|
||||
gradient = RiveGradient::Radial;
|
||||
gradientStart = CGPointMake(sx, sy);
|
||||
gradientEnd = CGPointMake(ex, ey);
|
||||
|
||||
}
|
||||
void RiveRenderPaint::addStop(unsigned int color, float stop) {
|
||||
// NSLog(@" --- RenderPaint::addStop");
|
||||
colorStops.emplace_back(((float)((color & 0xFF0000) >> 16))/0xFF);
|
||||
colorStops.emplace_back(((float)((color & 0xFF00) >> 8))/0xFF);
|
||||
colorStops.emplace_back(((float)(color & 0xFF))/0xFF);
|
||||
colorStops.emplace_back(((float)((color & 0xFF000000) >> 24))/0xFF);
|
||||
stops.emplace_back(stop);
|
||||
}
|
||||
void RiveRenderPaint::completeGradient() {
|
||||
// NSLog(@" --- RenderPaint::completeGradient");
|
||||
}
|
||||
|
||||
/*
|
||||
* Render path
|
||||
*/
|
||||
|
||||
RiveRenderPath::RiveRenderPath() {
|
||||
path = [[UIBezierPath alloc] init];
|
||||
// NSLog(@"INITIALIZING A NEW RENDER PATH");
|
||||
}
|
||||
|
||||
void RiveRenderPath::close() {
|
||||
// NSLog(@" --- RenderPath::close");
|
||||
[path closePath];
|
||||
}
|
||||
|
||||
void RiveRenderPath::reset() {
|
||||
// NSLog(@" --- RenderPath::reset");
|
||||
path = [[UIBezierPath alloc] init];
|
||||
// [path removeAllPoints];
|
||||
}
|
||||
|
||||
void RiveRenderPath::addPath(CommandPath* path, const Mat2D& transform) {
|
||||
// NSLog(@" --- RenderPath::addPath");
|
||||
UIBezierPath *addPath = reinterpret_cast<RiveRenderPath *>(path)->getBezierPath();
|
||||
|
||||
CGAffineTransform affineTransform = CGAffineTransformMake(transform.xx(),
|
||||
transform.xy(),
|
||||
transform.yx(),
|
||||
transform.yy(),
|
||||
transform.tx(),
|
||||
transform.ty());
|
||||
|
||||
UIBezierPath *clonePath = [addPath copy];
|
||||
|
||||
[clonePath applyTransform:affineTransform];
|
||||
[this->path appendPath:clonePath];
|
||||
}
|
||||
|
||||
void RiveRenderPath::fillRule(FillRule value) {
|
||||
// NSLog(@" --- RenderPath::fillRule");
|
||||
m_FillRule = value;
|
||||
}
|
||||
|
||||
void RiveRenderPath::moveTo(float x, float y) {
|
||||
// NSLog(@" --- RenderPath::moveTo x %.1f, y %.1f", x, y);
|
||||
[path moveToPoint:CGPointMake(x, y)];
|
||||
}
|
||||
|
||||
void RiveRenderPath::lineTo(float x, float y) {
|
||||
// NSLog(@" --- RenderPath::lineTo x %.1f, y %.1f", x, y);
|
||||
if (isnan(x) || isnan(y)) {
|
||||
NSLog(@"Received NaN in lineTo!!!!");
|
||||
return;
|
||||
}
|
||||
[path addLineToPoint:CGPointMake(x, y)];
|
||||
}
|
||||
|
||||
void RiveRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) {
|
||||
// NSLog(@" --- call to RenderPath::cubicTo %.1f, %.1f, %.1f, %.1f, %.1f, %.1f, ", ox, oy, ix, iy, x, y);
|
||||
[path addCurveToPoint:CGPointMake(x, y)
|
||||
controlPoint1:CGPointMake(ox, oy)
|
||||
controlPoint2:CGPointMake(ix, iy)
|
||||
];
|
||||
}
|
||||
|
||||
// Renderer
|
||||
|
||||
// Implement save by creating a sublayer
|
||||
void NewRiveRenderer::save() {
|
||||
// NSLog(@" --- Renderer::save");
|
||||
CGContextSaveGState(ctx);
|
||||
}
|
||||
|
||||
// Implement restore by moving back up to the parent layer. If the parent
|
||||
// layer is ctx, then there's been a restore without a save
|
||||
void NewRiveRenderer::restore() {
|
||||
// NSLog(@" -- Renderer::restore");
|
||||
CGContextRestoreGState(ctx);
|
||||
}
|
||||
|
||||
void NewRiveRenderer::drawPath(RenderPath* path, RenderPaint* paint) {
|
||||
|
||||
RiveRenderPaint *rivePaint = reinterpret_cast<RiveRenderPaint *>(paint);
|
||||
RiveRenderPath *rivePath = reinterpret_cast<RiveRenderPath *>(path);
|
||||
|
||||
// NSLog(@" --- Renderer::drawPath path for type %d", rivePaint->paintStyle);
|
||||
|
||||
// Apply the stroke join
|
||||
if (rivePaint->strokeJoin != RiveStrokeJoin::None) {
|
||||
switch(rivePaint->strokeJoin) {
|
||||
case RiveStrokeJoin::Miter:
|
||||
CGContextSetLineJoin(ctx, kCGLineJoinMiter);
|
||||
break;
|
||||
case RiveStrokeJoin::Round:
|
||||
CGContextSetLineJoin(ctx, kCGLineJoinRound);
|
||||
break;
|
||||
case RiveStrokeJoin::Bevel:
|
||||
CGContextSetLineJoin(ctx, kCGLineJoinBevel);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the strokeCap
|
||||
if (rivePaint->strokeCap != RiveStrokeCap::None) {
|
||||
switch (rivePaint->strokeCap) {
|
||||
case RiveStrokeCap::Butt:
|
||||
CGContextSetLineCap(ctx, kCGLineCapButt);
|
||||
break;
|
||||
case RiveStrokeCap::Round:
|
||||
CGContextSetLineCap(ctx, kCGLineCapRound);
|
||||
break;
|
||||
case RiveStrokeCap::Square:
|
||||
CGContextSetLineCap(ctx, kCGLineCapSquare);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the blend mode
|
||||
if (rivePaint->currentBlendMode != RiveBlendMode::None) {
|
||||
switch (rivePaint->currentBlendMode) {
|
||||
case RiveBlendMode::SrcOver:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeNormal);
|
||||
break;
|
||||
case RiveBlendMode::Screen:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeScreen);
|
||||
break;
|
||||
case RiveBlendMode::Overlay:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeOverlay);
|
||||
break;
|
||||
case RiveBlendMode::Darken:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeDarken);
|
||||
break;
|
||||
case RiveBlendMode::Lighten:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeLighten);
|
||||
break;
|
||||
case RiveBlendMode::ColorDodge:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeColorDodge);
|
||||
break;
|
||||
case RiveBlendMode::ColorBurn:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeColorBurn);
|
||||
break;
|
||||
case RiveBlendMode::HardLight:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeHardLight);
|
||||
break;
|
||||
case RiveBlendMode::SoftLight:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeSoftLight);
|
||||
break;
|
||||
case RiveBlendMode::Difference:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeDifference);
|
||||
break;
|
||||
case RiveBlendMode::Exclusion:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeExclusion);
|
||||
break;
|
||||
case RiveBlendMode::Multiply:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
|
||||
break;
|
||||
case RiveBlendMode::Hue:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeHue);
|
||||
break;
|
||||
case RiveBlendMode::Saturation:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeSaturation);
|
||||
break;
|
||||
case RiveBlendMode::Color:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeColor);
|
||||
break;
|
||||
case RiveBlendMode::Luminosity:
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeLuminosity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the path and then paint it appropriately
|
||||
CGPathRef cgPath = rivePath->getBezierPath().CGPath;
|
||||
CGContextAddPath(ctx, cgPath);
|
||||
|
||||
// If fill or stroke set, draw appropriately
|
||||
if (rivePaint->cgColor != NULL) {
|
||||
switch (rivePaint->paintStyle) {
|
||||
case RivePaintStyle::Stroke:
|
||||
// NSLog(@"Painting stroke");
|
||||
CGContextSetStrokeColorWithColor(ctx, rivePaint->cgColor);
|
||||
CGContextSetLineWidth(ctx, rivePaint->paintThickness);
|
||||
CGContextDrawPath(ctx, kCGPathStroke);
|
||||
break;
|
||||
case RivePaintStyle::Fill:
|
||||
// NSLog(@"Painting fill");
|
||||
CGContextSetFillColorWithColor(ctx, rivePaint->cgColor);
|
||||
CGContextDrawPath(ctx, kCGPathFill);
|
||||
break;
|
||||
case RivePaintStyle::None:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// NSLog(@"Color is null!!!");
|
||||
}
|
||||
|
||||
// Draw gradient
|
||||
if (rivePaint->gradient != RiveGradient::None) {
|
||||
NSLog(@"Drawing a gradient");
|
||||
CGGradientRef gradient = CGGradientCreateWithColorComponents(baseSpace, &rivePaint->colorStops[0], &rivePaint->stops[0], rivePaint->stops.size());
|
||||
|
||||
// If the path is a stroke, then convert the path to a stroked path to prevent the gradient from filling the path
|
||||
if (rivePaint->paintStyle == RivePaintStyle::Stroke) {
|
||||
CGContextSetLineWidth(ctx, rivePaint->paintThickness);
|
||||
CGContextReplacePathWithStrokedPath(ctx);
|
||||
}
|
||||
CGContextClip(ctx);
|
||||
|
||||
if (rivePaint->gradient == RiveGradient::Linear) {
|
||||
CGContextDrawLinearGradient(ctx, gradient, rivePaint->gradientStart, rivePaint->gradientEnd, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||
} else if (rivePaint->gradient == RiveGradient:: Radial) {
|
||||
// Calculate the end radius
|
||||
float dx = rivePaint->gradientEnd.x - rivePaint->gradientStart.x;
|
||||
float dy = rivePaint->gradientEnd.y - rivePaint->gradientStart.y;
|
||||
float endRadius = sqrt(dx*dx + dy*dy);
|
||||
CGContextDrawRadialGradient(ctx, gradient, rivePaint->gradientStart, 0, rivePaint->gradientStart, endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||
//CGContextSetFillColorWithColor(ctx, [UIColor yellowColor].CGColor);
|
||||
}
|
||||
CGGradientRelease(gradient); gradient = NULL;
|
||||
|
||||
if (rivePaint->paintStyle == RivePaintStyle::Fill) {
|
||||
CGContextDrawPath(ctx, kCGPathFill);
|
||||
} else if (rivePaint->paintStyle == RivePaintStyle::Stroke) {
|
||||
NSLog(@"Gradient paint with stroke");
|
||||
CGContextDrawPath(ctx, kCGPathStroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NewRiveRenderer::clipPath(RenderPath* path) {
|
||||
const CGPath *clipPath = reinterpret_cast<RiveRenderPath *>(path)->getBezierPath().CGPath;
|
||||
// NSLog(@" --- Renderer::clipPath %@", clipPath);
|
||||
|
||||
CGContextAddPath(ctx, clipPath);
|
||||
CGContextClip(ctx);
|
||||
}
|
||||
|
||||
void NewRiveRenderer::transform(const Mat2D& transform) {
|
||||
// NSLog(@" --- Renderer::transform %.1f, %.1f, %.1f, %.1f, %.1f, %.1f",
|
||||
// transform.xx(),
|
||||
// transform.xy(),
|
||||
// transform.yx(),
|
||||
// transform.yy(),
|
||||
// transform.tx(),
|
||||
// transform.ty());
|
||||
|
||||
CGContextConcatCTM(ctx, CGAffineTransformMake(transform.xx(),
|
||||
transform.xy(),
|
||||
transform.yx(),
|
||||
transform.yy(),
|
||||
transform.tx(),
|
||||
transform.ty()));
|
||||
}
|
||||
|
||||
/*
|
||||
* makeRenderPaint & makeRenderPath implementations
|
||||
*/
|
||||
|
||||
namespace rive {
|
||||
RenderPaint* makeRenderPaint() { return new RiveRenderPaint(); }
|
||||
|
||||
RenderPath* makeRenderPath() { return new RiveRenderPath(); }
|
||||
}
|
||||
19
Source/RiveKit/RiveView.h
Normal file
19
Source/RiveKit/RiveView.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// RiveView.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Rive.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RiveView : UIView
|
||||
|
||||
- (void)updateArtboard:(RiveArtboard*)artboard;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
30
Source/RiveKit/RiveView.mm
Normal file
30
Source/RiveKit/RiveView.mm
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// RiveView.m
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RiveView.h"
|
||||
#import "RiveRenderer.hpp"
|
||||
|
||||
@interface RiveView()
|
||||
|
||||
@end
|
||||
|
||||
@implementation RiveView
|
||||
|
||||
RiveArtboard *riveArtboard;
|
||||
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
RiveRenderer *renderer = [[RiveRenderer alloc] initWithContext:UIGraphicsGetCurrentContext()];
|
||||
[renderer alignWithRect:rect withContentRect:[riveArtboard bounds] withAlignment:Alignment::Center withFit:Fit::Contain];
|
||||
[riveArtboard draw:renderer];
|
||||
}
|
||||
|
||||
- (void)updateArtboard:(RiveArtboard *)artboard {
|
||||
riveArtboard = artboard;
|
||||
}
|
||||
|
||||
@end
|
||||
19
Source/RiveKit/RiveViewController.h
Normal file
19
Source/RiveKit/RiveViewController.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// RiveViewController.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RiveViewController : UIViewController
|
||||
|
||||
-(instancetype)initWithResource:(NSString *)resource withExtension:(NSString *)extension;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
114
Source/RiveKit/RiveViewController.mm
Normal file
114
Source/RiveKit/RiveViewController.mm
Normal file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// RiveViewController.m
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 9/11/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Rive.h"
|
||||
#import "RiveViewController.h"
|
||||
#import "RiveView.h"
|
||||
|
||||
@implementation RiveViewController
|
||||
|
||||
NSString *_resource;
|
||||
NSString *_extension;
|
||||
|
||||
RiveArtboard *artboard;
|
||||
RiveLinearAnimationInstance *_instance;
|
||||
|
||||
CADisplayLink *displayLink = NULL;
|
||||
CFTimeInterval lastTime = .0;
|
||||
|
||||
|
||||
- (instancetype)initWithResource:(NSString *) resource withExtension:(NSString *)extension {
|
||||
if (self = [super init]) {
|
||||
_resource = resource;
|
||||
_extension = extension;
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self forResource:_resource withExtension:_extension];
|
||||
}
|
||||
|
||||
- (void) loadView {
|
||||
RiveView *riveView = [[RiveView alloc] init];
|
||||
[riveView setBackgroundColor:[UIColor blueColor]];
|
||||
self.view = riveView;
|
||||
}
|
||||
|
||||
- (void) forResource: (NSString *) resource withExtension: (NSString *) extension {
|
||||
// load the Rive data
|
||||
NSString *filepath = [[NSBundle mainBundle] pathForResource:resource ofType:extension];
|
||||
NSError *error;
|
||||
NSData* data = [NSData dataWithContentsOfFile:filepath options:NSDataReadingUncached error:&error];
|
||||
// initialize the Rive file
|
||||
RiveFile* riveFile = [[RiveFile alloc] init];
|
||||
UInt8 *bytes = (UInt8 *) data.bytes;
|
||||
ImportResult result = [RiveFile import:bytes bytesLength:data.length toFile:riveFile];
|
||||
if (result != 0) {
|
||||
NSLog(@"Unable to import file: result code %i", (uint)result);
|
||||
return;
|
||||
}
|
||||
|
||||
artboard = [riveFile artboard];
|
||||
// update the artboard in the view
|
||||
[(RiveView *)self.view updateArtboard: artboard];
|
||||
|
||||
NSInteger animationCount = [artboard animationCount];
|
||||
// NSLog(@"Animation count: %d", (uint)animationcount);
|
||||
|
||||
if (animationCount > 0) {
|
||||
RiveAnimation *animation = [artboard animationAt: 0];
|
||||
// NSLog(@"Animation name: %@", [animation name]);
|
||||
_instance = [animation instance];
|
||||
[_instance advanceBy:.0]; // advance the animation
|
||||
[_instance applyTo:artboard]; // apply to the artboard
|
||||
[artboard advanceBy:.0]; // advance the artboard
|
||||
|
||||
[self runTimer];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) runTimer {
|
||||
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick)];
|
||||
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
-(void) stopTimer {
|
||||
if (displayLink != NULL) {
|
||||
[displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) tick {
|
||||
if (displayLink == NULL) {
|
||||
// Something's gone wrong, clean up and bug out
|
||||
[self stopTimer];
|
||||
}
|
||||
|
||||
double timestamp = [displayLink timestamp];
|
||||
|
||||
// Last time needs to be set on the first tick
|
||||
if (lastTime == 0) {
|
||||
lastTime = timestamp;
|
||||
}
|
||||
|
||||
// Calculate the time elapsed between ticks
|
||||
double elapsedTime = timestamp - lastTime;
|
||||
lastTime = timestamp;
|
||||
// NSLog(@"Timestamp: %.1f, elapsed time: %.5f, framerate %.1f", [displayLink timestamp], elapsedTime, 1. / elapsedTime);
|
||||
|
||||
[_instance advanceBy:elapsedTime]; // advance the animation
|
||||
[_instance applyTo:artboard]; // apply to the artboard
|
||||
[artboard advanceBy:elapsedTime]; // advance the artboard
|
||||
|
||||
[self.view setNeedsDisplay];
|
||||
}
|
||||
@end
|
||||
20
Source/RiveRuntime.h
Normal file
20
Source/RiveRuntime.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// RiveRuntime.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for RiveRuntime.
|
||||
FOUNDATION_EXPORT double RiveRuntimeVersionNumber;
|
||||
|
||||
//! Project version string for RiveRuntime.
|
||||
FOUNDATION_EXPORT const unsigned char RiveRuntimeVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <RiveRuntime/PublicHeader.h>
|
||||
#import <RiveRuntime/Rive.h>
|
||||
#import <RiveRuntime/RiveView.h>
|
||||
#import <RiveRuntime/RiveViewController.h>
|
||||
20
Source/Runtime/RiveRenderer.h
Normal file
20
Source/Runtime/RiveRenderer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// RiveRenderer.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/31/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RiveRenderer : NSObject
|
||||
|
||||
-(instancetype) initWithContext:(UIBezierPath *) context;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
26
Source/Runtime/RiveRenderer.mm
Normal file
26
Source/Runtime/RiveRenderer.mm
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// RiveRenderer.m
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/31/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RiveRenderer.h"
|
||||
|
||||
|
||||
@implementation RiveRenderer
|
||||
|
||||
//iOSRenderer *renderer;
|
||||
UIBezierPath *renderContext;
|
||||
|
||||
-(instancetype) initWithContext:(UIBezierPath *) context {
|
||||
if (self = [super init]) {
|
||||
renderContext = context;
|
||||
return self;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
15
Source/TestHeader.h
Normal file
15
Source/TestHeader.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// TestHeader.h
|
||||
// RiveRuntime
|
||||
//
|
||||
// Created by Matt Sullivan on 8/30/20.
|
||||
// Copyright © 2020 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TestHeader_h
|
||||
#define TestHeader_h
|
||||
|
||||
#import "RiveRuntime/Runtime/RiveFile.h"
|
||||
|
||||
|
||||
#endif /* TestHeader_h */
|
||||
Reference in New Issue
Block a user