Search code examples
iostitaniumpainttitanium-mobileappcelerator-mobile

transparent erase in iOS- Titanium


I have two images one on the above and i want to erase a small part from the top image to show the background image. Is it possible transparent erase using titanium for iOS?

Thanks and regards, GANESH M


Solution

  • You can do this using the ti.paint module. Specifically, its ability to have an image on the canvas which can be erased. After installing, try this:

    // Container window
    var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
    // Background image
    var backgroundImage = Ti.UI.createImageView({
        image : 'yourbgimage.png'
        width : Ti.UI.FILL,
        height : Ti.UI.FILL
    });
    
    // Require paint module and add to view with an erasable image
    var Paint = require('ti.paint');
    var paintView = Paint.createPaintView({
        image : 'yourfgimage.png', // This is the image you erase
        eraseMode : true,
        width : Ti.UI.FILL,
        height : Ti.UI.FILL,
        strokeColor : '#0f0', strokeAlpha : 255, strokeWidth : 10
    });
    
    win.add(backgroundImage);
    win.add(paintView);
    win.open();