GithubHelp home page GithubHelp logo

exyte / macaw Goto Github PK

View Code? Open in Web Editor NEW
6.0K 101.0 548.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 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

Animation support

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

image1

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()

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)

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?

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.

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.

Review Macaw API

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

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.