How to draw and fill gradient color ?

i'm trying to fill the gradient color for the customize shapes in my application please tell how to approach for this problem.

I sloved by cliping it by clipping gradient color with respec to path

Similar Messages

  • Drawing and filling with color in an image?

    How to draw an eclipse or a shape in the image (picture)?
    I want to whiten (convert to white color) all pixel elements outside the shape, and the pixel elements inside the shape remain the shape.
    Pliz give some hints.
    Regards,
    Chevas

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class Mask extends JPanel
        BufferedImage image;
        public Mask()
            loadImage();
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            int imageWidth = image.getWidth();
            int imageHeight = image.getHeight();
            int x = (w - imageWidth)/2;
            int y = (h - imageHeight)/2;
            g2.drawImage(image, x, y, this);
            Area mask = new Area(new Rectangle(0,0,w,h));
            Ellipse2D e = new Ellipse2D.Double(w/6, h/8, w*2/3, h*3/4);
            mask.subtract(new Area(e));
            g2.setPaint(Color.white);
            g2.fill(mask);
        private void loadImage()
            String fileName = "images/owls.jpg";
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
        private void saveAsImage()
            int w = getWidth();  // or you could use the width and height
            int h = getHeight(); // of the mask to clip the image...
            BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            paint(g2);  // this component paints itself into the new image
            g2.dispose();
            try
                ImageIO.write(image, "jpg", new File("mask.jpg"));
            catch(IOException ioe)
                System.err.println("write: " + ioe.getMessage());
        private JPanel getUIPanel()
            JButton save = new JButton("save");
            save.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    saveAsImage();
            JPanel panel = new JPanel();
            panel.add(save);
            return panel;
        public static void main(String[] args)
            Mask mask = new Mask();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(mask.getUIPanel(), "North");
            f.getContentPane().add(mask);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How to draw and modify double lines with Adobe Illustrator?

    I need tot draw roadmaps. This should be easy using the pen tool, but my problem is that I cannot find a way to draw double lines with this tool. I have seen many fancy border styles and patterns. Some do have double or even quadruple lines, but the problem is than that they have an offset from the vector line and the space in between the two lines (the edges of the road) cannot be filled. Somewere I also found some pens called 'Double line 1.1' to 'Double line 1.6' but they also had an offset from the vector and I could not chance the size of the lines and the interval in between them independently.
    What I am looking for is a way to draw two lines in parallel and have the option tot fill the space in between with a color or even a pattern.
    The color and size of the lines should be changeable to make a distinction between several types of road.
    Is there an existing set of pencils for this purpose? It would be nice to be able to draw not only roads, but also railways and rivers!
    I am surely not the first person who needs to do this?
    I use AI version 6

    Jacob,
    Thanks for the answer. I have been searching for a solutions for a long
    time, but today I found the solution on a forum (not on this one). That
    solution is exactly as you described below, i.e. using a coloured line and a
    narrower white line on top of the first one. My problem was that I did not
    know how to create a custom brush based on the two lines. Now I know how to
    do that. However, I still have the problem. I can now draw double lines and
    I can change the color of the background line (the coloured one) but I
    cannot change the white colour of the narrower line. I assume that I have to
    completely redefine a new brush when I need to change that colour too.
    Regards,
    Rob Kole
    Van: Jacob Bugge [email protected]
    Verzonden: donderdag 28 maart 2013 17:04
    Aan: RKOLE
    Onderwerp: How to draw and modify double lines with Adobe
    Illustrator?
    Re: How to draw and modify double lines with Adobe Illustrator?
    created by Jacob Bugge <http://forums.adobe.com/people/Jacob+Bugge>  in
    Illustrator - View the full discussion
    <http://forums.adobe.com/message/5186535#5186535

  • How to remove and change the color of Java cup and border

    Hi to all,
    How to remove and change the color of Java cup and border.
    Thanks in advance
    khiz_eng

    This is just an Image. You would need to create your own image and call setIconImage(Image) on your JFrame.

  • How I can divide an gradient colored object into pieces?

    Hi, I'm new here.
    I'm trying to draw a Saturn. Here's the problem: how I suppose to cut the ring in half make it circle around the Saturn?
    If I just cut with scissors, then the gradient color will be out of order. I don't want to rasterize it.
    Anybody can help, appreciate it.
    Thanks, guys.

    I would just copy the ring grad and paste in front, Draw a box covering only the lower front portion of the copy of the ring. Select both the ring and the box, use Pathfinder panel>Crop, This should retain the lower front portion of the ring, now just move the full ring behind the planet and you should have it.

  • Drawing and Filling Circle and Polygon.

    I have searched about creating these but cannot understand properly. 
    Let SetPixel(X,Y) be the function to set the pixel. I am working in unity3d for drawing on texture.
    Allow time to reverse.

    besides what Armin said
    which setpixel function do you mean ?
    the bitmap.setpixel or the Win32 setpixel ?
    also why would you want it in vb when you don't plan to use vb ?
    I am writing class library for unity3d in vb.net.
    "SetPixel(x,y)" is just a procedure that sets pixel on (x,y). It is enough for drawing.
    I am not dealing with color or anything. Just need to set pixels at right position.
    I tried and found this: (It is to draw non-filled circle)
    Public Function Apply(Texture As Texture2D) As Texture2D Implements Image.Appliments.Apply
    Dim x0 As Integer = Me.X
    Dim y0 As Integer = Me.Y
    Dim x As Integer = Radius
    Dim y As Integer = 20
    Dim RadiusError As Integer = 1 - x
    While x >= y
    Texture.SetPixel(x + x0, y + y0, Color)
    Texture.SetPixel(y + x0, x + y0, Color)
    Texture.SetPixel(-x + x0, y + y0, Color)
    Texture.SetPixel(-y + x0, x + y0, Color)
    Texture.SetPixel(-x + x0, -y + y0, Color)
    Texture.SetPixel(-y + x0, -x + y0, Color)
    Texture.SetPixel(x + x0, -y + y0, Color)
    Texture.SetPixel(y + x0, -x + y0, Color)
    y = y + 1
    If RadiusError < 0 Then
    RadiusError = RadiusError + 2 * y + 1
    Else
    x = x - 1
    RadiusError = RadiusError + 2 * (y - x) + 1
    End If
    End While
    Texture.Apply()
    Return Texture
    End Function
    Allow time to reverse.

  • How to draw and copy a line?

    I would like to draw a line in a XYLineChart and then copy this line, in order to get this result
    [http://s14.postimage.org/4cip47ult/A02519.png]
    First left mouse click on point 1, then second mouse click on point 2: my goal is to have now a copy (clone) of this line (same lenght, same slope) that I can place anywhere on the chart, in this example by a third left mouse click on point 3.
    How to do this?
    Here is the code to draw a line on the chart
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.chart.CategoryAxis;
    import javafx.scene.chart.LineChart;
    import javafx.scene.chart.NumberAxis;
    import javafx.scene.chart.XYChart;
    import javafx.scene.control.Label;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.Pane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Line;
    import javafx.scene.shape.LineTo;
    import javafx.scene.shape.MoveTo;
    import javafx.scene.shape.Path;
    import javafx.stage.Stage;
    public class Lines extends Application {
    Path path;
    public static void main(String[] args) {
        launch(args);
    @Override
    public void start(Stage stage) {
        final CategoryAxis xAxis = new CategoryAxis();
        final NumberAxis yAxis = new NumberAxis(0.5, 9.5, 0.1);
        yAxis.setTickUnit(1);
        //yAxis.setPrefWidth(35);
        yAxis.setMinorTickCount(10);
        yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis) {
            @Override
            public String toString(Number object) {
                String label;
                label = String.format("%7.2f", object.floatValue());
                return label;
        final LineChart<String, Number> lineChart = new LineChart<String, Number>(xAxis, yAxis);
        lineChart.setCreateSymbols(false);
        lineChart.setAlternativeRowFillVisible(false);
        lineChart.setLegendVisible(false);
        XYChart.Series series1 = new XYChart.Series();
        series1.getData().add(new XYChart.Data("Jan", 1));
        series1.getData().add(new XYChart.Data("Feb", 4.5));
        series1.getData().add(new XYChart.Data("Mar", 2.5));
        series1.getData().add(new XYChart.Data("Apr", 6.5));
        series1.getData().add(new XYChart.Data("May", 4.5));
        series1.getData().add(new XYChart.Data("Jun", 8.5));
        series1.getData().add(new XYChart.Data("Jul", 6.5));
        BorderPane bp = new BorderPane();
        bp.setCenter(lineChart);
        Scene scene = new Scene(bp, 800, 600);
        lineChart.setAnimated(false);
        lineChart.getData().addAll(series1);
        Lines.MouseHandler mh = new Lines.MouseHandler( bp );
        bp.setOnMouseClicked( mh );
        bp.setOnMouseMoved( mh );
        stage.setScene(scene);
        path = new Path();
        path.setStrokeWidth(1);
        path.setStroke(Color.BLACK);
        scene.setOnMouseDragged(mh);
        scene.setOnMousePressed(mh);
        bp.getChildren().add(path);
        stage.setScene(scene);
        stage.show();
    class MouseHandler implements EventHandler< MouseEvent > {
    private boolean gotFirst    = false;
    private Line    line;
    private Pane    pane;
    private double  x1, y1, x2, y2;
    public MouseHandler( Pane pane ) {
        this.pane = pane;
    @Override
    public void handle( MouseEvent event ) {
        if( event.getEventType() == MouseEvent.MOUSE_CLICKED ) {
            if( !gotFirst ) {
                x1 = x2 = event.getX();
                y1 = y2 = event.getY();
                line = new Line( x1, y1, x2, y2 );
                pane.getChildren().add( line );
                gotFirst = true;
            else {
                line = null;
                gotFirst = false;
            else {
                if( line != null ) {
                    x2 = event.getX();
                    y2 = event.getY();
                    // update line
                    line.setEndX( x2 );
                    line.setEndY( y2 );
      }Thanks all.
    Edited by: 932518 on 16-nov-2012 1.54

    Sorry for the simplistic question - but where are the photos you are intending to add going to be coming from?
    If it is the pictures you take - then it almost seems like you need to first upload them to a cloud service like OneDrive or iCloud and then provide the URL to Google Maps

  • How to measure and fill with the same transparency?

    for example creating a fill using Edit > Fill with a random Color and Opacity in the Fill dialog, then later without the original information about the Color and Opacity but just the file, how can I make exact same fill and opacity again?

    White represents 100% opacity, so, yes, 100 minus the black (K) percentage of gray in the mask is the equivalent of opacity. The Info panel can tell you colour and opacity of the displayed composite of visible layers under the pointer/cursor at any time.

  • How to remove and fill in areas of a picture

    I am using the 30 day trial of Photoshop and trying to use online Help to learn the "how to's" BUT I'm finding it dificult to always follow the videos and explanations.
    I want to remove unwanted areas of a photo and then fill in those areas to match the surrounding image.
    I have figured out how to use the SELECT tool to cut out the unwanted areas BUT I can't figure out how to fill in the vacant areas.

    Ex IBM er work there for 40 years myself. Even if you worked with computers for years. Your not going to learn Photoshop in 30 days.  It will take longer then 30 days for you to become comfortable using Photoshop and much longer to become proficient with it.  Photoshop is an on going learning exercise the more you use it the stronger you become.
    Many of the video tutorials are done by users that are proficient using Photoshop and they use images that tools like content aware distortion will work well on if you know how to use the tools well. Without that knowledge you will have a hard time using the tools.  It also easy to miss point watching a video. Watch them more then once.  You also need knowledge of masking and other thing they have pre done for their videos.  They make it look easy its not that it hard its most beginners lack Photoshop knowledge
    Before any of the content aware stuff  I did this before and after images full size link http://www.mouseprints.net/BeforeAndAfter/AirplaneModFull.jpgopen in new window to see full size.
    Before
    After

  • How to resize and change background color of table item

    i am using netbeans as a compiler and i am using an item (in my mobile application)called org.netbeans.microedition.lcdui.TableItem.Can i change row height and column
    width.Also i wanna change cell background color.How can i do these?
    THX FOR REPLIES

    http://www.netbeans.org/kb/50/custom-tableitem.html

  • How to design and have universal color correctness?

    I designed a label using Illustrator and Photoshop, but when I got it printed, the color came out different than the onscreen visual. How can I avoid having to adjust everything? I want to be able to take it anywhere and print it and it come out how I designed it.

    Hi Saravanan,
    In your view, you have to add the UI element TabStrip. You will have an empty tab strip then. Right click on the tab strip, and add a 'Tab'. Continue in this manner to add as many tabs as you want. Each tab will have a header, specify the tab title in that.
    Now go to each tab, right click and insert element. You could insert any element like a table, Input fields etc. Event handling has to be done separately for these elements. At the tabstrip level, you need to handle only the onTabSelect event. This is the event triggered when you change tab selection in the tabstirp. In the properties of the tab strip, there will be a field selectedTab. Specify the ID of the tab which you want as selected. This will be your initial selection.
    You can also enable and disable tabs, say grey out tabs that have no data etc. All this can be done by context attribute binding.
    You can also refer to the view  by name TABSTRIP in the component WDR_TEST_EVENTS.
    Regards,
    Uday

  • TS4000 How to show and change Fonts, color, etc, on iCloud NOTES ?

    How can I apply the same features as in this toolbar make text
    modifications in my iCloud "NOTES" ??

    Notes on icloud is very limited.
    Tell Apple...
    http://www.apple.com/feedback/

  • How do I match a pantone color in Photoshop

    I need to match a pantone color in CMYK for a shape I need to print can someone help

    Adobe Photoshop contains support for the PANTONE COLOR BRIDGE libraries.  PANTONE COLOR BRIDGE is the physical guide which displays a side-by-side match between PANTONE solid colors, and explicit CMYK simulations, including the CMYK values used to print the Guide.  These explicit CMYK values are provided within the PANTONE COLOR BRIDGE libraries.
    Adobe CS6 contains native support for the updated PANTONE PLUS SERIES versions of PANTONE COLOR BRIDGE, with the exception of the 336 newest PANTONE colors launched in April 2012.  To access the 336 newest colors for Adobe CS6, or for older versions of the Adobe suite, the libraries can be exported from PANTONE Color Manager software, which is provided free of charge with purchase and registration of any PANTONE PLUS SERIES product.  Details of how to obtain and use PANTONE Color Manager software can be found at http://www.pantone.com/pages/pantone/pantone.aspx?pg=21054&ca=12.  You can also e-mail Pantone support directly at [email protected]
    Best regards,
    John Stanzione
    Manager - Technical Support
    Pantone, LLC

  • How do I copy and paste a gradient color from one document and then use the gradient on another document?

    I am making business cards. On the back of the cards there are two lines with gradients. Below is a card with a magenta gradient. I want to select both lines and change the magenta gradient to the orange gradient from the file below. How do I do this? (I do not want to copy a paste the orange lines and then move them over the magenta ones.) I just want to select the magenta lines and change their color to the orange gradient. This will insure absolute alignment. I want to do repeat the process with several other gradients too. Thank you.

    David,
    As I (mis)understand it, you may:
    1) Copy one orange gradient path to the magenta gradient path document;
    2) Select the two magenta gradient paths and change the Fill to None;
    3) Select the orange gradient path;
    4) Select the two magenta gradient paths and change the Fill to Gradient.
    That should give you the desired replacement. For multiple use of the same gradient, you may consider a gradient swatch.

  • How do you change the color of the sign and fill text to the color blue

    How do you change the color of the sign and fill text to the color blue in a pdf document

    Is this using the "Fill & Sign" tab of https://cloud.acrobat.com/fillsign (for now text input is only black) or maybe using the Fill & Sign tool in Adobe Reader XI, or another application? 
    Thanks,
    Josh

Maybe you are looking for

  • How to force Tiger to print doc within Classic environment, not with OSX?

    I want to print certain documents using OS9's printing utility within the Classic environment, and NOT using Tiger's standard OSX printing method. How? I know it is possible because I have two Macs connected to the same printer, and it works on one a

  • CX_HRPA_INVALID_PARAMETER DUMP

    hi Experts We have developed a function module which calculates certain amount based on certain criteria and update the amount in a wage type in Infotype 15. The function module calculates the amount , but when im trying to update infotype 15 using H

  • Posting pics on iWeb Photo pages

    hi, i did some research on the issue i am having but couldn't find any resolutions. i'm hoping someone can help me with their experience / expertise. this is the weirdest thing and perhaps i'm overlooking something obvious? i have taken digital pics

  • Order type in MTO  cycle

    I am using planning strategy 41 for a FG. I have created an  order type ZA01. this order type works for MTS cycle, whereas for a MTO, i am getting order type as PP01. i want to change it to ZA01. pl any suggestions

  • I try to synch my Ipod but when it tries it says device cannot be found

    try to synch my Ipod but when it tries it says device cannot be found, how do i solve this problem??