Paint inside rectangle shape

I am confused about following.  How to paint inside rectangle with paint brush without going outside my edges. 
I create rectangle with rectangle tool and now i would like to use brush inside it but it keeps going outside.  How do i prevent that?
is the only way to do that to use marquette tool? i tried that but cant seem to be able to select all of my shape. 
Can someone give me some suggestions please

Similar Messages

  • Different ways to paint inside of a shape that is not closed

    1. One segment of a path is not closed and I want to fill the shape with a color. How would you handle this? Just draw a line and join it together with the rest of the shape so you can apply a fill? OR would you do this differently?
    2. Isn't there some tool that also allows you to paint inside shapes that are not closed?
    Thanks.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    So is the whole idea behind Live Paint that it will somehow complete a shape with paint even if the path is not there?
    No. The paths have to "be there." The whole idea of Live Paint is to allow the user to apply fills and strokes according to what visually appears to be contiguous bounds of filled/unfilled and/or colored/uncolored regions. In other words, to apply fills and strokes as if the visual appearance of paths actually were the shapes of the paths.
    Example 1:
    Draw a tic-tac-toe board. Four stroked unfilled open paths. Now you know these paths are not connected, and there is no actual rectangular closed path in the middle "square" to which you can apply a normal fill. But the four strokes appear to form a square that you could fill. LivePaint acts as if that square was there, and fills it. (Under the table, LivePaint is actually creating a "virtual" or "live" rectangle that corresponds to the visible white space surronded by your original four paths. You can see this by Expanding the LivePaint group.)
    Example 2:
    Draw two partially-overlapping unstroked circles with the same solid fill. Now you know these two circles are separate paths; there is no actual "figure 8" path. But there appears to be a figure 8 -shaped path just because the two circles have same-colored fills. LivePaint can act as if that "figure 8" path is actually there, and fill it all at once (by doubleClicking). In this case, the expanded result will be three separate closed paths with the same fill, not one figure 8-shaped path. So now instead of having two overlapping paths that look like a single figure 8 path, you have three non-overlapping paths that look like a figure 8-shaped path.
    So LivePaint does act upon paths that "are there." It performs path-combination operations to create new paths (sort of like Pathfinders) based upon the stroke and/or fill "boundaries" that you visually see; but it does so in a "live" fashion, in an attempt to make it feel more like flood-filling in a raster image program, and in an attempt to make the auto-created shapes themselves remain "live" even as you alter the original paths.
    Sometimes its behavior is intuitive. Other times, it is not.
    Illustrator is neither the first nor the only vector drawing program to provide this kind of function. Other vector drawing programs provide flood-fill and flood-stroke features, but do so in a more straightforward manner, not overly-complicating (and confusing) the matter by trying to make too much a "live effect." Illustrator sometimes tends to go overboard with the whole "live effect" thing, and the result is a feature ostensibly designed to make the program more "intuitive" for newcomers, yet becomes more confusing.
    Regardless whether you use "live" effect features or not, a serious vector illustrator needs to know what objects will ultimately and actually exist, especially when destined for commercial print. That is, in Example 2, it's up to the user to decide whether it's more appropriate to the intended purpose to end up with two separate overlapping paths that look like a single figure 8, three separate "kissing" paths that look like a figure 8, or one path that actually is in the shape of a figure 8. That's why I've never been particularly enamoured with features like LivePaint. They encourage newcomers to disregard how things are actually built in favor of what things merely "look like" on screen.
    JET

  • Aligning text horizontally inside a rectangle shape?

    I have text on top of a rectangle made with a shape layer. I now want to align the text in the center of the rectangle shape. I select both layers, though the option to align the text sometimes shows and other times does not. When it does show the horizontal option is greyed out. How is this done?
    Thanks.

    With the Move Tool selected and no Selection active it should be no problem, could you please post a screenshot with the pertinent Panels visible?

  • Problem with CS4 brush tool "paint inside mode"

    When I use the Flash CS4 brush tool in "Paint Inside" mode it erases part of the strokes around shapes. For rectangles it erases the stroke on the top and left hand side where the brush head crosses it, though it never seems to affect the other sides. The effect is less consistant with ovals, but it breaks the strokes at some points. I am using Flash CS4 version 10.0.2 on Windows XP, and I have checked for program updates through the Help menu. Here are two examples:
    If I understand right, the brush tool shouldn't be changing the stroke anywhere in this mode. I would be grateful for any help.

    This has existed for a very long time in Flash, at least back to version 8. I'm not too sure, but it certainly only affects two out of the four sides of a square. There is a bug on this, so I will send it back for review.

  • Select objects inside a shape

    Hello!
    Im looking for a way to export a pattern made in Illustrator to auto cad.
    I would like to select objects inside a shape based on the shape.
    As you can see here i would like to select all the objects inside the blue circle, and delete everything outside of it. I dont want to use a cliping mask as it does not really destory the objects outside the
    circle. Any help would be much appreciated.
    /Jakob

    Jakob,
    You may use careful manual cutting (using Smart Guides) along the circle and grumble over the lack of easy ways to do it properly on open paths.
    Or you may do the destructive deed, with the Clipping Mask selected:
    1) In the Transparency palette/panel dropdown list select anything but Normal (Multiply is fine),
    2) Object>Flatten Transparency, just keep the defaults including 100% Vector,
    3) Shudder.
    This should reduce the size to the Bounding Box of the Clipping Path.
    It makes a bit of a mess out of the mesh (strokes are outlined to become filled paths); it has the (dis)advantage of cutting each path end at the actual angle of the Clipping Path (the circle).

  • Moving an image inside  a shape

    OS X Yosemite, Pages 5.5.1. I am trying to move an image I opened as a filling for a shape. I how can I move the image inside the shape without moving the actual shape?

    Double click on the image and you will see the shape that frames it. Click outside the frame and your cursor becomes a hand to drag it around.  Click on the handles of the image and you can resize it.
    When in doubt try the usual things.
    Peter

  • Placing text inside curved shape

    i am having bit trouble placing the text inside this custom shape (i used custom shape tool)
    I followed one of the post found here Fitting text inside a custom shape but i couldn't get any results at all. Would someone maybe try to give me exact instructions on how to do this please.
    I would like to place this text inside yellow shape and text should follow the curved path of the shape.

    It's easier to apply the flag warp to both the Type and Shape layers at the same time, so start with your text, and create the shape layer below it.  Select both layers, and right click and choose Convert to Smart Object.  Then Free Transform > Warp

  • Since I've updated, I can't resize rectangle shapes.

    Since I've updated, it seems like I can't resize rectangles or rounded edge rectangles any more.  The bounding box isn't even present, only the nodes for rounding the corners.  This only seems to be happening for the rectangle shapes, ellipses and other polygons are unaffected.  Did they change something, and this is a feature, or is it a bug?
    I've tried restarting and all that, this is happening consistently across many files.  Help!

    Object > Shape > Expand Rectangle
    or use the free transform tool
    For the benefits of live shapes see here:
    Illustrator Help | Live Rectangles and Rounded Rectangles

  • Drawing an arrow between two rectangle shapes

    i am trying to draw an arrow between two rectangle shapes. the arrow will start from the center of one rectangle and end with the arrow tip at the edge of the other rectangle. i actually draw the arrow first, and draw the rectangles last so the effect of where the arrow starts will seem to come from the edge and not the center.
    i have code using some trigonmetry that works for squares, but as soon as the shape becomes a rectangle (i.e. width and height are not the same), the drawing breaks.
    can i detect where a line intersects with a shape through clipping and use that point location to draw my arrow head? if so, how?

    Here's one way to do this using the rule of similar triangles.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Pointers extends JPanel {
        Rectangle r1 = new Rectangle(40,60,100,150);
        Rectangle r2 = new Rectangle(200,250,175,100);
        int barb = 20;
        double phi = Math.toRadians(20);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.blue);
            g2.draw(r1);
            g2.draw(r2);
            g2.setPaint(Color.red);
            g2.draw(getPath());
        private GeneralPath getPath() {
            double x1 = r1.getCenterX();
            double y1 = r1.getCenterY();
            double x2 = r2.getCenterX();
            double y2 = r2.getCenterY();
            double theta = Math.atan2(y2 - y1, x2 - x1);
            Point2D.Double p1 = getPoint(theta, r1);
            Point2D.Double p2 = getPoint(theta+Math.PI, r2);
            GeneralPath path = new GeneralPath(new Line2D.Float(p1, p2));
            // Add an arrow head at p2.
            double x = p2.x + barb*Math.cos(theta+Math.PI-phi);
            double y = p2.y + barb*Math.sin(theta+Math.PI-phi);
            path.moveTo((float)x, (float)y);
            path.lineTo((float)p2.x, (float)p2.y);
            x = p2.x + barb*Math.cos(theta+Math.PI+phi);
            y = p2.y + barb*Math.sin(theta+Math.PI+phi);
            path.lineTo((float)x, (float)y);
            return path;
        private Point2D.Double getPoint(double theta, Rectangle r) {
            double cx = r.getCenterX();
            double cy = r.getCenterY();
            double w = r.width/2;
            double h = r.height/2;
            double d = Point2D.distance(cx, cy, cx+w, cy+h);
            double x = cx + d*Math.cos(theta);
            double y = cy + d*Math.sin(theta);
            Point2D.Double p = new Point2D.Double();
            int outcode = r.outcode(x, y);
            switch(outcode) {
                case Rectangle.OUT_TOP:
                    p.x = cx - h*((x-cx)/(y-cy));
                    p.y = cy - h;
                    break;
                case Rectangle.OUT_LEFT:
                    p.x = cx - w;
                    p.y = cy - w*((y-cy)/(x-cx));
                    break;
                case Rectangle.OUT_BOTTOM:
                    p.x = cx + h*((x-cx)/(y-cy));
                    p.y = cy + h;
                    break;
                case Rectangle.OUT_RIGHT:
                    p.x = cx + w;
                    p.y = cy + w*((y-cy)/(x-cx));
                    break;
                default:
                    System.out.println("Non-cardinal outcode: " + outcode);
            return p;
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new Pointers());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How to cut of rectangle shape to create bracket in Photoshop?

    I want a layer like this:
    I've drawn the rectangle then I made a selection with the marquee selection tool to delete a part of the rectangle but it deleted whole shape. Can anyone please help me out with this.
    Thanks in advance.

    hungp15938294 wrote:
    Thanks to Trevor.Dennis and @station_two for helping me . I have more a stupid question because I'm not good at Photoshop. Please take a look at image below
    Make your rectangle shape.  If you want it to be perfectly square, hold down the Shift key while you drag.
    Make your two text layers using the centered text alignment option.
    Select the entire canvas — Ctrl a (Cmd a )
    Select the Move tool and then select the rectangle shape and both text layers.  You should see matching ants at the edges of your image.
    Click on the Align horizontal centers icon in the Options bar. The rectangle and text layers will now be centered vertically in the image.
    If you want the box centered width wise, select just the box layer, and make sure you still have the matching ants at the image edges.
    Click on Align vertical centers second icon from the left in the strip above.
    You will need to align the text layers to intersect the horizontal lines manually, but if you hold down the shift key while dragging, they will not move sideways.
    Nearly done.
    You still need those marching ants at the screed edges (Ctrl a).  Go Select > Transform selection You will now see handles on the selection.
    Hold down the Alt (Opt) key, and drag either the central handles on the vertical sides towards the middle of the box. Both sides will move symmetrically.
    When the select is a couple of mm clear of the wider text, click on the tick icon on the Options bar to OK it.
    Make sure just the box layer is selected, and add a Layer mask. This will actually hide the bits you don't want hidden, so last step.
    Invert the layer mask Ctrl i (Cmd i)

  • Painting a rectangle after clicking a JButton?

    Hi all,
    I'm developing an applet that when a button is clicked, a rectangle is painted over an image. The problem is that when I add the painting code in the mouseClicked() method, using Graphics2D.createGraphics(), etc., run the applet and click the button, nothing happens. So, how can I paint a rectangle over an image by clicking a JButton?
    Perhaps something like JPanel.validate(), I don't know...
    Any help would be appreciated.
    Thanks in advance.

    http://forum.java.sun.com/thread.jsp?forum=54&thread=529542&start=5

  • Drawing character inside rectangle

    Hi!
    I have the following problem. I have a string and my task is to be able to draw every character of the string in every rectangle. For example I have a string:
    String = ("GCATCGCAGAGAGT");
    So now I will have 14 characters inside 14 rectangles. My question is how to do that? Please help me to solve it.

    This is my code. There's still error in it. It can not show the rectangle and also the characters. Could you fix my code? I am still a beginner in this field
    I am sorry if my code is not formatted as well, because I am a new comer in this forum. So please help me to solve my problem, I expecting a lot from you.
    /** Here is my code **/
    package brute_force;
    import javax.swing.*;
    import javax.swing.border.Border;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    * BorderLayoutDemo.java
    public class BruteForceAnimation4 extends JPanel{
              /** Variable for drawing character inside rectangle **/
              private String[] mSourceString = {"G","C","A","T","C","G","C","A","G","A","G","A","G","T"};
              private String[] mPatternString = {"G","C","A","G","A","G","A","G"};
              /** This is variables to draw the rectangle **/
              private int xPosSource = 40;
              private int yPosSource = 100;
              private int xPosPattern = 80;
              private int yPosPattern = 80;
         /** constants for predefined colors */
         private static final Color lightBlue = new Color(153, 204, 255);
         public BruteForceAnimation4()
         super();
         public static void addComponentsToPane(Container pane) {
         JLabel lblTitle = new JLabel("Brute Force String Searching
    Algorithm", SwingConstants.CENTER);
         String bruteForceCode[] = {
         "int count = 0", //0
         "int m = mPattern.length();", //1
         "int n = mSource .length();", //2
         "outer:", //3
         " for (int i = 0; i <= n - m; ++i) {", //4
         " for (int k = 0; k < m; ++k) {", //5
         " if (mPattern.charAt(k) != mSource.charAt(i + k)) {", //6
         " continue outer;", //7
         " }", //8
         " }", //9
         " ++count;", //10
         " }", //11
         " return count;", //12
         "}" //13
         JList list = new JList(bruteForceCode); // a container for pseud code
         JButton cmdRun = new JButton("Run");
         JButton cmdStep = new JButton("Step");
         //Set the title of the applet
         lblTitle.setFont(new Font("Serif", Font.BOLD, 18));
         JPanel buttons = new JPanel();
         buttons.add(cmdRun);
         buttons.add(cmdStep);
         buttons.setBackground(lightBlue);
         //Set the size and border of list (JList component)
         Border etch = BorderFactory.createEtchedBorder();
         list.setBorder(BorderFactory.createTitledBorder(etch, "Brute Force
    Code"));
         JPanel listPanel = new JPanel();
         listPanel.add(list);
         listPanel.setBackground(lightBlue);
         list.setBackground(lightBlue);
         BruteForceAnimation4 border = new BruteForceAnimation4();
              pane.add(lblTitle, BorderLayout.NORTH);
         pane.add(border, BorderLayout.CENTER);
         pane.add(listPanel, BorderLayout.EAST);
         pane.add(buttons, BorderLayout.SOUTH);
         pane.setBackground(lightBlue);
         public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D) g;
         setBackground(lightBlue);
         drawSourceString(g2, mSourceString);          
    /** this is the method to draw character inside rectangles **/
    /** but it still wrong **/
         public void drawSourceString(Graphics2D g2,String[] mSource)
              if (mSource == null)
                   return;
              for (int i=0; i < mSource.length; i++)
                   g2.drawRect(xPosSource, yPosSource, 60, 40);
                   g2.drawString(mSource,40,40);                              
                   xPosSource += 30;
    //This is to count the length of the the Source
                   System.out.println("Your length" +mSource.length);
         public static void main(String[] args) {
         //Create and set up the window.
         JFrame frame = new JFrame("Brute Force Algorithm");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //Set up the content pane.
         addComponentsToPane(frame.getContentPane());
         //Use the content pane's default BorderLayout. No need for
         //setLayout(new BorderLayout());
         //Display the window.
         frame.pack();
              frame.setSize(800, 600);
         frame.setVisible(true);

  • Rectangle shape and add to controls to it:

    Hi,
    I've a requirement where I need to add rectangle shapes to the application and I should add text, image and button. I checked with Rectangle shape, but it will not allow us to add controls within that. Please let me know how can I do the same.
    Thanks,
    Santosh

    Just add the Rectangle and the TextBlocks and Image to the same Grid:
    <Grid Width="100">
    <Rectangle Width="100" Height="100" Fill="Green"/>
    <Image Source="pic.png" Width="10" Height="10" Margin="20"/>
    <TextBlock Margin="10 5 10 5">text...</TextBlock>
    </Grid>
    The TextBlock will end up on top of the Image that will end up on top of the Rectangle using the above sample markup. Use the Margin property to control the position of the elements.
    Please remember to close your threads by marking helpful as answer and then start a new thread if you have a new question.

  • JS to add url hyperlink to a rectangle shape?

    Hi there,
    Any JS script to add a url hyperlink to a shape object ?
    Thanks a million....

    Hi,
    here's a script that might help you. I made it and tested it only for InDesign CS5.5.
    How to use it: select any object in InDesign then run the script. At first, the script will try to see in the clipboard has valid URL (well, a text startiong with http…) and if so, the clipboard will be take as a good URL for the new created button. If no valid URL in the clipboard, the script will ask for the URL to be entered manually. If the ibject is a text frame, the script will try to take the text from inside the frame as a URL – if not valid, then the dialog pops up.
    // -------------------------------------------- BEGIN SCRIPT ----------------------------------------------
    if (app.selection.length==1) {
    //get the selected object (only one object)
    var xOBJECT = app.selection[0];
    var xPAGE = xOBJECT.parentPage;
    var xBOUNDS = xOBJECT.geometricBounds;
    //create the button
    var xBUTT = xPAGE.buttons.add({geometricBounds:xBOUNDS});
    //add selected object to the normal state
    xBUTT.states.item(0).addItemsToState(xOBJECT);
    //create the gotoURL behavior
    var xGOTOURL = xBUTT.gotoURLBehaviors.add({behaviorEvent:BehaviorEvents.mouseUp});
    //get the clipboard
    var xTEMP = app.documents[0].textFrames.add(); xTEMP.insertionPoints[-1].select(); app.paste(); var xCLIP = xTEMP.parentStory.contents; xTEMP.remove();
    //check the clipboard or text frame's text; if it does not starts with "http" then it's not good and a dialog asking a good URL will popup
    if (xOBJECT.constructor.name!="Rectangle")
        var xURL = xOBJECT.parentStory.contents;
    } else {
        var xURL = xCLIP;
    if (xURL.substring(0, 6)!="http://") {
    // do the dialog here
    var xDIAG = app.dialogs.add();
    with (xDIAG.dialogColumns.add().dialogRows.add()){staticTexts.add({staticLabel:"Enter URL:"}); var xURLTEXT = textEditboxes.add({editContents:xCLIP, minWidth:160});}
    var xRESULT = xDIAG.show({name:"Button creation"});
    if (xRESULT == true){xURL = xURLTEXT.editContents; xDIAG.destroy();} else { xURL="http://"; xDIAG.destroy();}   
    // set the URL to the behavior
    xGOTOURL.url=xURL;
    // -------------------------------------------- END SCRIPT ----------------------------------------------
    Have fun!

  • Resizing a rectangle shape?

    In my drawing application the user uses the mouse to drag out a rectangle. When the rectangle is drawn it has four handles on it, so that the user can click on any one of these handles and resize it. I'm having great difficulties getting this to working properly, does anyone know of an open source example I could look at to see how to do this?
    I have resizing a Line working perfectly, all I need now is the rectangle functionality.
    Here is how I draw the handles on my rectangle:
    public void drawHandles(Graphics2D aGraphics2D)
            aGraphics2D.setColor(Color.RED);
            // If the shape is selected then draw the handles
            if(isSelected())
                aGraphics2D.fillRect(getX1() - 2, getY1() - 2, 5, 5);
                 aGraphics2D.fillRect(getX2() - 2, getY2() - 2, 5, 5);
                 aGraphics2D.fillRect(getX1() - 2, getY2() - 2, 5, 5);
                 aGraphics2D.fillRect(getX2() - 2, getY1() - 2, 5, 5);
        }I have also a method that returns which handle has been clicked.
    Please help guys, I've spent too long trying to get this to work.
    Thanks.

    Probably you do custom painting. So do something like this:
    class SuperClass extends JPanel implements MouseListener, MouseMotionListener {
    private static final int NO_HANDLE_SELECTED = -1;
    private static final int POINTS_COUNT = 4;
    private Point[] points = new Point[POINTS_COUNT];
    private int editedHandle = NO_HANDLE_SELECTED;
    SuperClass(Rectangle rect) {
    addMouseListener(this);
    addMouseMotionListener(this);
    points[0] = new Point(rect.x, rect.y);
    points[1] = new Point(rect.x + rect.width, rect.y);
    points[2] = new Point(rect.x, rect.y + rect.height);
    points[3] = new Point(rect.x + rect.width, rect.y + rect.height);
    public void paint(Graphics g) {
    // Draw the "rectangle"
    g.moveto(points[0]);
    for (int i = 1; i < POINTS_COUNT; i++) {
    g.lineto(points);
    g.lineto(points[0]);
    drawHandles(g); // This is your handle drawing routine
    * A little bit altered
    public void drawHandles(Graphics2D g) {
    for (int i = 0; i < POINTS_COUNT; i++) {
    g.fillRect(points[i].x - 2, points[i].y - 2, 5, 5);
    public void mousePressed(MouseEvent m) {
    editedHandle = getEditedHandle(m); // Your handle detecting routine.
    // This should return 0 if the first point was clicked e.c.t. or NO_HANDLE_SELECTED
    // if the user clicks in empty space.
    public void mouseDragged(MouseEvent m) {
    if (editedHandle != NO_HANDLE_SELECTED) {
    points[editedHandle].x = m.getX();
    points[editedHandle].y = m.getY();
    repaint();
    public void mouseReleased(MouseEvent m) {
    editedHandle = NO_HANDLE_SELECTED;
    1. Warning. This code was composed on the fly on an HTML browser and not in an IDE. It will probably not run. But with little debugging (1-5 mins) I am sure it will work.
    2. This "algorithm" is nice because it paints and edits any polygon without holes, not only Rectangles.
    3. This component is being based on JPanel as it is the most likely for you to use. You can adapt it to everything e.g. a JButton in order to edit its (Vectorized) icon when you double click over it! That would be fun!

Maybe you are looking for