GithubHelp home page GithubHelp logo

runngezhang / animation-6371ff2c32c27666b6d8231ec6faedc4e31402cf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lcs-svallamkonda/animation-6371ff2c32c27666b6d8231ec6faedc4e31402cf

0.0 0.0 0.0 3.66 MB

C++ 22.22% C 31.66% Objective-C 9.35% Objective-C++ 6.09% Swift 30.68%

animation-6371ff2c32c27666b6d8231ec6faedc4e31402cf's Introduction

Animation

Welcome to Animation, an environment for authoring Processing-style animations with Swift.

Examples

Animations are, naturally, easy to generate:

colorful-animation-smaller-resolution

Of course, animations are crisp and smooth when running in Xcode; what you see above is an animated GIF.

Static images can also be generated, for example:

thepixies

NOTE: the original gig poster design shown here is by Mike Joyce at Swissted.

Motivation

Animation shares the same goal as the Processing environment – to allow students to learn programming by creating interactive graphics.

The following is an excerpt from Getting Started with Processing (2010) by Casey Reas and Ben Fry:

Programming courses typically focus on structure and theory first. Anything visual—an interface, an animation—is considered a dessert to be enjoyed only after finishing your vegetables, usually several weeks of studying algorithms and methods. Over the years, we’ve watched many friends try to take such courses and drop out after the first lecture or after a long, frustrating night before the first assignment deadline. What initial curiosity they had about making the computer work for them was lost because they couldn’t see a path from what they had to learn first to what they wanted to create.

My experience has been that:

  • easy creation of interactive graphics
  • the elegance of the Swift programming language
  • the forgiving and exploratory nature of the Swift Playgrounds environment

... combines to make an extremely powerful introductory learning experience for students in Computer Science classes.

Getting Started

Clone or download a ZIP of the repository.

Be sure you open the Animation.xcodeproj file:

Screen Shot 2019-07-24 at 9 42 57 PM

Once you open the project, you must (one time only) build the CanvasGraphics framework:

Screen Shot 2019-07-24 at 9 45 16 PM

To create static images, use the playground file:

Screen Shot 2019-07-24 at 9 41 46 PM

To create an animation, work in the Sketch.swift file:

Screen Shot 2019-07-24 at 9 46 23 PM

To see your animation, build and run the Animation application:

Screen Shot 2019-07-24 at 9 48 07 PM

Documentation

Animation is designed to be an easy-to-use sketching environment.

Create an instance of the Canvas class and begin drawing:

import Cocoa
import PlaygroundSupport
import CanvasGraphics

// Create canvas
let canvas = Canvas(width: 300, height: 600)

// Show the canvas in the playground's live view
PlaygroundPage.current.liveView = canvas

// Draw a face
canvas.fillColor = .white
canvas.defaultBorderWidth = 5
canvas.drawEllipse(at: Point(x: 150, y: 300), width: 200, height: 200)

// Draw eyes
canvas.drawEllipse(at: Point(x: 125, y: 325), width: 10, height: 20)
canvas.drawEllipse(at: Point(x: 175, y: 325), width: 10, height: 20)

// Draw mouth
canvas.drawEllipse(at: Point(x: 150, y: 270), width: 100, height: 30)

// Turn mouth into a smile by covering up top half of mouth
canvas.drawShapesWithBorders = false
canvas.drawRectangle(at: Point(x: 150, y: 275), width: 125, height: 25, anchoredBy: .centre)

You can read through the documentation for available drawing methods here.

animation-6371ff2c32c27666b6d8231ec6faedc4e31402cf's People

Contributors

lcs-svallamkonda avatar

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.