Draw beautiful diagram effortlessly on ipad. Click here to know more..

Tuesday, September 17, 2013

Tuesday, September 3, 2013

Lekh Diagram for Android

Lekh Diagram for Samsung Galaxy S4 is now available for download from Samsung App store. It can be downloaded from http://www.samsungapps.com/appquery/appDetail.as?appId=com.avabodh.lekh.s4

The Lekh Diagram will be soon available on Play Store for other Android devices.


Check out demo on S4



To know more about Lekh Diagram: http://www.avabodh.com/lekh





Tuesday, April 9, 2013

Lekh Diagram 1.3 is now on App Store

The Lekh Diagram version 1.3 is now on App Store. This update contains following enhancements:

  • Resizing shapes in horizontal and vertical directions independently. To do this: select a shape, tap on right bottom corner of selection rectangle (a dotted circle at corner) then move the vertex handle.
  • Box support. Diagram can be uploaded to Box and can also be imported from Box
  • Enhancing Dropbox upload experience. If a file with same name already exists, then update the same file instead of creating new file every time.
  • Few other bug fixes


Latest Demo:

Saturday, March 23, 2013

Variable size text view in iOS (iPad and iPhone)

Based on specific need, you may want a variable size text view on iOS as

  • Fixed width. Vary height based on length of text
  • Vary both width and height, based on length of text. You will increase height if new line is added otherwise increase width.
These two kinds of text views are used in "Lekh Diagram" app. This is a diagramming app. You can add text on a shape, or free floating text. If text is added on a shape, then width of text is constrained to the width of shape. The free floating text has variable width and height.

Lets see how to do in code:
Add to text boxes, one for fixed width and other for variable width and height.

In ViewController.h

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *textView1;
@property (weak, nonatomic) IBOutlet UITextView *textView2;
@end

In ViewController.m

#import "ViewController.h"

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.textView1.delegate = self;
    self.textView2.delegate = self;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
-(BOOL)shouldAutorotate
{
    return NO;
}
- (void)textViewDidChange:(UITextView *)textView
{
    // textView2 has variable width and variable height
    if (textView == self.textView2) {
        // max widht and height: some random big value
        float maxWidth = 40000;
        float maxHeight = 40000;
        
        CGSize sz = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(maxWidth, maxHeight)];
        
        // There is some margin around text view. we need to consider margin,
        // otherwise there will text wrapping without new line.
        sz.width += 32;
        sz.height += 16;
        
        CGRect frame = textView.frame;
        frame.size = sz;
        textView.frame = frame;
    }
    else {
        // textView1 has fixed width and variable height
        CGRect frame = textView.frame;
        frame.size.width = textView.contentSize.width;
        frame.size.height = textView.contentSize.height;
        textView.frame = frame;
    }
}
@end


In code above, textView2 has variable width and height and textView1 has fixed width.
Download code from here

The code above is based on code used in "Lekh Diagram", a sketch recognition diagramming app for iPad and iPhone.
Get "Lekh Diagram" from app store: https://itunes.apple.com/us/app/lekh-diagram/id576124115?mt=8


Monday, March 4, 2013

Lekh Diagram now available for iPhone

Lekh Diagram is a sketch recognition diagramming app for iOS. It enables you to draw diagrams simply by sketching with your finger. The Lekh Diagram has a powerful shape recognition capability. It can recognize shapes you sketch and will convert them into regular shapes (e.g circle, rectangle etc) and connections.

The Lekh Diagram was initially released for iPad and now it is available for iPhone too. It is a universal app, which will run on both: iPhone and iPad.

The new release also adds support for a most wanted feature: zooming drawing canvas. This feature is available on both: iPhone and iPad

The UI of iPhone version is designed such a way that, you will get almost full of the screen as drawing area. It has a small tool bar which can be collapsed. When the toolbar is collapsed, you will get whole of the screen as drawing area except for small corner area where there is expand button.

The zooming drawing canvas feature will be very useful on iPhone. You can draw various shapes on normal zoom and then later can view whole of the diagram by zooming out. You can also do most of the re-arrangement of shapes while canvas is zoomed-out.

App store link: https://itunes.apple.com/us/app/lekh-diagram/id576124115?mt=8
Learn more about Lekh Diagram: http://www.avabodh.com/lekh
Get updates on twitter: https://twitter.com/avabodh

iPhone version demo


Tuesday, February 12, 2013

Lekh Diagram: iPhone support coming soon

"Lekh Diagram" is a sketch recognition diagramming app. It recognizes rough sketches and convert them into regular shapes like rectangle, circle etc.

The "Lekh Diagram" was first released for iPad and now the next update is adding iPhone support.

The the screen of iPhone is much smaller as compared to iPad, so the UI of "Lekh Diagram" (iPhone version) has been designed so that you will have almost full screen of the iPhone for drawing purpose. There is small toolbar which can be collapsed and expanded.

The iPhone version has all those functionalities that the iPad version has.

The next update also adding feature of zooming canvas. This feature will be available on both iPhone and iPad.

Here is a demo of iPhone version


http://www.avabodh.com/lekh
https://twitter.com/avabodh










Saturday, February 2, 2013

Touch gestures in iOS (iPhone, iPad) sdk

iOS sdk provides simple and powerful touch gesture API. With few lines of code, you can make your app touch/multitouch aware.
In this blog post, I am posting code snippet for using touch gesture in iOS app. The code snippet is taken from a drawing app: Lekh Diagram
The Lekh Diagram heavily uses touch gestures. Here are touch gestures used by Lekh Diagram

  • pan
  • two finger drag
  • tap
  • double tap
  • long press
  • pinch
  • rotate
All these gestures are used in the app on the drawing canvas. The Lekh Diagram registers and handles all multitouch events except "two finger drag". The two finger drag is handled by UIScrollView. 

Here is code snippet for registering gesture events:

The Lekh Diagram has drawing canvas which derives from UIView as
@interface DrawingView : UIView
@end

In the constructer of this class, following code registers for events.

// *******************************************************************
    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc
                                          initWithTarget:self action:@selector(handlePanGesture:)];
    panGesture.minimumNumberOfTouches = 1;
    panGesture.maximumNumberOfTouches = 1;
    [self addGestureRecognizer:panGesture];
    

// ****************************************************************
    UITapGestureRecognizer *doubleTap = 
    [[UITapGestureRecognizer alloc]
     initWithTarget:self action:@selector(handleDoubleTapGesture:)];
    [doubleTap setNumberOfTapsRequired:2];
    [self addGestureRecognizer:doubleTap];
    

// ****************************************************************
    UITapGestureRecognizer *tapGest = 
    [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
    [tapGest requireGestureRecognizerToFail:doubleTap];
    [self addGestureRecognizer:tapGest];
    

// *******************************************************************
    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
    longPressGesture.minimumPressDuration = 1;
    [self addGestureRecognizer:longPressGesture];
    

// *********************************************************************
    UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handleZoom:)];
[self addGestureRecognizer:pinchRecognizer];
    
// *******************************************************************
    UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotate:)];
[self addGestureRecognizer:rotationRecognizer];


Here are event handler functions

-(IBAction)handleLongPress:(UILongPressGestureRecognizer*)sender{  
    if(UIGestureRecognizerStateBegan == sender.state) {
     // long press handler code
   }
}

-(IBAction)handleRotate:(UIRotationGestureRecognizer*)sender{
  if([sender state] == UIGestureRecognizerStateEnded) {
     // handler code for rotation end

   }

    else if([sender state] == UIGestureRecognizerStateBegan){

       // handler code for rotation start
    }
    else{
        double rotation = [sender rotation]; // amount of rotation
        // handler code for rotation in progress
    }

}

-(IBAction)handleZoom:(UIPinchGestureRecognizer*)sender{
    if([sender state] == UIGestureRecognizerStateEnded) {
        // handler code for pinch end
    }
    else if([sender state] == UIGestureRecognizerStateBegan){
      // handler code for pinch start
    }
    else{
        CGFloat scale = [(UIPinchGestureRecognizer*)sender scale]; // amount of pinch
       // handler code for pinch progress
    }

}

-(IBAction)handlePanGesture:(UIPanGestureRecognizer *)sender{
     CGPoint location = [sender locationInView:self];  // current touch position
      if(sender.state == UIGestureRecognizerStateEnded){
        // handler code for panning end
      }
      else if(sender.state == UIGestureRecognizerStateBegan){
         // handler code for panning starts
      }
      else {
         // handler code for panning in progress
      }

}

- (IBAction)handleTapGesture:(UIGestureRecognizer *)sender {
    CGPoint location = [sender locationInView:self]; // tap location
   // handler code for tap
}

- (IBAction)handleDoubleTapGesture:(UIGestureRecognizer *)sender {
    CGPoint location = [sender locationInView:self]; // double tap location
    // handler code for double tap
}




Here is demo of Lekh Diagram, you can see touch gesture in action in this video




Tuesday, January 1, 2013

My first Android app after a year

Scratchpad completes one year on google play store today. The Scratchpad is my first mobile app. I developed it during my last winter vacation. I took total of 5 days to learn (Android app development) and develop this app. This is a very very simple drawing app (similar to mspaint), no fancy features.

In this blog post, I am posting download statistics over the year. These data might be helpful to other Android newbie developers. The images below are screenshots from the android developer console.

Total downloads stat:





The total number of downloads are not much. But this is not bad at all if I consider the fact that this is my first app, total time I spent to develop this app and features provided by this app.




Active device install stat over the year:










Initially number of downloads per day were very small.  In fact, there was no download in initial few days. Then I posted about this app on reddit (/r/androidapps), then people started downloading it.




Active device install by Android version:






















The Android version 2.3 is at top for productivity app but the Scratchpad is available only for Android version 3.0 and higher.




Active device install by country:



The United States is at the top of this list. This is an interesting data. I am finding similar statistics for my iPad app (Lekh Diagram, a sketch recognition app for iPad). Even for the Lekh Diagram, more than 50% downloads are from US