Using Gradients in motion

I'm working on a project that has used the DnD package to create an interface where users can create various shaped objects and drag them about the screen. The user can change the colour of the objects. I'm trying to make it possible for the user to select a gradient instead of just a colour. However, when the object is made gradient, the gradient changes as I move the object. Is seems like the gradient is set to the background, and then the shape allows you to see through to the background.
Does anyone have any ideas on how to keep the gradient consistant as the object moves?
I don't know how helpful this code will be out of context, but here it is:
     public void drawObject(Graphics2D g2) {
          /* Fill shape */
          g2.setColor(((NodeStyleSheet) attributes).getBackgroundColor());
          g2.setPaint(theGradient);
          if (drawableShape == null )
               g2.fill( ShapeObject.getObject(ShapeObject.DEFAULT_NAME).getShape());
          else
               g2.fill(drawableShape);
Thank you
Brina

import java.awt.*;
import java.awt.geom.Ellipse2D;
import javax.swing.*;
public class GradientMotion extends JPanel
    Ellipse2D.Double ball;
    int dx = 2;
    int dy = 1;
    public GradientMotion()
        ball = new Ellipse2D.Double(50, 50, 50, 50);
    protected void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        Rectangle r = ball.getBounds();
        int x = r.x + r.width;
        int y = r.y + r.height;
        GradientPaint gradient = new GradientPaint(r.x, r.y, Color.blue,
                                                   x, y, Color.yellow);
        g2.setPaint(gradient);
        g2.fill(ball);
    public void moveBall()
        checkBoundries();
        ball.x += dx;
        ball.y += dy;
        repaint();
    private void checkBoundries()
        if(ball.x + dx < 0 || ball.x + ball.width + dx > getWidth())
            dx *= -1;
        if(ball.y + dy < 0 || ball.y + ball.height + dy > getHeight())
            dy *= -1;
    public static void main(String[] args)
        GradientMotion gradientMotion = new GradientMotion();
        Locomoter locomoter = new Locomoter(gradientMotion);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(gradientMotion);
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
        locomoter.start();
class Locomoter implements Runnable
    GradientMotion gradientMotion;
    int delay = 25;
    boolean animate = false;
    Thread thread;
    public Locomoter(GradientMotion gm)
        gradientMotion = gm;
    public void run()
        while(animate)
            try
                Thread.sleep(delay);
            catch(InterruptedException ie)
                System.err.println(ie.getMessage());
            gradientMotion.moveBall();
    public void start()
        if(!animate)
            animate = true;
            thread = new Thread(this);
            thread.setPriority(Thread.NORM_PRIORITY);
            thread.start();
}

Similar Messages

  • QT: Poor video quality for gradients when Motion JPEG A/B codec used.

    Hello,
    I have a problem using the Quicktime (7.6) and the Motion JPEG A/B codec.
    My workflow is as follows:
    1. Create animation with Quartz Composer. This animation should use gradients from dark red to white.
    2. Export the animation as Quicktime film (MOV), set full HD (1920x1080), duration e.g. 2 minutes.
    3. Open exported MOV with Quicktime(Pro)
    4. Export again to Quicktime film, now choose Motion JPEG A for codec, set quality to best.
    5. Check the exported film. The gradient is not smooth, I see bright and dark lines. The quality of the gradient is poor.
    I checked the other codecs. When I use "Animation" then the gradient is smooth and beauty.
    Unfortunately I have to use Motion JPEG codec due to customer requirements.
    Does anybody have an idea, how I can improve the quality? Maybe internal QT settings? Other external Motion JPEG codec ?
    Thanks in advance
    LeKarmar

    Hello QuickTimeKirk,
    Thank you for your reply.
    I need Motion JPEG A/B or PhotoJPEG This is my "final distribution format" required by the customer.
    I have problems not only with the red color. Even using grey, blue or yellow gradients produces bad output.
    You're right. Animation codec produces what I will accept and want, but the files are huge sized and my customer doesn't accept this format.
    Please note, that I already set the high quality playback setting in Quicktime.
    Regards
    LeKarmar
    Message was edited by: LeKarmar

  • Banding in Photoshop CC 2014 when using gradient or curves, 5K imac and Nikon D810. Help?

    I am experiencing severe banding in
    Photoshop CC 2014.
    5K imac, Nikon D810.
    16 Bit Tiff in both Adobe RGB and Profoto RGB.
    It seems to be something new.
    OSX Yosemtie 10.10.1
    It appears when using gradients.
    Help?

    Thanks for your help Trevor.
    That does not seem to make a difference.
    I sometimes use the Nik Collection for
    gradients as well.
    The banding is very visible in the
    Plugin as well.
    It is odd because this seems to have
    just started this week.
    It is the same on my 2011 iMac as well.
    Not sure if it is because I shot on a grey
    background.
    I will post an example.
    I am also using Profoto RGB which
    is supposed to have smoother gradients.

  • How can i use gradient tool in Illustrator

    Hello,
    I am trying to use gradient tool in illustrator.
    My image is active but how can i start using gradient tool.
    I clicked the tool and tried to drag with my mouse but, i can not activate the tool itself.
    Can any one help me, I am using CS4 extended with Mac.
    Thank you very much.
    Steve

    First in order to use the gradient tool you must have a gradient fill applied to an object not an raster image it can be a vector illustration..
    Select the object or objects or groups of objects
    Now click on the gradient bar in the Gradient Panel while the object(s) are still selected that will fill the object with the default gradient.
    You can also use a gradient swatch in the Swatches panel, you can make a gradient swatch as well.
    Now your object(s) is filled with the default gradient fill.
    Now in the tool panel select the gradient tool this will allow you to control the way the gradient is oriented and applied to the object.
    Now you can change the colors and add colors to you gradient by clicking on the color markers below the gradient bar which will bring up the color or swatches panels.
    Now finally and this is the most important factor to consider you have to purchase a book and or tutorials and the book that will probably do you the most good at this stage is Mordy Golding's Real World Illustrator CS 4 this you shoud do before you go any further. Honest.

  • Creating glossy surfaces WITHOUT using gradients

    Greetings,
    I'm trying to do a smartphone illustration in Illustrator for a t-shirt print. The challange is I can't use any gradients, and I'm having a hard time creating that glossy/reflective feel. The tutorials I found always uses gradients so they're not much help.
    My question is, can someone give me some tips about creating a reflective surface illustration without using gradients (and preferably without using transparency)? Thank you very much for your help.

    You need to be clear about your requirements. Limiting the number of inks to eight does not rule out grads or tints. Are you saying you can't handle halftone or tint screens (array of tiny dots)? If so, then your requirements are solid line art, no screens.
    For example, Joe's example is line art (no grads or other continuous-tone), but it may very well be set up as tints of one color (black), in which case it would still require tint screens. If your requirement is strictly solid line art, then you would have to use a different ink for each shade of gray, printed as a solid, and the file would have to be built to separate that way; i.e.; using a separate spot color for each gray.
    JET

  • Using PXI 7352 Motion card and 6025E DAQ

    Dear Sir,
    I am using SCXI 1520 along with PXI 1011 & E Series DAQ (6025E) to measure the Load Value of a load cell. I am also using PXI 7352 Motion card to control the velocity of a Plunger. Now my requirement is to stop the movement of the Plunger depending on the value I read from the load cell. I am not able to achieve the stoping accuracy for high speeds (around 150mm/sec) in the software. Can it be possible with the use of Motion Control card and RTSI signals? If so, how can I do that? (I am not used any limit switches as the load value at which the Plunger should stop is user programmable and I am using DAQ card in Multiplexed mode because i am reading more number of analog inputs with only one DAQ card)
    Ramkumar. D
    Soliton Automation,
    India.

    Hello.
    Based on your post I am guessing that you are performing the control in software, i.e. starting a velocity move, and then reading the load cell until it reaches a threshold, then stopping the motion. As such you are essentially limited by the software control loop rates.
    You are using PXI so it is possible that you are using real-time. If not, one solution could be to implement a real-time application that would be more deterministic, but again this would still depend on the software.
    Depending on your system (stepper or servo), you could implement a direct analog feedback into the motion card itself, but this would require a signal which has a range much greater than your load cells. This is only a good option for servo axes. If this was somehow possible, you can tell the motion controller to move to a specified LOAD instead of a specified position/velocity. Provided you could appropriately condition the signal, this is the best choice.
    Unfortunately, you cannot implement limit switches/etc over RTSI, so I believe that this will not be a good option.
    A third, and probably most un-desireable option, is to output a voltage on the PXI-6025E proportional to the load received from the load cell. This voltage could then be used as the analog feedback for your motion device. This, however, still adds the software layer of delays.
    I hope these ideas help you out.
    Regards,
    Colin C.
    Applications Engineering
    Colin Christofferson
    Community Web Marketing
    Blog

  • I'm using gradient mesh tool

    Hi. I'm learning how use gradient mesh. the problem I'm having is there is one anchor point on one of my paths that keeps going back to white. I select it with the white arrow and use the eyedropper tool to replace the color, switch to a new anchor, then go back to the original anchor point and it becomes white again. I have even tried deleting the anchor point and replacing it and it encounters the same problem. Any ideas how I can fix this?

    We can't know. You have not provided any screenshot, no info about what version of AI, no system info.
    Mylenium

  • CS6 how to use gradient Tool for outline

    Hi!
    I am a graphic designer I like to work hand and not numbers. The new version of Ai CS6 gradients can be given for strokes. Great!
    Please help me how exactly I can do it with a convenient tool 'Gradient Tool'?
    Does not respond to changes in drag when I try to use the mouse to outline?
    In advertising and instructions CS6 somehow strange is described ... I do not understand.
    http://helpx.adobe.com/illustrator/using/gradient-panel-gradient-tool-overview.html
    Regards!

    @Ivan David: Thank you for your response. I asked for something else. How to use the "Gradient Tool" no gradient palete. Why are chceck "ON" you own answer as helpful?
    As I explained I am a graphic designer will create a hands than numbers. I do not understand why no tool "gradient tool" works to fill but it does not work on outline.
    If I get a chance to show off with a representative of Adobe's a bit like crying...
    We need fair and real changes. According to me the most to do is to think about using Illustrator for themselves of their creators Illustrator.
    * For example in work with new gradient tool.
    - Why when you edit the gradient for the outline of the object is displayed slider gradient fill???. It's confusing and totally unnecessary.
    - Why is the Gradient Tool Outline tool does not work???
    - Why Control bar does not drop the Gradient icon??? What is the control bar when no controls? Control Bar cool idea but how would the developers were thinking of him as a stranger?
    - Why still the option of working with the gradient tool to fill, when you edit a color marker, I can not turn on the Eyedropper tool to select a color from another object???
    - Why does the apperance in the attributes panel stoke attribute does not appear easy gradient of a potential of gradient palette???
    - Why can not I fast copy between objects only attribute gradient???
    After all, it's easy and does not require a great job developers reach a solution to the function. I know that my naive questions now, and nobody I will not answer to them but sorrow grows. Sometimes I feel like a fly in pitch.
    This is not normal.
    So many years have passed, there was a lot of new tools but Adobe wants to use the same techniques as in his first product. Refresh in the new 64 bit version is also not so different to that in compared to regular equipment and are currently using...
    http://www.youtube.com/watch?v=N3TDmvZma84
    Sorry for the harsh words of criticism, But your answer is a perfect example that Adobe does not know what's going to people who work with Illustrator on a daily basis and  as can be seen starting to irritate me tight.
    Perhaps I have exaggerated expectations about the tools Adobe. I understand that there is so much work and needs, but I lack only a change of thinking about working with tools in Illustartor and reducing unnecessary clicks. Now, instead of tools to work with each other often exclusive and force running around.
    Regards!

  • How to use gradient colors in Muse?

    Is there a way to use gradient colors in Muse?  I keep reading that you can but there is no instructions that I can find how to do it. 

    I found it.

  • Error Message using Gradients - Not enough solid color

    "This library cannot be used because it does not have enough solid color swatches. Gradients and patterns cannot be used." What does this error message mean when I am trying to use gradient swatches and how to do I stop it?

    Step 1: Click on the Color Guide Dropdown
    Step 2: Select Gradients
    Step 3: Get Error Message

  • [svn:fx-trunk] 7155: Line bug fixes when using gradient strokes

    Revision: 7155
    Author:   [email protected]
    Date:     2009-05-20 14:39:39 -0700 (Wed, 20 May 2009)
    Log Message:
    Line bug fixes when using gradient strokes
    SDK-21272 - Lines with gradient (LinearGradientStroke) draw as solid color if perfectly vertical / horizontal
    StrokedElement was not taking the stroke weight into account when passing the bounds to the stroke. The gradient strokes rely on the bounds to help them transform the gradient to fit the shape of the stroke.
    SDK-21274 - Line with gradient stroke does not draw properly
    This bug occurs when the Line has a non-zero x and/or y values and is sharing a DisplayObject. StrokedElement was passing the stroke the measuredX and measuredY position as part of the bounds. Instead, I've changed it to pass in drawX + measuredX and drawY + measuredY which accounts for the drawing offset position.
    QE Notes: Test Line w/ gradient strokes
    Doc Notes: None
    Bugs: SDK-21272, SDK-21274
    Reviewer: Evtim
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-21272
        http://bugs.adobe.com/jira/browse/SDK-21274
        http://bugs.adobe.com/jira/browse/SDK-21272
        http://bugs.adobe.com/jira/browse/SDK-21274
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/supportClasses/StrokedEleme nt.as

    This bug figures out also when creating a custom spark ComboBox, then trying to programatically update the userProposedSelectedIndex property. The proposed selected index is selected, but does not apply the same skin as when mouse is on rollover or item is selected due to up and down keys.
    The issue seems like updating the status of the item renderer to rollover or selected to get the same skin applied.
    Please could you attach DropDow nList.as that you edited ?
    Thank you so much.

  • Tension control in labview using PCI 7354 Motion Control Board

    I want to make a program for web tension control of roll to roll system in labview using PCI 7354 Motion Control Board. Is there any interface program that can convert my controller output in a format to be directly used as the input of PCI 7354 (Motion Controller Board) for tension control?
    Thank you!

    thanks for your reply, i have already make the code of a straight line move and the motor moves successfully, but know i want to put the H-bridge to be able to make a reverse direction for the motor, for your information i only use a PCI-7340 controller and a UMI-7774, where the controller connected to the UMI-7774, the UMI connected to a PWM circuit and the PWM connected to the DC-motor, so what do you think i can do?

  • Unable to use gradient tool on placed photo Photoshop CS Trial

    I placed a jpg photo over another photo and attempted to use gradient tool tool but it indicated cannot smart object cannot be edited directly.  It gives me a circle with a line through it with this statement.  I am operating a trial version of CS5 on Windows XP. What  am I missing.  Use to use CS3 and Photoshop 5.0.  Must be another step.  Cannot answer.

    You could double click on the smart object icon to edit the smart object contents
    or rasterize the the smart object.
    You could also use a gradient overlay layer style or gradint fill adjustment layer.
    More about smart objects:
    http://help.adobe.com/en_US/photoshop/cs/using/WSCCBCA4AB-7821-4986-BC03-4D1045EF2A57a.htm l
    MTSTUNER

  • How to create the perfect gradient in motion

    Hi does anyone know how to create a gradient background in motion without it banding in the final movie ?
    Paul

    Hillster wrote:
    What is Floating Point?
    Floating point math. Open your project properties (CMD+J) and change the bit depth to 16 or 32 bit float. It'll cause a tremendous slowdown of playback, but presumably you should just be able to leave it off until you're ready to export.
    Also, use the best compression you can afford to. Uncompressed, Animation (maybe), or even a TIFF sequence. The less you're compressing the file, the better it'll look.
    Andy

  • Transparency of white gradients: Nesting Motion in FCP

    Hi there. If I nest a motion project into FCP that has white gradient transparency and super it onto video, it introduces black into the tranparency. When importing the PSD file that was animated in Motion directly into FCP as a super, the white transparency gradient works perfect. But that defeats the joy of animating elements in Motion for FCP.
    I have tried changing the Motion Project background to white transparent (vs default black), but that makes no difference.
    Anyone out there knows the solution?

    New Discussions ReponsesThe new system for discussions asks that after you mark your question as Answered, you take the time to mark any posts that have aided you with the tag and the post that provided your answer with the tag. This not only gives points to the posters, but points anyone searching for answers to similar problems to the proper posts.
    If we use the forums properly they will work well...
    Patrick

Maybe you are looking for

  • What's the optimum version of Safari for OS 10.3.9?

    My first post here. What is the optimum version of Safari for use on a PowerBook G3 "Pismo" running OS 10.3.9? I'm currently running 1.2 (v 125). I've downloaded 1.3.1 but when I try to install it says "Not compatible with this system." Is there some

  • ShowOptionDialog - one works, one doesn't

    Just learning and prototyping a program at the same time. 2 classes to do the same thing different ways. the fist works, the second doesn't. The problem is in the displaying of the showOptionDialog in the getConfirmation function. In the second the d

  • 90 days are over and still unable to sync

    I had an old itunes account with old style format for apple ID.  When I bought a new iPOD touch and tried to sync it to my library, it forced me to change apple ID to email based format.   It said I had to wait 90 days for my old library (on computer

  • Need help saving user information

    I was just asked to start looking into how we will save user information from a Flex application.  We will need to store information for each user such as the following: 1) sort settings for all objects for grids. 2) which page/window user was in. 3)

  • I uninstalled my Elements 10, I have my serial number how do I reinstall it, and will it be able to except files from Canons new camera dos 70d?

    I uninstalled my elements 10, I want to reinstall it, because elements 12 does not have the lighting effects, and because it seems impossible to use, I bought it because i am having trouble getting my camera raw files excepted in elements 10 from Can