Doubts on LinearGradient#proportional=true
Gerrit Grunwald
han.solo at muenster.de
Fri Jun 8 07:40:16 PDT 2012
Hi,
But you defined the LinearGradient to start at 0, 0 and the Rectangle starts at 40, 0 so i guess the behavior is correct.
The following code should give you what you expected to get:
LinearGradient lg = new LinearGradient(r.getX(), 0, r.getWidth(), 0, false, CycleMethod.NO_CYCLE, stops);
Cheers,
Gerrit
Am 08.06.2012 um 16:33 schrieb Tom Schindl:
> Hi,
>
> I'm not sure if i understood proportional true wrong or I'm found a
> serious bug.
>
>> import java.util.ArrayList;
>> import java.util.List;
>>
>> import javafx.application.Application;
>> import javafx.scene.Group;
>> import javafx.scene.Scene;
>> import javafx.scene.paint.Color;
>> import javafx.scene.paint.CycleMethod;
>> import javafx.scene.paint.LinearGradient;
>> import javafx.scene.paint.Stop;
>> import javafx.scene.shape.Rectangle;
>> import javafx.stage.Stage;
>>
>> public class TestGradient extends Application {
>>
>> /**
>> * @param args
>> */
>> public static void main(String[] args) {
>> launch(args);
>> }
>>
>> @Override
>> public void start(Stage primaryStage) throws Exception {
>> Group g = new Group();
>> Rectangle r = new Rectangle(40,0,90,75);
>> List<Stop> stops = new ArrayList<Stop>();
>> stops.add(new Stop(0, Color.RED));
>> stops.add(new Stop(1, Color.BLUE));
>> LinearGradient lg = new LinearGradient(0, 0, 90, 0, false, CycleMethod.NO_CYCLE, stops);
>> r.setFill(lg);
>> g.getChildren().add(r);
>> Scene s = new Scene(g,200,200);
>> primaryStage.setScene(s);
>> primaryStage.show();
>> }
>>
>> }
>
> Running this code gives me an UI like shown in the attached screenshot.
> Is this really the right behaviour? I'd expect red to start on the left
> of the rect and end at 1/2 of the width.
>
> Tom
>
> --
> B e s t S o l u t i o n . a t EDV Systemhaus GmbH
> ------------------------------------------------------------------------
> tom schindl geschäftsführer/CEO
> ------------------------------------------------------------------------
> eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
> http://www.BestSolution.at phone ++43 512 935834
More information about the openjfx-dev
mailing list