Coder Social home page Coder Social logo

exyte / macaw Goto Github PK

View Code? Open in Web Editor NEW
6.0K 101.0 552.0 56.42 MB

Powerful and easy-to-use vector graphics Swift library with SVG support

License: MIT License

Swift 99.80% Ruby 0.20%
ios ios-animation drawing graphics svg ui transition swift animation

macaw's Introduction

     

❗Macaw Deprecated❗

Check out this post for deatils. TL;DR:

  • You can continue to use this framework as is: expect no new features or bug fixing; however, it will be updated to work in future Xcode releases.
  • if you need some good declarative UI framework, please use SwiftUI.
  • If you need a powerful SVG support, please use SVGView.
  • If you’d like to fix something in Macaw, feel free to fork this repo. Publish your PRs so that other people can use it as well. Some PRs will be merged from time to time.

Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support

Version Carthage Compatible License Platform

What is Macaw?

Macaw is a powerful and easy-to-use vector graphics library written in Swift.

It's simple

Get started with Macaw in several lines of code:

class MyView: MacawView {

	required init?(coder aDecoder: NSCoder) {
		let text = Text(text: "Hello, World!", place: .move(dx: 145, dy: 100))
		super.init(node: text, coder: aDecoder)
	}

}

It has SVG support

Include Scalable Vector Graphics right into your iOS application:

It's powerful

Affine transformations, user events, animation and various effects to build beautiful apps with Macaw:

Motivation

Modern designs contain tons of illustrations and complex animations. Mobile developers have to spend a lot of time on converting designs into native views that will be resizable for different screens. With Macaw you can reduce development time to a minimum and describe all graphics in high level scene elements. Or even render SVG graphics right from your design tool with Macaw events and animation support.

Resources

Docs

We're working hard to provide full documentation. Currently you can take a look at the following docs:

Posts

Examples

Macaw-Examples is a repository where you can find various usages of the Macaw library from simple charts to the complex periodic table.

Requirements

  • iOS 9.0+
  • Mac OS X 10.11+
  • Xcode 7.3+

Installation

To install it, simply add the following line to your Podfile:

pod "Macaw", "0.9.7"
github "Exyte/Macaw" ~> 0.9.7

Building from sources

To build Macaw from sources:

  • clone the repo [email protected]:exyte/Macaw.git
  • open terminal and run cd <MacawRepo>/Example/
  • run pod install to install all dependencies
  • run open Example.xcworkspace/ to open project in the Xcode

Change Log

You can find list of all changes by version in the Change Log

License

Macaw is available under the MIT license. See the LICENSE file for more info.

macaw's People

Contributors

amarunko avatar aure avatar basilche avatar chalkdust avatar damienpontifex avatar devpolant avatar evgeny-sureev avatar f3dm76 avatar fangpenlin avatar fassko avatar fdelencl avatar hotbott avatar joachimm7 avatar k-be avatar kayuri avatar khoren93 avatar lordjashin32 avatar mgoldin avatar mnndnl avatar nikita-afonasov avatar nverinaud avatar revever avatar scorsinsc avatar shipinev avatar sroik avatar stephsharp avatar tomaslinhart avatar vhailor13 avatar ystrot avatar zapletnev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

macaw's Issues

Review Macaw API

  • MacawView
  • scene: Shape/Text/Image/Group
  • geometry
  • draw
  • effects
  • animation
  • events
  • SVG

Clean up scene/draw/geometry

scene:

  • Rename Group.contentsVar to Group.contents
  • Node.pos needs a better name
  • TBD: Remove Drawable.bounds from the model
  • Make Text.font optional
  • Image.xAlign/yAlign/aspectRatio properties are too complicated and clumsy

draw:

  • Remove AspectRatio
  • Move static properties/methods of Color to Fill
  • Remove unnecessary FontStyle and FontWeight
  • Rethink Font.bold/italic/underline/strike properties. Need a better solution for Macaw.
  • Gradient.userSpace needs a better name

geometry:

  • Make sure we use consistent system for every angle
  • Add Sector class
  • Transform.invert should return nil when doesn't exist
  • Move -> MoveTo, PLine -> LineTo
  • Rethink Path API: do we really need excess model?

Improve Animation API

Problems:

  • Current Animation API requires user to say same things twice which makes it more error prone:
// need to say 'opacity' twice, need to say 'node' twice
OpacityAnimation(animatedNode: node, observableValue: node.opacityVar, ...)
// it allows user to make errors
OpacityAnimation(animatedNode: node1, observableValue: node2.opacityVar, ...)
  • Animation needs registration through MacawView.addAnimation which makes API imperative VS declarative.

Proposal:

For every animatable property use AnimatableVariable, which has reference to Node, understand property type and has 'animate' method:

public class AnimatableVariable<T: Interpolable> : Variable<T> {
    public func animate(from: T, to: T, during: Double, ...) -> Animation
}

This method automatically register animation in global registry which then delegates to appropriate MacawView.

// current
let animation = OpacityAnimation(animatedNode: ballGroup, observableValue: ballGroup.opacityVar, startValue: 0.1, finalValue: 1.0, animationDuration: 3.0)
view.addAnimation(animation)
...
animation.stop()

// proposed
let animation = ballGroup.opacityVar.animate(from: 0.1, to: 1.0, during: 3.0)
...
animation.stop()

Nullable by default

Currently Kaway doesn't support non-nullable types which means that all fields should be nullable by default. It's important because currently Group has non-nullable clip field which means it can't be used without clipping.

Radial gradient support

I've added model to the repo. The following code can be useful to draw radial gradient in Macaw:

let context = UIGraphicsGetCurrentContext()
let minSize = min(bounds.size.width, bounds.size.height)
let options: CGGradientDrawingOptions = [.DrawsAfterEndLocation]

// get from stops
let colors: CFArray = [UIColor.redColor().CGColor, UIColor.blueColor().CGColor]
let locations : [CGFloat] = [0.0, 1.0]
let gradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), colors, locations)

// radial gradient parameters
let cx = 0.5  * minSize
let cy = 0.5  * minSize
let fx = 0.25 * minSize
let fy = 0.25 * minSize
let r  = 0.5  * minSize

CGContextDrawRadialGradient(context, gradient, CGPoint(x: fx, y: fy), 0, CGPoint(x: cx, y: cy), r, options)

Animation support

let c = Circle(...) let animation = Animation(c, c.rProperty, 0, 100, 10s) let view = MacawView(c, animation) view.addAnimation(anotherAnimation)

image1

Use default values in constructors

In Kaway every type has default value. Please use this value (or field default) in constructor. Currently objects with 5+ fields really hard to initialize.

SVG Support

  • nested svg tags parsing
  • viewbox parsing
  • gradients
  • clipping
  • defs
  • text tspan
  • opacity

Effects support

<feOffset dx="2" dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="10" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0   0 0 0 0 0   0 0 0 0 0  0 0 0 0.6 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.