Swift library of lightweight interfaces for prototyping, bridged to JS

Related tags

Guides Prototope
Overview

Build Status

Prototope

Prototope is a lightweight, high-performance prototyping framework. Its goals are:

  • making simple things very easy
  • making complex things possible
  • enabling rapid iteration
  • high performance execution
  • concepts easily mapped onto production implementation

Interfaces to the API are presently available in Swift and JavaScript. The current implementation only runs on iOS, but the interface should be portable.

You can use Protocaster (a Mac app) to broadcast live-reloading JavaScript prototypes to Protoscope (an iOS app). More documentation about this is forthcoming.

Documentation is available here.

Bootstrapping with prototope

You'll need Xcode 6.3 to use Prototope!

You can clone the OhaiPrototope project. If you do, you'll need to run

    $ git submodule update --init --recursive

from within the repo in order to pull down the prototope and pop submodules. The project, however, is ready to go. Edit MainScene.swift and start making dreams come true!

Including prototope in your existing project

If you plan to include prototope as a submodule from within your project, you'll likely have to do the following from within your project

getting it

    $ git submodule add https://github.com/khan/prototope
    $ git submodule update --init --recursive

the first adds prototope as a git submodule to your project (and clones it outright), but you need the second command in order to pull in prototope's dependencies (namely pop).

adding it to xcode

This part is somewhat more involved.

  1. under Embedded Libraries, add Prototope.framework
  2. under Build Settings -> Other Linker Flags, add -Objc -lc++
  3. under Build Settings -> Header Search Paths, add
    • $(SRCROOT)/prototope/Prototope/
    • $(SRCROOT)/prototope/ThirdParty/ (set it to be recursive)
  4. under Build Settings -> Library Search Paths, add $(SRCROOT)/prototope/ThirdParty (set it to be recursive)

making sure things work

You should be able to test that you've imported everything if you can type import Prototope in your ViewController.swift file and if the project builds. XCode may complain that it can't find the bridging header in the gutter, but it's a lie. It can, and if the project builds, you're in good shape.

Comments
  • [FIN] Collision Behaviors

    [FIN] Collision Behaviors

    ...

    UPDATE: Changed API across the board with feedback from Andy.

    To do:

    • [x] Currently this only works for layers in the same parent layer. Need to make it work regardless of the layer hierarchy.
    • [x] More feedback from Andy
    • [x] Add JS bridging for the behavior API
    opened by saniul 15
  • [Hold] Transform JavaScript with Babel before running

    [Hold] Transform JavaScript with Babel before running

    This lets you use let/const, arrow functions, and more.

    I updated all the examples that I could figure out how to run so they use let/const. Also threw in an arrow function for fun, though there weren't many short functions so using them elsewhere is more a matter of taste.

    opened by sophiebits 12
  • Layer.frameMinX vs Layer.frame.minX

    Layer.frameMinX vs Layer.frame.minX

    Feels weird having both of those sets of properties.

    How about we just always use the Layer.frame.minX lot? We could also make these properties writable.

    opened by saniul 11
  • [WIP] Decay animation support

    [WIP] Decay animation support

    This isn’t ready to merge, this is more like a sketch to discuss changing the animation API.

    Adds DecayAnimation and extracts the previous spring animation properties into SpringAnimation. This PR also adds an applyHandler, which allows processing on every POP animation tick.

    opened by saniul 8
  • Bridge the Point.slopeToPoint() function.

    Bridge the Point.slopeToPoint() function.

    Is it possible (or does it make sense) to bridge an optional type?

    The slope function is optional for the case where the slope is infinite/undefined (i.e., there's a divide by zero). For the bridge I'm just returning 0 because it seems more sensible to do this than really worry about it too much. Thoughts?

    [Fixes #66]

    opened by jbrennan 7
  • Insetting APIs for Rect

    Insetting APIs for Rect

    Would like to be able to do things like:

    var someRect = new Rect({x: 5, y: 10, width: 20, height: 30})
    var x = someRect.inset({top: 30, right: 15})
    var y = someRect.inset({vertical: 30, horizontal: 15})
    var z = someRect.inset(20)
    
    enhancement 
    opened by andymatuschak 6
  • console.log() stops working after end of main completes

    console.log() stops working after end of main completes

    I modified the JSTest.swift to have a consoleLogHandler:

    context.consoleLogHandler = { str in
        println(str)
    }
    

    I also added some console.log statements at the end of JSTest.js:

    afterDuration(1, function() {
         layer.backgroundColor = new Color({red: 0.0, green: 0.7, blue: 1.0, alpha: 0.7});
         console.log("Hello, world");
    });
    console.log("hello");
    console.log("goodbye");
    
    var foo = function() { console.log("foo"); };
    foo();
    
    "Done JSTest.js"
    

    The resulting output was:

    hello
    goodbye
    foo
    Done JSTest.js
    

    I was expecting Hello, world to appear after Done JSTest.js. I know that afterDuration fired the callback successfully because the layer background color changed to blue.

    bug 
    opened by kevinbarabash 6
  • Image from text

    Image from text

    This patch lets you create an Image by rendering a given string (with optional font and textColor parameters) into a buffer.

    This is useful if you need to make an image from text (in particular, emoji) for things like particles, or if you need a text layer and you want to add touch handling to it, but you can’t because of #41

    This should be looked at after Swift 2 changes are merged in (#108)

    opened by jbrennan 5
  • Integrate Early Math Prototypes into a player app

    Integrate Early Math Prototypes into a player app

    What it does

    This pull request integrates prototypes from the Early Math Prototypes repo (as a submodule) into a local player app so they can be played on the iPad without needing to be tethered / served over wifi.

    • Handles loading JS prototypes
    • Lists all available prototypes
    • handles images and sounds

    Notes

    Everything should be functional but I want to clean up the code style a little and add a few docs here or there. I’d love to have feedback on this (and spotting for any showstoppers) but it should be more or less ready to go.

    opened by jbrennan 5
  • Protocaster should try to reconnect to protoscope when it reappears

    Protocaster should try to reconnect to protoscope when it reappears

    95% of the time, I want Protocaster to just reconnect to the device/simulator when it comes back online.

    Self-assigning for now, but feel free to take it from me if you're looking for something to chew on!

    enhancement 
    opened by jbrennan 5
  • JavaScript mode for docs

    JavaScript mode for docs

    💥

    The docs don’t actually have the JS content yet, but now we’ve got a switch.

    Check out the changes to the readme for information about how JS-specific docs work, or see Animator's docs for an example.

    Would appreciate your benevolent guidance, sir @nsfmc. :D

    opened by andymatuschak 4
  • Cloning layers

    Cloning layers

    I’d love to be able to say let myClone = someLayer.clone() to have another layer identical to the original.

    I think the new layer should clone:

    • the size and position
    • the border and corner radius
    • the background colour and image
    • the parent layer
    • any sublayers
    • gesture / touch handlers?
    enhancement 
    opened by jbrennan 1
  • Image from any Layer

    Image from any Layer

    From #109, @andymatuschak writes:

    It's useful to be able to get an image of anything a layer can draw (e.g. a bezier path, etc). What if you could get an image (i.e. a snapshot) from any layer?

    enhancement 
    opened by jbrennan 0
  • Built-in lorem ipsum (placeholder) text generator

    Built-in lorem ipsum (placeholder) text generator

    It's often nice to just put in paragraphs, lines, or a certain number of words/characters of placeholder text. It'd be great to be able to do this without having to statically put large chunks of text in the script.

    enhancement 
    opened by nefaurk 0
Owner
Khan Academy
Working to make a free, world-class education available for anyone, anywhere.
Khan Academy
Swift Client library to interact with Supabase Functions.

functions-swift Swift Client library to interact with Supabase Functions. Usage let client = FunctionsClient( url: URL(string: "https://project-id.s

Supabase Community 3 Dec 1, 2022
DCL Private Library

DCLPrivateLibrary Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation

null 0 Nov 28, 2021
SwiftUI module library for adding seasons theme animations to your app

HolidayThemes SwiftUI module library for adding seasons theme animations to your app. Requirements iOS 13.0+ Xcode 12.0+ Installation Swift Package Ma

null 2 Mar 7, 2022
This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.

>> 日本語 UIPiPView This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS. Using this library, information that is updated in real

Akihiro Urushihara 128 Jan 4, 2023
SmartString - A powerful and small library that will allow the creation of complex String Styles

SmartString A powerful and small library that will allow the creation of complex

Valerio 7 Oct 26, 2022
⚛️ A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency.

SwiftUI Atom Properties A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency ?? API Reference Introduction Examples Gett

Ryo Aoyama 199 Dec 17, 2022
CoreDragon is a drag'n'drop library for iOS applications

CoreDragon is a drag'n'drop library for iOS applications. Instead of using context menus, modal view controllers, share sheets and other "indirect manipulation" ways of moving data around, it's much more intuitive to just grab the thing you want to move, and drop it on the place where you want to move it to.

Nevyn Bengtsson 680 Sep 9, 2022
SwiftLint - A tool to enforce Swift style and conventions, loosely based on Swift Style Guide.

SwiftLint - A tool to enforce Swift style and conventions, loosely based on Swift Style Guide.

Realm 16.9k Dec 30, 2022
Sweet-swift - Make Swift Sweet by Gracefully Introducing Syntactic Sugar, Helper Functions and Common Utilities

Sweet Swift Make Swift Sweet by Gracefully Introducing Syntactic Sugar, Helper F

Yanzhan Yang 2 Feb 6, 2022
Airbnb's Swift Style Guide.

Airbnb Swift Style Guide Goals Following this style guide should: Make it easier to read and begin understanding unfamiliar code. Make code easier to

Airbnb 1.8k Jan 3, 2023
LinkedIn's Official Swift Style Guide

Swift Style Guide Make sure to read Apple's API Design Guidelines. Specifics from these guidelines + additional remarks are mentioned below. This guid

LinkedIn 1.4k Jan 5, 2023
The Official raywenderlich.com Swift Style Guide.

The Official raywenderlich.com Swift Style Guide. Updated for Swift 5 This style guide is different from others you may see, because the focus is cent

raywenderlich 12.5k Jan 3, 2023
A self-taught project to learn Swift.

30 Days of Swift Hi Community I am Allen Wang, a product designer and currently learning Swift. This project was totally inspired by Sam Lu's 100 Days

Allen Wang 11.4k Dec 31, 2022
Explanations and samples about the Swift programming language

About Swift Contents Explanations and samples about: Swift Programming Language Swift Standard Library Target audience Developers familiar with object

Nicola Lancellotti - About 74 Dec 29, 2022
A collection useful tips for the Swift language

SwiftTips The following is a collection of tips I find to be useful when working with the Swift language. More content is available on my Twitter acco

Vincent Pradeilles 929 Dec 10, 2022
Swift Featured Projects in brain Mapping

Swift 开源精选   自 2014年 WWDC 发布 Swift 语言以来,本项目 一直致力于将主流 Swift 中文学习、开发资源汇集于此,并且尽力紧密地跟踪、甄选优秀 Swift 开源项目,以方便开发者快速获得并使用。考虑 Swift 已经正式发布超过四年半(更无力管理维护海量的 Swift

iPader 15.8k Jan 9, 2023
A collection of Swift tips & tricks that I've shared on Twitter

⚠️ This list is no longer being updated. For my latest Swift tips, checkout the "Tips" section on Swift by Sundell. Swift tips & tricks ⚡️ One of the

John Sundell 3.9k Dec 30, 2022
An Xcode playground showcasing the new features in Swift 4.0.

What’s new in Swift 4 An Xcode playground showcasing the new features in Swift 4.0. As seen in the What’s New in Swift session at WWDC 2017. Written b

Ole Begemann 1.8k Dec 23, 2022