Giter VIP home page Giter VIP logo

potraxe's Introduction

Potraxe

Haxe port of potrace - http://potrace.sourceforge.net/

Install via haxelib with

haxelib git potraxe https://github.com/UltraVisual/Potraxe

Basic trace text example - note the huge font size - this is for better precision as smaller font sizes look less precise in the final drawing but larger ones take up more computation times.

Text tracing

package ;
import flash.Lib;
import flash.display.Sprite;
import uk.co.ultravisual.potraxe.Potraxe;
import flash.display.Sprite;

class TextSample extends Sprite {

    private static var xPos:Float = 0;

    @final private static var PADDING:Float = 30;
    @final private static var SCALE:Float = 0.45;

    public function new():Void {
        super();

        addChild(drawWord('Potraxe'));
    }

    private function drawWord(word:String):Sprite {
        var container:Sprite = new Sprite();
        for (i in 0...word.length) {
            var sprite:Sprite = Potraxe.drawLetter(word.charAt(i), 600, 'Arial', 0.5, 0xff6600, 0xff6600, 0.4);
            sprite.x = xPos;
            xPos += sprite.width + PADDING;
            container.addChild(sprite);
        }
        container.scaleX = container.scaleY = SCALE;
        container.x = ((Lib.current.stage.stageWidth - container.width) * 0.5) - 20;
        return container;
    }
}

Bitmap tracing

Basic trace bitmap example

package ;

import flash.display.Sprite;
import uk.co.ultravisual.potraxe.Potraxe;
import uk.co.ultravisual.potraxe.ClosedPathList;
import flash.display.Bitmap;
import flash.display.BitmapData;

@:bitmap("assets/manga.png") class HaxeImage extends BitmapData {}

class BitmapSample extends Sprite{

    public function new() {
        super();
        var bmp:Bitmap = new Bitmap();
        var bmd:BitmapData = new HaxeImage(263, 357);
        bmp.bitmapData = bmd;
        addChild(bmp);
        bmp.alpha = 0.5;

        var curvesList:ClosedPathList = Potraxe.traceBitmap(bmp.bitmapData);

        var sprite:Sprite = new Sprite();
        sprite.graphics.lineStyle(0.5, 0x0066ff);
        sprite.graphics.beginFill(0x0066ff, 0.4);
        curvesList.draw(sprite.graphics);
        sprite.graphics.endFill();
        sprite.x = bmp.width;
        addChild(sprite);
    }
}


potraxe's People

Contributors

ultravisual avatar

Watchers

Stéphane Le Dorze avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.