Welcome to the ProcessingKit documentation! Here, you will find detailed information and resources to help you get started with ProcessingKit.
Getting Started
Installation
- Open your Xcode project
- Add ProcessingKit as a dependency by either:
- Using CocoaPods: Add
pod 'ProcessingKit'
to yourPodfile
and runpod install
- Manually installing:
- Download the latest framework from the ProcessingKit GitHub repository
- Unzip the downloaded file and drag the
ProcessingKit.framework
into your Xcode project - Make sure to add the framework to your project’s target
- Import ProcessingKit in your code:
// Swift import ProcessingKit // Objective-C @import ProcessingKit;
Basic Usage
ProcessingKit provides a simple and intuitive API for creating graphics and animations. Here’s a basic example to get you started:
let sketch = Sketch() sketch.setup { // Set up initial environment sketch.size(width: 500, height: 500) sketch.background(r: 255, g: 255, b: 255) } sketch.draw { // Draw code here (runs in a loop) sketch.background(r: 255, g: 255, b: 255) sketch.fill(r: 0, g: 0, b: 0) sketch.rect(x: 250, y: 250, width: 100, height: 100) } SketchRunner.run(sketch: sketch)
Features
Graphics
- Create and manipulate basic shapes (rectangles, ellipses, lines)
- Apply transformations (translate, rotate, scale)
- Control stroke and fill colors
- Draw text
Interaction
- Handle touch events
- Detect collision between objects
- Implement user input controls (buttons, sliders)
Animation
- Animate object properties (position, size, color)
- Create tweens and easing functions
- Control frame rate
Sound
- Load and play audio files
- Control volume and panning
- Add sound effects
- Implement interactive sound
Examples
Shape Animation
This example shows how to animate the position and size of a shape:
let sketch = Sketch() var rectPosition = Point(x: 0, y: 0) var rectSize = Size(width: 50, height: 50) sketch.setup { // Set up initial environment sketch.size(width: 500, height: 500) sketch.background(r: 255, g: 255, b: 255) } sketch.draw { // Draw code here (runs in a loop) sketch.background(r: 255, g: 255, b: 255) sketch.fill(r: 0, g: 0, b: 0) sketch.rect(x: rectPosition.x, y: rectPosition.y, width: rectSize.width, height: rectSize.height) // Animate rect position and size rectPosition.x += 1 rectPosition.y += 1 rectSize.width += 1 rectSize.height += 1 } SketchRunner.run(sketch: sketch)
Sound Player
This example demonstrates how to load and play an audio file:
let sketch = Sketch() var player: SoundPlayer? sketch.setup { // Set up initial environment sketch.size(width: 500, height: 500) sketch.background(r: 255, g: 255, b: 255) // Load audio file if let url = Bundle.main.url(forResource: "sound", withExtension: "mp3") { player = sketch.loadSound(url: url) } } sketch.draw { // Draw code here (runs in a loop) sketch.background(r: 255, g: 255, b: 255) // Play audio if let player = player { player.play() } } SketchRunner.run(sketch: sketch)
Conclusion
ProcessingKit is a powerful framework for creating graphics and animations in your iOS apps. With its intuitive API, you can quickly prototype and develop visually appealing experiences. We hope this documentation has provided you with the necessary guidance to get started with ProcessingKit. Happy coding!