All Projects → Awalz → Swiftydraw

Awalz / Swiftydraw

Licence: mit
A simple, lightweight drawing framework written in Swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Swiftydraw

Touchdraw
A subclass of UIView which allows you to draw with your fingers.
Stars: ✭ 119 (-50.21%)
Mutual labels:  drawing
Godot Texture Painter
A GPU-accelerated texture painter written in Godot 3.0
Stars: ✭ 155 (-35.15%)
Mutual labels:  drawing
Storyboarder
✏️ Storyboarder makes it easy to visualize a story as fast you can draw stick figures.
Stars: ✭ 2,467 (+932.22%)
Mutual labels:  drawing
Singledivproject
☝️One <div>. Many possibilities.
Stars: ✭ 1,586 (+563.6%)
Mutual labels:  drawing
Noodle
Small, Sharp Sketch Tool
Stars: ✭ 151 (-36.82%)
Mutual labels:  drawing
Drawingboard.js
A canvas based drawing app that you can integrate easily on your website.
Stars: ✭ 2,072 (+766.95%)
Mutual labels:  drawing
Rough Charts
📈 A responsive, composable react charting library with a hand-drawn style.
Stars: ✭ 1,485 (+521.34%)
Mutual labels:  drawing
Gbox
🎨 A multi-platform graphic library
Stars: ✭ 216 (-9.62%)
Mutual labels:  drawing
Mypaint
MyPaint is a simple drawing and painting program that works well with Wacom-style graphics tablets.
Stars: ✭ 2,072 (+766.95%)
Mutual labels:  drawing
Librecad
LibreCAD is a cross-platform 2D CAD program written in C++11 using the Qt framework. It can read DXF and DWG files and can write DXF, PDF and SVG files. The user interface is highly customizable, and has dozens of translations.
Stars: ✭ 2,602 (+988.7%)
Mutual labels:  drawing
Ragg
Graphic Devices Based on AGG
Stars: ✭ 127 (-46.86%)
Mutual labels:  drawing
Drawbot
Drawing robot capable of rendering SVG paths over WebSockets. Powered by a Raspberry Pi running Node.js.
Stars: ✭ 142 (-40.59%)
Mutual labels:  drawing
Scribble.rs
A skribbl.io alternative - Play at https://scribblers-official.herokuapp.com/
Stars: ✭ 188 (-21.34%)
Mutual labels:  drawing
Pixelfarm
From Vectors to (sub) Pixels, C# 2D Rendering Library
Stars: ✭ 120 (-49.79%)
Mutual labels:  drawing
Pencil.js
✏️ Nice modular interactive 2D drawing library
Stars: ✭ 204 (-14.64%)
Mutual labels:  drawing
Mocodo
Modélisation Conceptuelle de Données. Nickel. Ni souris.
Stars: ✭ 113 (-52.72%)
Mutual labels:  drawing
Lazy Line Painter
Lazy Line Painter - A Modern JS library for SVG path animation
Stars: ✭ 1,918 (+702.51%)
Mutual labels:  drawing
Sketch
Sketch have a lot of basic functions to develop a drawing app for iPhone. Anyone can easily create drawing iOS Application.
Stars: ✭ 229 (-4.18%)
Mutual labels:  drawing
Autocadcodepack
AutoCAD Code Pack: A powerful library that helps you to develop AutoCAD plugins using the AutoCAD .NET API
Stars: ✭ 207 (-13.39%)
Mutual labels:  drawing
Librecad 3
LibreCAD 3 is a next generation 2D CAD application written to be modular, with a core independent from GUI toolkits. Scripting is possible with Lua.
Stars: ✭ 189 (-20.92%)
Mutual labels:  drawing

SwiftyDraw

Platform: iOS 9.1+ Language: Swift 5 CocoaPods License: MIT

Overview

SwiftyDraw is a simple, light-weight drawing framework written in Swift. SwiftyDraw is built using Core Gaphics and is very easy to implement.

Requirements

  • iOS 9.1+
  • Swift 5.0

Installation

Cocoapods:

SwiftyDraw is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'SwiftyDraw'

Carthage

SwiftyDraw is also available through Carthage. To install, add the following line to your Cartfile:

github "awalz/SwiftyDraw" "master"

Manual Installation:

Simply copy the contents of the Source folder into your project.

Usage

Using SwiftyDraw is very simple:

Getting Started:

Create a SwiftyDrawView and add it to your ViewController:

let drawView = SwiftyDrawView(frame: self.view.frame)
self.view.addSubview(drawView)

By default, the view will automatically respond to touch gestures and begin drawing. The default brush is .default, which has a black color.

To disable drawing, simply set the isEnabled property to false:

drawView.isEnabled = false

Brushes

For drawing, we use Brush to keep track of styles like width, color, etc.. We have multiple different default brushes, you can use as follows:

drawView.brush = Brush.default

The default brushed are:

public static var `default`: Brush { get } // black, width 3
public static var thin     : Brush { get } // black, width 2
public static var medium   : Brush { get } // black, width 7
public static var thick    : Brush { get } // black, width 10
public static var marker   : Brush { get } // flat red-ish, width 10
public static var eraser   : Brush { get } // clear, width 8; uses CGBlendMode to erase things

Adjusted Width Factor

SwiftyDrawView supports drawing-angle-adjusted brushes. This effectively means, if the user (using an Pencil) draws with the tip of the pencil, the brush will reduce its width a little. If the user draws at a very low angle, with the side of the pencil, the brush will be a little thicker. You can modify this behavior by setting adjustedWidthFactor of a brush. If you increase the number (to, say, 5) the changes will increase. If you reduce the number to 0, the width will not be adjusted at all. The default value is 1 which causes a slight de-/increase in width.

This is an opt-in feature. That means, in shouldBeginDrawingIn, you need to call drawingView.brush.adjustWidth(for: touch).

Further Customization:

For more customization, you can modify the different properties of a brush to fit your needs.

Line Color:

The color of a line stroke can be changed by adjusting the color property of a brush. SwiftyDraw accepts any Color:

drawView.brush.color = Color(.red)

or

drawView.brush.color = Color(UIColor(colorLiteralRed: 0.75, green: 0.50, blue: 0.88, alpha: 1.0))

We have our own implementation of UIColorColor – to be able to de-/encode it.

Line Width:

The width of a line stroke can be changed by adjusting the width property of a brush. SwiftyDraw accepts any positive CGFloat:

drawView.brush.width = 5.0

Line Opacity:

The opacity of a line stroke can be changed by adjusting the lineOpacity property. SwiftyDraw accepts any CGFloat between 0 and 1:

drawView.brush.opacity = 0.5

Editing

Clear All:

If you wish to clear the entire canvas, simply call the clear function:

drawView.clear()

Drawing History:

drawView.undo()

...and redo:

drawView.redo()

To en-/disable custom un- & redo buttons, you can use .canUndo and .canRedo.

Apple Pencil Integration

Apple Pencil can be used for drawing in a SwiftyDrawView, just like a finger.
Special features, however, regarding Apple Pencil 2 are only supported on iOS 12.1 and above versions.

Apple Pencil 2 Double Tap action

Enable/ Disable pencil interaction

Apple Pencil interaction is enabled by default, but you can set drawView.isPencilInteractive to change that setting.

Pencil Events

When double tapping the pencil, SwiftyDraw will check the user preferences set in the system. If the preference is set to switch to eraser, SwiftyDraw will switch between normal and erasing mode; if set to last used tool, SwiftyDraw will switch between current and previous brush.

Delegate

SwiftyDraw has delegate functions to notify you when a user is interacting with a SwiftDrawView. To access these delegate methods, have your View Controller conform to the SwiftyDrawViewDelegate protocol:

class ViewController: UIViewController, SwiftyDrawViewDelegate

Delegate methods

func swiftyDraw(shouldBeginDrawingIn drawingView: SwiftyDrawView, using touch: UITouch) -> Bool

func swiftyDraw(didBeginDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)

func swiftyDraw(isDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)
    
func swiftyDraw(didFinishDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)
    
func swiftyDraw(didCancelDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)

Contribution

This project was built by Awalz and is mostly maintained & improved by LinusGeffarth.

If you'd like to propose any enhancements, bug fixes, etc., feel free to create a pull request or an issue respectively.

Contact

If you have any questions, or just want to say Hi!, you can reach me via Twitter, or email.

LICENSE

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].