Smooth line drawing in as3

I am looking for a smoothe line drawing effect as in the pencil tool in Flash. I need to implement the same using as3. Any idea how I can achieve that?

Smoothness is a relative concept. Pencil tool in Flash doesn't produce very smooth lines. Nevertheless, runtime drawing smoothness depends on how often you draw lines between points. Here is a quick and dirty drawing board (just paste it on timeline). If you want it even smoother - you will need to write an algorithm that takes into account direction, speed, angles, etc.
var board:Sprite = new Sprite();
addChild(board);
board.x = board.y = 20;
var g:Graphics = board.graphics;
g.beginFill(0xcccccc);
g.drawRect(0, 0, stage.stageWidth - 40, stage.stageHeight - 40);
g.endFill();
board.addEventListener(MouseEvent.MOUSE_DOWN, startDraw);
function draw(e:MouseEvent):void {
     g.lineTo(board.mouseX, board.mouseY);
function startDraw(e:MouseEvent):void {
     stage.addEventListener(MouseEvent.MOUSE_UP, stopDraw);
     addEventListener(MouseEvent.MOUSE_MOVE, draw);
     g.lineStyle(1, Math.random() * 0xffffff);
     g.moveTo(board.mouseX, board.mouseY);
function stopDraw(e:MouseEvent):void {
     removeEventListener(MouseEvent.MOUSE_MOVE, draw);
     stage.removeEventListener(MouseEvent.MOUSE_UP, stopDraw);

Similar Messages

  • HELP - CONVERTING A JPEG IMAGE INTO A LINE DRAWING

    PLEEEASE HELP ME!!!
    sorry to be thick - im only a beginner   ---   is there any way to covert a jpeg image into like a line drawing where there is a block colour background and solid lines that make up the picture like you sometimes get in brochures - somthing different to just the effects that are availible in the filter gallery...
    thanks
    LUK

    As far as I recall there's no magic/easy "convert to vector drawing" functionality in Photoshop, though there are some things you can do to help smooth rough edges (e.g., Filter - Noise - Median).  There are also some things you can do, if you want to get fancy, based on converting selections to paths, but that can get kind of involved and likely requires manual path editing afterward.
    I have heard there are some pretty decent vector conversion functions in other Adobe apps...  Adobe Illustrator, perhaps?  Someone who uses Illustrator may want to chime in here; I don't have that package.
    -Noel

  • How to make smooth line movement?

    Hello!
    I've been searching it everywhere, but couldn't find anything in the net. I want to make smooth line movement. I've tried to create motion, but line just moves, and I want it to move smoothly according to the path. What I want to achieve can be seen here:
    http://www.noartistname.com/demo/
    But that's what I did so far - made movement out of several broken lines - how can I make more smooth movement?
    Thanks,
    Aleks.

    the easiest for non-coders is to tween a mask of the full line.  you can also use the flash drawing methods but that takes some coding.  see:
    www.kglad.com , click snippets, function graphs.

  • Healing Brush "skips", leaves a line of brush-sized circles instead of a smooth line

    When I use the healing brush is tends to "skip".  It leaves a line of circles like a stamp would instead of a flowing line like it should leave.  No matter how slow I move the brush it leaves a circle and then as I continue to draw nothing happens until I reach the edge of the first circle, it then drops another circle and it continues that way as long as I draw with it.   The brush tool works fine, leaves a smooth line.  The Spot Healing and Patch Tool work fine but the healing brush will not heal in a smooth stroke.  It skips along a leaves a tail of circles the size of the brush.  I am using a fast computer, i7 processor, 16bg ram and a SSD drive so I do not think speed is an issue.  I upgraded from CS4 where the healing brush worked fine on this computer

    If the spacing of a tool's brush is 100% then it will behave as you described.
    Reduce the spacing to get a stroke without circles.
    Reset Tool as shown by R_Kelly will set the spacing to 25%, but it'll also reset the size and hardness of the brush and reset other options of the tool.

  • I have a line drawing (black on white paper) i have scanned and need to make the white paper transparent, maintaining the line drawing, can i and then HOW can i do this in PS?

    i have a line drawing (black on white paper) i have scanned and need to make the white paper transparent, maintaining the line drawing, can i and then HOW can i do this in PS? this is for my business logo. ive used it for years but with a solid background. id like to have it just be the drawing over my photos with a transparent background.

    First let me apologize for posting a reply that was only suitable for advanced users.  Photoshop is broad and powerful therefore has a huge learning curve.  In fact I would state no one knows and uses all of Photoshop.  When we first get Photoshop it intimidate us and we're very uncomfortable using it.  Many thing are not intuitive there in much learning involved.  After some time we begin to know something and we are able to do some thing.  Learning become rapid and we start playing in Photoshop.  It is very important to play with Photoshop.  Playing with Photoshop and asking for help with in forums like this IMO is the best way to learn. 
    Photoshop Power lies in layers, selection and automation.  However it takes knowledge to use photoshop well so most powerful tool you have ins Photoshop is the gray matter between your ears.  Most at one time or another want to watermark or put a logo on their image.  So its best to automate this process. All run into a problem in the process. "Size"  We find our assets vary in size and aspect ratios. Landscape, Portraits, Panoramas and others. This complicates automation.  Vector graphics works best when size vary greatly.  If you can not work out how to create a vector solution like a custom shape.  Create your Logo and watermark large thing scale down better the up. Text scale well for text uses vectors graphics however if you rasterize text it will not scale well.
    I do not type or do English well so let me do some screen captures.  I can not stress enough how important Black, White, Grays and Blending is when it come to image processing.  Become friends with Multiply, Screen, Overlay and Luminosity blending.....
    However when there is a white or black background though you can blend them you can not add a style like a drop shadow, emboss or make it invisible setting fill to 0 so only the style is visible.  When there is contrast between the logo and background it is easy to separate the two. To select the background and delet it to have the logo with a transparent background.  Many tools can be used to create the selection hee I use my action kill white.
    Vector Shape would work better for scaling However it would be best to create the logo from scratch in a vector program like illustrator but I never had the resources to justify the Creative suite. I only had Photoshop.  Recently Adobe gave me and other a year subscription to the creative suite for our participation here.  I still have not installed anything but Photoshop,  A while back I found a program that can create vector patf for black and white art work.  It will not be as good as using something like illustrator. However vector paths can be edited in Photoshop and cleaned up some. Here is the PSD it 13MB because od the gradient http://www.mouseprints.net/old/dpr/AmPm24-7.psd

  • I tried to import a PDF of a line drawing into Photoshop Elements. The thumbnail looks fine, but when imported the file is empty. This used to work in the past. What is wrong and how do I solve this?

    I tried to import a PDF of a line drawing into Photoshop Elements. The thumbnail looks fine, but when imported the file is empty. This used to work in the past. What is wrong and how do I solve this?

    Hi
    The value of the Channel Strip volume etc is not stored within the C Strip setting, as you have discovered.
    If you really wanted, you could add a Gain plug to the strip, with it set to give the correct output level with the Fader set to 0
    (Or just set the fader manually in MS)
    CCT

  • How to create a smooth line chart in dashboard design?

    hello everyone, i am creating a line chart but found that there is no smooth line option to choose in line chart component... is there anyway this can be done? thanks in advance

    Hi ,
    Check this link
    How to make a Line Chart curved instead of straight from point-to-point?
    Regards
    Rajesh

  • Convert a photo to a single line drawing

    It seems I've seen this in one of the photoshop tips & tricks books but did not buy the book. Any suggestions will be appreciated.

    http://www.myjanee.com/tuts/linedraw/linedraw.htm
    Also, Google for "photoshop elements line drawing" or similar.

  • [SOLVED] terminals & line drawing characters problem

    I use quite some escape sequences in my bash prompt, amongst them a few that produce line drawing characters. Works fine in the virtual consoles (tty), but no terminals in X (tried xterm, terminal, urxvt) display them correctly, for some reason. My locale settings seem fine, and I've tried various fonts (including the one I use in the virtual consoles).
    What could the issue be?
    FYI, my bash prompt variable. Does it display correctly for you?
    DRED='\e[0;31m'
    DGREEN='\e[0;32m'
    DYELLOW='\e[0;33m'
    DBLUE='\e[0;34m'
    DPURPLE='\e[0;35m'
    DCYAN='\e[0;36m'
    DWHITE='\e[0;37m'
    LRED='\e[1;31m'
    LGREEN='\e[1;32m'
    LYELLOW='\e[1;33m'
    LBLUE='\e[1;34m'
    LPURPLE='\e[1;35m'
    LCYAN='\e[1;36m'
    LWHITE='\e[1;37m'
    COLRESET='\e[0m'
    PS1="\n\[$DBLUE\]\[\016\]l\[\017\]\[$DRED\](\u@\h)\[$DBLUE\]\[\016\]qqq\[\017\](\[$LBLUE\]H\!\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]C\#\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]J\j\[$DBLUE\])\[\016\]qqq\[\017\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\016\]t\[\017\]\[\016\]q\[\017\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\016\]mqq\[\017\]> \[$LBLUE\]"
    Last edited by Mzg (2010-07-09 10:00:41)

    After some detective work I have managed to come up with an explanation as well as what seems to be a working solution.
    If you have not tried the prompt above, basically I tried to use some line drawing characters in my bash prompt, but these refused to display correctly under any X terminals I tried (though it looked fine on virtual consoles).
    The problem was in the
    \[\016\] ... \[\017\]
    sequences. The \016 escape sequence is supposed to enter the alternate character set mode (common way to draw e.g. lines in text mode) while \017 returns the terminal to the standard character set. These work fine on the virtual consoles, but are apparently a no-no in (some) X terminals. If you tried the prompt you would notice that the color escape sequences worked fine, only the line drawing characters failed.
    So that is the explanation part. So for the solution...
    For urxvt, which is my preferred terminal emulator, the solution is quite simple. This should also work with other rxvt-derived terminals (including the popular aterm), though I have not tested this.
    These terminals offer the same functionality as the virtual consoles, though the escape sequences are different. "\033(0" enters alternate charset mode while "\033(B" returns to standard charset mode. So the solution is simply to replace all previous
    \[\016\] ... \[\017\]
    sequences with
    \[\033(0\] ... \[\033(B\]
    But this poses a problem, as the virtual consoles do not recognize these sequences and you'll get the same problem as before, only in text mode instead of X. I solved this by using the PROMPT_COMMAND variable to run fgconsole every time a command is ran in bash, checking if the command is ran in tty7 (i.e. X11) or in one of the (other) virtual consoles. This is my code for the root prompt:
    DRED='\e[0;31m'
    DGREEN='\e[0;32m'
    DYELLOW='\e[0;33m'
    DBLUE='\e[0;34m'
    DPURPLE='\e[0;35m'
    DCYAN='\e[0;36m'
    DWHITE='\e[0;37m'
    LRED='\e[1;31m'
    LGREEN='\e[1;32m'
    LYELLOW='\e[1;33m'
    LBLUE='\e[1;34m'
    LPURPLE='\e[1;35m'
    LCYAN='\e[1;36m'
    LWHITE='\e[1;37m'
    COLRESET='\e[0m'
    function prompt_func
    # Running in tty7 or larger (X11)
    if [ `sudo fgconsole` -gt 6 ]
    then
    PS1="\n\[$DBLUE\]\[\033(0\]l\[\033(B\]\[$DRED\](\u@\h)\[$DBLUE\]\[\033(0\]qqq\[\033(B\](\[$LBLUE\]H\!\[$DBLUE\])\[\033(0\]qq\[\033(B\](\[$LBLUE\]C\#\[$DBLUE\])\[\033(0\]qq\[\033(B\](\[$LBLUE\]J\j\[$DBLUE\])\[\033(0\]qqq\[\033(B\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\033(0\]t\[\033(B\]\[\033(0\]q\[\033(B\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\033(0\]mqq\[\033(B\]> \[$LBLUE\]"
    else
    PS1="\n\[$DBLUE\]\[\016\]l\[\017\]\[$DRED\](\u@\h)\[$DBLUE\]\[\016\]qqq\[\017\](\[$LBLUE\]H\!\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]C\#\[$DBLUE\])\[\016\]qq\[\017\](\[$LBLUE\]J\j\[$DBLUE\])\[\016\]qqq\[\017\](\[$LBLUE\]\D{%H:%M %A %d - %B %Y}\[$DBLUE\])\n\[\016\]t\[\017\]\[\016\]q\[\017\](\[\[$LBLUE\]\w\[$DBLUE\])\n\[\016\]mqq\[\017\]> \[$LBLUE\]"
    fi
    PROMPT_COMMAND=prompt_func
    Note that I do not claim to be a good bash programmer, so there might be better ways. This has however worked flawlessly so far, including when su'ing to other users, and switching between tty's and X.
    The code is the same for my other users, except from the colors. Note the
    `sudo fgconsole`
    Sudo proved necessary for non-root users. I added an entry in the sudoers config file to let all users run fgconsole as root without providing a password.
    Okay, that's it. It's a bit dirty, but it solved my problem at least.
    Last edited by Mzg (2010-07-10 07:06:44)

  • Want to do pencil line drawing based on photograph

    PS Elements has a really neat quick line drawing effect.  I'd like to do something similar in PS CS3.  Does anyone know how?  I've been trying the sketch filter, but it doesn't seem quite as nicely done.  Can I use that action out of my elements folder in CS3?  Elements regularly freezes my computer which is why I'm not using it any longer and intend to uninstall soon.
    THanks!

    It all depends on the original.
    You might have success with Image > Mode > Grayscale
    Then increase Contrast via Image > Adjustments
    followed by Filter > Stylize > Find Edges and a Threshold adjustment if necessary.
    You have to experiment!

  • Unicode line-drawing characters - possible Java bug?

    Hi all, I am trying to draw a box using line drawing characters in UTF-8. I make the UTF-8 box file in Microsoft Word where it looks aligned. However, when I run my Java program to display the box in a JTextArea, it is all out of alignment like below. Is this a bug in Java that prevents it from displaying aligned line-drawing characters? I am tearing my hair out over this so your help is much appreciated.
    Regards,
    Rianmal.
    ╔═══════════════════╗
    ║║║║║║║║║║║║║║║║║║║║║
    ║ ║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║
    ╚═══════════════════╝

    sabre,
    Looks like monospaced isn't found on windows (vista)... So I used "Courier New" instead.
    Sabre20090412a.java is saved with encoding=UTF-8 (i.e. CP1252) instead of the default ASCII, which doesn't support the extended characters.
    package forums;
    import java.awt.Font;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    public class Sabre20090412a
      private static final String text;
      static {
        String t;
        t =  "╔═══════════════════╗\n"; // LINE 12
        t += "║║║║║║║║║║║║║║║║║║║║║\n";
        t += "║                   ║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "║∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙║\n";
        t += "╚═══════════════════╝\n"; // LINE 23
        text = t;
      public static void createAndShowGUI() {
        final JFrame frame = new JFrame("Test");
        final JTextArea ta = new JTextArea();
        ta.setFont(new Font("Courier New", Font.PLAIN, 14)); // <<<<< Note font-name="Courier New"
        ta.setText(text);
        frame.setContentPane(ta);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            createAndShowGUI();
    build (NOTE the -encoding utf-8)*
    cd /d C:\Java\home\src\forums
    "C:\Program Files\Java\jdk1.6.0_12\bin\javac.exe" -encoding utf-8 -Xlint -d C:\Java\home\classes -cp c:\java\home\src;.;C:\Java\home\classes C:\Java\home\src\forums\Sabre20090412a.java
    run
    cd /d C:\Java\home\src\forums
    "C:\Program Files\Java\jdk1.6.0_12\bin\java.exe" -cp C:\Java\home\classes forums.Sabre20090412a
    References:
    http://www.google.com/search?q=warning%3A+unmappable+character+for+encoding+Cp1252&hl=en
    http://en.wikipedia.org/wiki/Windows-1252 #says 1252== IANIA UTF-8 except
    http://www.utf8-chartable.de/unicode-utf8-table.pl #page for 2500 onwards
    http://forums.sun.com/thread.jspa?threadID=5185338 #-encoding
    http://www.java2s.com/Code/Java/2D-Graphics-GUI/Listallavailablefontsproviedinthesystem.htm
    Roedy Green rocks!
    http://mindprod.com/jgloss/font.html#AVAILABLEJ
    http://mindprod.com/applet/fontshower.html
    Thanx for the fish!
    Cheers. Keith.

  • Line Drawing best file format for import in InDesign

    i was wondering what is  the accepted and recommended file format for files to be imported in InDesign. I was under the impression that AI files should be saved as EPS but I just read an article that says that Adobe's Dov  Isaacs said that eps will be shortly obsolete.What should I do. I work on curriculum that contains both photographs and line drawing and we use tiff for the former and eps for the latter. Most of our line drawing is done in AI. Howeverwe have a cartoonist that sends us files in jpg format. What would be the best file format for him and for us as we draw in AI?
    Article link: http://www.prepressure.com/library/file-formats/eps
    The future of the EPS file format
    EPS is rapidly becoming an outdated file format which is being  replaced by PDF just like PostScript itself is also being phased out and  replaced by PDF. Don’t just take my word on this. Here is what Dov  Isaacs from Adobe said in a discussion on a PrintPlanet forum about the  future of PostScript: “ …Adobe will continue to support EPS as a  legacy graphics format for import of non-color managed, opaque graphical  data into Adobe applications (such as InDesign and Illustrator).  Although we certain do not recommend that new graphical content be  stored in EPS format (except to satisfy the need to import data into  page layout programs that aren’t quite PDF-centric — no need to mention  names here!), our user base should feel comfortable that there is no  need to worry about a need to convert their very sizable libraries of  EPS-based graphic assets.”

    Yes, I drag the AI file in.
    If after it's in place I need to change I can just right click and chose edit original make the changes and save and the illustration in inDesign will reflect the changes.
    On the other hand I can make changes to the original and all iterations of the file will automatically update, say if I used the illustration in several documents.
    As an example I had completed a set of documents for a new company, i.e., biz cards, brochures, product labeling, stationery, etc. and in their wisdom they decided to make changes in their logo, which, of course, is on everything. I opened the AI file with the logo made the changes saved and all the documents then reflected the changes. The only caveat to do this seamlessly is to make sure that your file logo size is the same as the original or you might have to tweak placement in the other documents
    It is this interoperability that to me makes the Creative Suite so much more than the sum of their parts.
    Craig

  • How do I change the white background color in a b/w line drawing jpg?

    How do I change the white background color in a b/w line drawing jpg?

    Just put a Solid Color Layer atop it and set it to Blend Mode Multiply or
    • load the Channel with the best contrast (cmd-click it in the Channels Panel)
    • invert Selection (cmd-I)
    • create a black Solid Color Layer
    • put whatever below that Layer

  • Simple line drawing project in swing

    hi folks,
    i want to write a simple line drawing project. it has a JPanel, a JFrame and JButton.
    JPanel and JButton are on JFrame. When Button is clicked,
    a line will be added to JPanel but previous lines which have been added are not removed on JPanel.
    Could you please help me?

    i wrote below codes but it adds first line but when click button �n order to add line, it is not adding line. Please help and thanxs...
    import java.awt.BasicStroke;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.geom.Line2D;
    import java.util.Enumeration;
    import java.util.Vector;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.WindowConstants;
    import javax.swing.SwingUtilities;
    public class NewJFrame extends javax.swing.JFrame implements ActionListener {
         private JButton addButton;
         MainPanel mainPane ;
         public Vector lines ;
         * Auto-generated main method to display this JFrame
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        NewJFrame inst = new NewJFrame();
                        inst.getContentPane().add(new MainPanel(inst.lines));
                        inst.setLocationRelativeTo(null);
                        inst.setVisible(true);
         public NewJFrame() {
              super();
              initGUI();
              lines = new Vector();
              lines.add(0, 30);
              addButton.addActionListener(this);
         private void initGUI() {
              try {
                   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                        addButton = new JButton();
                        getContentPane().add(addButton, BorderLayout.SOUTH);
                        addButton.setText("ADD");
                        addButton.setPreferredSize(new java.awt.Dimension(71, 21));
                   pack();
                   setSize(400, 300);
              } catch (Exception e) {
                   e.printStackTrace();
         @Override
         public void actionPerformed(ActionEvent e) {
              if(e.getSource() == addButton){
                   lines.addElement(Integer.parseInt(lines.get(0).toString())+30);
                   mainPane.repaint();
    class MainPanel extends JComponent {
         Vector tempLines ;
         MainPanel(Vector lines){
              tempLines = lines;
              setBackground(Color.white);
         public void paintComponent(Graphics g) {
              Enumeration enumeration = tempLines.elements();
              while(enumeration.hasMoreElements()) {
                   Integer point = Integer.parseInt(enumeration.nextElement().toString());
                   Line2D line = new Line2D.Double(30, point, 200, point);
         Graphics2D g2d = (Graphics2D)g;
         g2d.setStroke(new BasicStroke(5));
         g2d.draw(line);
    }

  • How to make smooth line by brush tool using shift key?

    Heya, I have a short question. Is there a way to make smooth line by brush tool using shift key, without that characteristic dot on the begining? I'm using PS CS6 on Win7.
    http://i.imgur.com/orGsIwv.jpg
    Cheers

    The shift key constrains the brush to paint a straight line. Those dark spots you see are from two paint strokes overlapping each other. If the flow or opacity of the brush is not at 100% you can see the stroke below it.

Maybe you are looking for