Ti.Paint Smoothing
Just thought I'd pass this on. I forked and update the Ti.Paint module so you can use Bezier based smoothing/correction, i.e., so the you can draw curves rather that jagged lines.
I also updated it so you can open the PaintView with an image inside it. It is handy if you want to edit/erase parts of an image you have drawn and saved (with toImage()) previously.
An example would be like this:
var paint = require("ti.paint");
var paint_view = paint.createPaintView({
strokeWidth : 6,
strokeColor : '#d50000',
zIndex : 10,
bottom : 30,
top : 0,
image: '/Default.png',
useBezierCorrection: true
});
I popped in a pull request. But while you wait you can get a compiled version from my github repo here.
7 Answers
-
Accepted Answer
My TiPaint fork has been updated again.
In short here are some of the new features:
- Smoothing now occurs as you draw as apposed to when you lift your finger.
- There are now drawing "modes": ERASE, STRAIGHT_LINE, CURVE_LINE, CIRCLE, RECTANGLE. So you can now draw ellipses and rectangles if you like.
- Also experimenting with dynamic width based on speed when using CURVE_LINE (very early stages).
Please look at the example app.js as the interface with the module has changed.
-
Hi David,
Any chance to get a compiled copy?
Unable to get it compiled under Windows + Android.
Getting errors after changing all properties to windows (Ti 1.8.2):
The constructor TiViewProxy(TiContext) is undefined
Error within Debug UI: java.lang.reflect.InvocationTargetException
-
Thanks David, added it to LearningTitanium site.
-
Thanks David, it's a good update.
I can load a image form file into the new PaintView, but can't load a Blob into the new PaintView. Can I use any way to load a Blob image to show on the new PaintView? Thank you very much!Sample code like this,
var paintView = Ti.Paint.createPaintView({
image : blob,
top : 0,
right : 0,
bottom : 0,
left : 0,
});
the PaintView does't show any thing. -
Hi, is it possible to have a compiled version of TiVinci? I tried to do it myself but I always get a lot of errors (No module named tools for instance).
-
Thanks again for this plugin. It works perfectly for my app. By the way, the ellipse is extremely slow on retina screens. Is it possible to improve it?
And I would like to add a "text" tool to insert some text on the painter canvas. Is there a way to transfer some label content into the paint canvas (through the .toImage(à methid for instance) ?
-
Just added straight line drawing to the module.
So if you want draw a straight line from from touchStart to touchEnd, just do the following:
paint.straightLineMode = true;
Binary also updated in the github repo (link above).