Skip to content

Commit

Permalink
Merge pull request #1 from rive-app/tidy_up
Browse files Browse the repository at this point in the history
Tidying up a bunch of stuff
  • Loading branch information
mjohnsullivan authored Oct 1, 2020
2 parents 06d8e3a + 2623deb commit 8479d9c
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 108 deletions.
Binary file added Example-iOS/Assets/sheep.riv
Binary file not shown.
4 changes: 4 additions & 0 deletions Example-iOS/RiveExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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 */; };
C9A7D7F52523C1D900AFB875 /* sheep.riv in Resources */ = {isa = PBXBuildFile; fileRef = C9A7D7F22523C1D900AFB875 /* sheep.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 */; };
Expand Down Expand Up @@ -65,6 +66,7 @@
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>"; };
C9A7D7F22523C1D900AFB875 /* sheep.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep.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>"; };
Expand All @@ -91,6 +93,7 @@
C9696B0E24FC6FD10041502A /* Assets */ = {
isa = PBXGroup;
children = (
C9A7D7F22523C1D900AFB875 /* sheep.riv */,
C99E2FE6251E8E35009227CA /* bird.riv */,
C99E2FE7251E8E35009227CA /* funtime.riv */,
C99E2FE0251E8DB4009227CA /* van.riv */,
Expand Down Expand Up @@ -260,6 +263,7 @@
C970484A250822F300CB3AB3 /* simple.riv in Resources */,
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */,
C9927C1B250986BF009F17F5 /* truck.riv in Resources */,
C9A7D7F52523C1D900AFB875 /* sheep.riv in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 0 additions & 1 deletion Example-iOS/Source/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import RiveRuntime

struct ContentView: View {
var body: some View {
// Text("Hello, World!")
MyRive()
}
}
Expand Down
24 changes: 8 additions & 16 deletions RiveRuntime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -523,21 +523,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
C9601F20250C13D40032AA07 /* RiveKit */ = {
isa = PBXGroup;
children = (
C9C741F224FC510200EF9516 /* Rive.h */,
C9C741F324FC510200EF9516 /* Rive.mm */,
C9601F29250C25830032AA07 /* RiveRenderer.hpp */,
C9601F2A250C25930032AA07 /* RiveRenderer.mm */,
C9601F25250C14560032AA07 /* RiveView.h */,
C9601F26250C14560032AA07 /* RiveView.mm */,
C9601F21250C143A0032AA07 /* RiveViewController.h */,
C9601F22250C143A0032AA07 /* RiveViewController.mm */,
);
path = RiveKit;
sourceTree = "<group>";
};
C9601F2C251004770032AA07 /* math */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -661,7 +646,14 @@
C9C73ED324FC478800EF9516 /* Source */ = {
isa = PBXGroup;
children = (
C9601F20250C13D40032AA07 /* RiveKit */,
C9C741F224FC510200EF9516 /* Rive.h */,
C9C741F324FC510200EF9516 /* Rive.mm */,
C9601F29250C25830032AA07 /* RiveRenderer.hpp */,
C9601F2A250C25930032AA07 /* RiveRenderer.mm */,
C9601F25250C14560032AA07 /* RiveView.h */,
C9601F26250C14560032AA07 /* RiveView.mm */,
C9601F21250C143A0032AA07 /* RiveViewController.h */,
C9601F22250C143A0032AA07 /* RiveViewController.mm */,
C9C73ED424FC478800EF9516 /* RiveRuntime.h */,
C9C73ED524FC478800EF9516 /* Info.plist */,
);
Expand Down
1 change: 0 additions & 1 deletion Source/RiveKit/Rive.h → Source/Rive.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
6 changes: 5 additions & 1 deletion Source/RiveKit/Rive.mm → Source/Rive.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ @implementation RiveRenderer
-(instancetype) initWithContext:(CGContextRef) context {
if (self = [super init]) {
ctx = context;
_renderer = new rive::NewRiveRenderer(context);
_renderer = new rive::RiveRenderer(context);
return self;
} else {
return nil;
}
}

-(void) dealloc {
delete _renderer;
}

-(void) alignWithRect:(CGRect)rect withContentRect:(CGRect)contentRect withAlignment:(Alignment)alignment withFit:(Fit)fit {
// NSLog(@"Rect in align %@", NSStringFromCGRect(rect));

Expand Down
38 changes: 26 additions & 12 deletions Source/RiveKit/RiveRenderer.hpp → Source/RiveRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
#ifndef rive_renderer_hpp
#define rive_renderer_hpp

#import <UIKit/UIKit.h>

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <vector>

#import "renderer.hpp"

namespace rive
{

/*
* RenderPaint
*/

enum class RiveGradient
{
None,
Expand Down Expand Up @@ -69,7 +72,6 @@ namespace rive
Luminosity = static_cast<int>(BlendMode::luminosity)
};


class RiveRenderPaint : public RenderPaint
{
private:
Expand All @@ -81,15 +83,16 @@ namespace rive
RiveBlendMode currentBlendMode;
float paintThickness;

// Gradient
RiveGradient gradient = RiveGradient::None;
// Gradient data
RiveGradient gradientType = RiveGradient::None;
CGGradientRef gradient = NULL;
CGPoint gradientStart;
CGPoint gradientEnd;
std::vector<CGFloat> colorStops;
std::vector<CGFloat> stops;


RiveRenderPaint();
~RiveRenderPaint();

void color(unsigned int value) override;
void style(RenderPaintStyle value) override;
Expand All @@ -103,6 +106,10 @@ namespace rive
void completeGradient() override;
};

/*
* RenderPath
*/

enum class RivePathCommandType
{
MoveTo,
Expand All @@ -126,12 +133,14 @@ namespace rive
class RiveRenderPath : public RenderPath
{
private:
UIBezierPath *path;
CGMutablePathRef path;
FillRule m_FillRule;

public:
RiveRenderPath();
UIBezierPath *getBezierPath() { return path; }
~RiveRenderPath();

CGMutablePathRef getPath() { return path; }
FillRule getFillRule() { return m_FillRule; }

void reset() override;
Expand All @@ -143,14 +152,19 @@ namespace rive
void close() override;
};

class NewRiveRenderer : public Renderer
/*
* Renderer
*/

class RiveRenderer : public Renderer
{
private:
CGContextRef ctx;

public:
NewRiveRenderer(CGContextRef context) : ctx(context) {}

RiveRenderer(CGContextRef context) : ctx(context) {}
~RiveRenderer();

void save() override;
void restore() override;
void transform(const Mat2D &transform) override;
Expand Down
Loading

0 comments on commit 8479d9c

Please sign in to comment.