Fill shape with a pattern

Hi,
I am drawing some shapes using java.awt.Shape, java.awt.geom.Area and java.awt.geom.GeneralPath and would like to know whether it's possible to fill these closed shapes with a color - or even better - with a pattern.
Thanks!

er, yes, why not?
http://java.sun.com/docs/books/tutorial/2d/geometry/strokeandfill.html
-Puce

Similar Messages

  • How to fill shape with pattern... and cut outline?

    I have an old plotter that works great for making drawings. I can fill a shape with a pattern, convert the pattern to outlines (or strokes) BUT my problem is that the outline of the original shape remains, and this will be plotted. I do not want an outline of the original shape, I want the pattern to create the shape. Any ideas? Also, shape stroke remains part of the art (even if stroke = none before object/expand/ungroup/divide)

    aha!
    made scribble
    expanded scribble
    put shape in front
    select all, ctrl+7 (masked scribble to shape)
    pathfinder/crop
    solved. thanks! sishamDSS!

  • Fill shape with pen tool

    Hi there,
    this might be a very simple question, but couldn't figure it out ..
    I made a Title in Premiere and I want to draw a shape with the pen tool.
    However this only results into a shape with line instead of it being filled.
    So my question: how to draw a filled shape in Premiere Pro with the pen tool?
    Thanks in advance

    Set Graphic Type to Filled Bezier, that will fill the shape.

  • Fill Shape With Picture? student

    Hello,
    Is there a way to draw a shape and then fill it with a picture from a file?
    Also, I'm not sure if that is the best way to put pictures into the program I am making... any advice?
    - Jason

    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class ShapeImage {
        private JScrollPane getContent(BufferedImage source) {
            BufferedImage framed = getFramedImage(source);
            Box box = Box.createHorizontalBox();
            box.add(Box.createHorizontalGlue());
            box.add(new JLabel(new ImageIcon(source)));
            box.add(Box.createHorizontalGlue());
            box.add(new JLabel(new ImageIcon(framed)));
            box.add(Box.createHorizontalGlue());
            return new JScrollPane(box);
        private BufferedImage getFramedImage(BufferedImage image) {
            int w = 160, h = 160;                   // shape/frame size
            int type = BufferedImage.TYPE_INT_RGB;  // other options
            BufferedImage out = new BufferedImage(w, h, type);
            Graphics2D g2 = out.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            Ellipse2D circle = new Ellipse2D.Double(0,0,w-1,h-1);
            // Center image in circle frame.
            double x = (w - image.getWidth())/2;
            double y = (h - image.getHeight())/2;
            AffineTransform at = AffineTransform.getTranslateInstance(x,y);
            g2.drawRenderedImage(image, at);
            // Mask out image pixels that lie outside of the circle disk.
            Area mask = new Area(new Rectangle(0,0,w,h));
            mask.subtract(new Area(circle));
            // Use the desired background color.
            g2.setPaint(UIManager.getColor("Panel.background"));
            g2.fill(mask);
            // Draw the circle/shape frame.
            g2.setPaint(Color.red);
            g2.draw(circle);
            g2.dispose();
            return out;
        public static void main(String[] args) throws IOException {
            BufferedImage image = ImageIO.read(new File("images/cougar.jpg"));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new ShapeImage().getContent(image));
            f.pack();
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Fill shape with image

    Hi,
    I have drawn a curved box and wish to fill it with and image. I'm having trouble with this as the image is a rectangle and the box has curved edges. Is there any way which you can fill the box with the image. It will not matter if edges of the image are cut out.
    Thanks in advance
    Euan

    > I'm having problems copying layers.
    I take it this is a separate question? (no need to copy layers for what I suggested before)
    Highlight a layer in the layers palette, then press CTRL+J (windows) or Command+J (Mac) if you want a duplicate.
    Otherwise, highlight the layer, press CTRL+A (windows) or Command+A(Mac) , then CTRL+C (windows) or Command+C (Mac) and then you can paste it where you want.

  • Fill shape with 2 solid colors

    Hi,
    I was wondering if there is an easy way to fill a roundRectangle2D with 2 solid colors. For example that 1/3 is blue and the other 2/3 is green? I've looked in the java graphics2D api but can't find anything. GradientPaint isn't what I'm looking for, so is there any other easy option.
    Or is it the hard way and you need to draw several shapes on top of each other?
    class EventPanel extends JComponent{
        @Override
        protected void paintComponent(Graphics g){
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g.create();
            Double widthRect = (double) this.getWidth();
            Double heightRect = (double) this.getHeight();
            Double arc = widthRect / 20.0;
            Float strokeSize = 1.0f;
            Double offset = strokeSize / 2.0;
            Double adj = offset * 2;
            RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(offset, offset, widthRect - adj, heightRect - adj, arc, arc);
            RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHints(rh);
            g2.setPaint(new Color(30, 144, 255, 80));
            g2.fill(roundRect);
            g2.setPaint(Color.BLACK);
            g2.setStroke(new BasicStroke(strokeSize));
            g2.draw(roundRect);
            g2.dispose();
        }Similar to this: Example Don't mind the quality. Not good at art.
    Edited by: Kligham on 26-aug-2010 22:55
    Edited by: Kligham on 26-aug-2010 22:58
    Edited by: Kligham on 26-aug-2010 23:01

    Or is it the hard way and you need to draw several shapes on top of each other?What's so hard about that? But if you're looking for an alternative approach, you can do it with Graphicd$setClip(...)
    GradientPaint isn't what I'm looking forWhat about LinearGradientPaint?import java.awt.*;
    import javax.swing.*;
    public class StepGradientPaint {
      float[] fractions = {0F, 0.5F, 0.50001F, 1F};
      Color[] colors = {Color.RED, Color.RED, Color.GREEN, Color.GREEN};
      Paint paint = new LinearGradientPaint(0F, 0F, 200F, 0F, fractions, colors);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new StepGradientPaint().makeUI();
      public void makeUI() {
        JPanel panel = new JPanel() {
          @Override
          protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g.create();
            g2.setPaint(paint);
            g2.fillRect(0, 0, getWidth(), getHeight());
            g2.dispose();
        panel.setPreferredSize(new Dimension(200, 200));
        JFrame frame = new JFrame();
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }db

  • Fill Shape with text

    I'm trying to Fill Number 9 with text but I always get this :
    I want to have the circle inside without text !
    Someone Can help me ?
    Sorry Im newbie  :/

    I know you know a lot more about the internals than I do, Chris, and I hate to be argumentative, but I'm just not seeing the difficulty...
    Consider that the text placement code as written today can deal with the following (hastily drawn path).
    And as Paulo points out, Photoshop clearly already knows what's "inside" and what's "outside" a complex path.
    Emil makes a good point about the readbility suffering if one has to follow it across breaks in the figure...
    Still, who's to say whether someone wouldn't come up with a good use for this.  Bottom line is this - here you have a user expecting Photoshop to do something that's expected, and it's falling short because of the implementation and not allowing him to express his creativity the way he wants....
    This exercise DID bring one new idea to mind possibly for hhtun...  Try using a stencil font!
    -Noel

  • How can I fill mask with pattern?

    Hi
    Would you please help me? How can a add pattern to a mask? I drew a motion mask on video clip and now I want to fill it with pattern that I made in Photoshop and saved as PSD, what should I do? How can I fill mask with specific pattern?
    Thanks for any help

    AE doesn't directly support a pattern-fill like PS, so here's a workaround (as Mylenium suggested):
    Create a PS document and create a layer filled with the pattern required.
    Import the layer/PSD to AE and place in timeline.
    Place a copy of the masked layer above the Pattern layer.
    On the pattern layer, set the Track Matte to Alpha Matte.
    Read more here:
    http://livedocs.adobe.com/en_US/AfterEffects/8.0/WS3878526689cb91655866c1103906c6dea-7cf9. html

  • Filling in a shape with a dot pattern

    Hi there,
    I have this shape of a light which I am trying to fill with a dot pattern but when applied it cuts some of the dots off.
    How can I avoid this?
    Ideally it would also follow the 3 dimensional shape of the object, like the first picture.
    This is correct style of pattern I'm trying to achieve but wrong shape (I did not create this one) :
    This is the right shape but wrong pattern style:
    Thanks for your help!
    Charles

    Thanks, I've cleaned up the shape manually as the the tutorial suggested but it still doesn't quiet look right.
    Is there a way I can perhaps manipulate the pattern in order to follow to 3D shape whilst keeping the dots round?

  • Pattern fills with seamless patterns

    Hi,
    I'm doing some shapes that have a seamless pattern fill & then I want to use the shapes with the sealess pattern fill in another seamless pattern.  The only way i see I can do this is by expanding the artwork before dragging it into the swatch palatte.  The files are so big illustrator is crashing or the file is near impossible to work with.  I love the look of what i'm doing..but the files are too big.  Any ideas on a better way to do this?
    Thanks,
    Jessica

    You mean you are trying to make a pattern of objects that already have pattern fills?
    I don´t think you can do that.
    On the other hand you can easily select one tile of a pattern from an expanded pattern (double click on it with the direct selection tool), copy that and recolour artwork as you wish. Drag to palette for a new pattern.

  • How can I replace a color with a pattern fill?

    Hi everyone, thanks for any responses in advance!
    I've created quite a detailed design that works with 4 pixels per cm and 16 colors, canvas size 120x170cm. I'm wanting to replace all of a single color with a pattern, is there a way to do this?
    I can replace a color with another flat color by using adjustments etc... but I want to fill the entire of one color area with a pattern instead. The only way I can think to do this would be to use the magic wand tool to select every pixel of the same color, then create a new layer and overlay with a fill of the desired pattern, however as the design is so detailed it would take me an awful long time to select each color!
    Can anyone suggest a quicker more efficiant way to do this?
    Thanks!

    Select --> Color Range
    Mylenium

  • Cannot fill a rectangular shape with Color

    HI,
    I cannot fill a rectangular shape with color. I know it was working at some point. I checked the ID help, and did a search here with no results.
    I have the tool bar set correctly I think (see below). The object isn't behind other objects either, - that I can see. I do see it when I use the scroll bar so it's there somewhere. (see Pink box below).
    Any ideas profound or otherwise?
    Thenk Yew.

    You haven't got 100% transparency applied to it?  Then it might appear while scrolling because of a slightly delayed display.  That's all I can think of at the moment...
    The other thing to try if you suspect an individual document is playing up is to export it to inx or idml and open that.  Then another thing is to try replacing your preferences.

  • Hi ya'll, I'm having problems with patterns. Error 519, what's going on?? URGENT!!! Can't seem to fill layers with user defined patterns

    I've never had this problem before, I noticed improvements a few days ago regarding pattern tool but the last few days I've been unable to fill layers with a user defined pattern. This is one of the main reasons I use photoshop and it's giving me a headache!!! I have to turn in some patterns by monday and this is not working, please fix it!!

    First a clarification:  You are NOT addressing Adobe here in these user forums.
    BOILERPLATE TEXT:
    Note that because this is boilerplate text, not all points may apply to any given, specific poster.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Filling an object with a pattern without distortion?

    I have this camo pattern:
    wich already tiles seemlessy but when i turn it into a swatch it won't tile. it distorts the pattern and blows it up instead of using it as is and tiling:
    what is the problem here? can i scale it in some option menu? can i control the orientation? im creating a vector based logo, is this the right way to go about filling the object with this pattern?
    i want it to be scaled and tiled. what is the best way to go about it? what would u do? thanks in advance

    yup i thought so. it HAS to be vector based.
    it does not have to be vector, it can be jpeg or gif, but it has to be embedded...as for not using it in a logo, Scott can explain that.
    255x247 px
    the object is any size as its a vector. How are u filling yours? photoshop then a clipping mask?
    I meant the size of the camo image in relation to your vector object, not the actual size in pixels.
    in this sample I grabbed a GIF, embedded it, dragged it to the swatches palette, sent the image to back, then filled both the small object and the big object with the gif-embedded swatch, just to illustrate what happens with the size position.

  • How to draw a shape with line tool then fill with colour

    How can i draw a shape with the line tool and then fill it with colour

    Click and drag from one anchor point to the next, making sure that each new line segment begins where the last one ended. The Line Tool will snap onto the anchors.
    Once you're done creating what looks like a closed path, the lines are still separate objects. To combine them into one path, select them all and press Ctrl/Cmd+J (for Join) or via the menu select Object > Path > Join.
    The Pen Tool can be used in a similar manner, but each segment will be a continuation rather than a separate object. The last (closing) click will be indicated by a tiny circle on the mouse pointer.
    If you make an open path, Ai will still "fill" it with a fill color by assuming a straight path between the last open anchor points. Individual straight paths, however, such as those drawn by the line tool, have no "inside", so they won't show the fill color even if you have assigned one.
    Allen

Maybe you are looking for

  • Move tool in Photoshop CS5 on MacBook Pro

    I am trying to move one photo into another in Photoshop CS5. Instead of being able to to drag one tab overtop of the other to put one photo in a layer over another, the tab I am trying to drag snaps back into place. This is really frustrating. I have

  • Change in Fiscal Year Variant Causes Cube to become inactive

    In Maintain Fiscal Year variant, we attempted to change the Fiscal Periods to reflect the 2007 Fiscal Calendar. When we saved it, it caused the Update Rules for our Infocube to become inactive. I need to know how to reactivate them or what to do. The

  • MSI GT72 2QE BIOS Unlock and vBios GTX980m unlock

    Hey guys, searching for an MSI GT72 2QE unlocked BIOS with all possible voltages, like in XTU (see: ) Offset voltage, processor cache voltage, digital IO voltage Oh and Graphics voltage for the integrated HD 4600 is very important for me (also integr

  • Can't get ECDSA to work (Java 5)

    Hi all, I'm trying to create digital signatures w/ ECDSA using Java 5. Although the JCA doc promises support for the ECDSA digital signature algorithm, an attempt to aquire a signature object Signature signature = Signature.getInstance("ECDSA"); resu

  • How to run pioneercycling in atg10.1.1

    Hi, I have both Atg 9.1 and 10.1.1,jboss 4.2 and 5.1,jdk 1.5.0 and 1.6.0_30 and oracle 10g xe. I want to run the pioneercycling app in atg 10.1.1 though it does have the solid and pioneercyclingjsp modules.how can i run this app using oracle 10g.plea