Drawsana is a generalized framework for making freehand drawing views on iOS. You can let users scribble over images, add shapes and text, and even make your own tools.
Do you want to let your users mark up images? Are you writing a simple painting app? Drawsana might work for you!
Blog post: Let your users mark up images on iOS with Drawsana
Like what you see? Come work with us!
Codable
, so you can save and load themAdd Asana/Drawsana
to your Cartfile and update your project like you would for any other
Carthage framework, or clone the source code and add the project to your workspace.
github "Asana/Drawsana" == 0.12.0
import Drawsana
class MyViewController: UIViewController {
let drawsanaView = DrawsanaView()
let penTool = PenTool()
func viewDidLoad() {
/* ... */
drawsanaView.set(tool: penTool)
drawsanaView.userSettings.strokeWidth = 5
drawsanaView.userSettings.strokeColor = .blue
drawsanaView.userSettings.fillColor = .yellow
drawsanaView.userSettings.fontSize = 24
drawsanaView.userSettings.fontName = "Marker Felt"
}
func save() {
let jsonEncoder = JSONEncoder()
jsonEncoder.outputFormatting = [.prettyPrinted, .sortedKeys]
let jsonData = try! jsonEncoder.encode(drawingView.drawing)
// store jsonData somewhere
}
func load() {
let data = // load data from somewhere
let jsonDecoder = JSONDecoder()
let drawing = try! jsonDecoder.decode(Drawing.self, from: jsonData)
drawsanaView.drawing = drawing
}
func showFinalImage() {
imageView.image = drawsanaView.render()
}
}
Drawsana does not currently have a way to automatically show an image under your drawing.
We recommend that, like in the example class, you add a UIImageView
underneath your
DrawsanaView
and make sure your DrawsanaView
's frame matches the image frame. When
it's time to get the final image, use DrawsanaView.render(over: myImage)
.
sudo gem install jazzy
make docs
open .docs/index.html
pip install ghp-import
make publish-docs
open https://asana.github.io/Drawsana
AddShapeOperation
RemoveShapeOperation
ChangeTransformOperation
EditTextOperation
ChangeExplicitWidthOperation
DrawingOperationStack.clearRedoStack()
clears all redo operations from the
redo stack.DrawingToolForShapeWithThreePoints
and
DrawingToolForShapeWithTwoPoints
are declared open
instead of public
so
they can be subclassed.PenShape
now works with the selection tool.DrawsanaView.selectionIndicatorAnchorPointOffset
allows Drawsana to
keep working when you change the anchorPoint.Shape.id
is now settable.NgonShape
and TextShape
serialization bugs. Old data can't be fixed, but
new data will be correct.Drawing.debugSerialization
.DrawingView.drawing
now behaves correctly instead of being unusably
buggy.PenLineSegment
's members are now public.ShapeTransform
and PenLineSegment
are now Equatable
.DrawsanaView.render()
accepts a scale
parameter instead of always using zeroDrawsanaView.selectionIndicatorViewShapeLayer
is exposed, allowing you to more
easily customize the appearance of the selection indicatorDrawsanaView.selectionIndicatorView
's style are animated in fewer
cases, which more closely matches user intentInitial release
link |
Stars: 635 |
Last commit: 1 year ago |
AddShapeOperation
RemoveShapeOperation
ChangeTransformOperation
EditTextOperation
ChangeExplicitWidthOperation
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics