當前位置: 首頁>>代碼示例>>Java>>正文


Java Color.hsb方法代碼示例

本文整理匯總了Java中javafx.scene.paint.Color.hsb方法的典型用法代碼示例。如果您正苦於以下問題:Java Color.hsb方法的具體用法?Java Color.hsb怎麽用?Java Color.hsb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.paint.Color的用法示例。


在下文中一共展示了Color.hsb方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createColorVariations

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final Color[] createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
    int    noOfColors = clamp(1, 5, NO_OF_COLORS);
    double step       = 0.8 / noOfColors;
    double hue        = COLOR.getHue();
    double brg        = COLOR.getBrightness();
    Color[] colors = new Color[noOfColors];
    for (int i = 0 ; i < noOfColors ; i++) { colors[i] = Color.hsb(hue, 0.2 + i * step, brg); }
    return colors;
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:10,代碼來源:Helper.java

示例2: getColorRangeMinMax

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final Color[] getColorRangeMinMax(final Color COLOR, final int STEPS) {
    double hue            = COLOR.getHue();
    double saturation     = COLOR.getSaturation();
    double brightness     = COLOR.getBrightness();
    double saturationStep = saturation / STEPS;
    double brightnessStep = brightness / STEPS;
    double halfSteps      = STEPS / 2;
    Color fromColor       = COLOR.hsb(hue, saturation, clamp(0, 1, brightness + brightnessStep * halfSteps));
    Color toColor         = COLOR.hsb(hue, saturation, clamp(0, 1, brightness - brightnessStep * halfSteps));
    return new Color[] { fromColor, toColor };
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:12,代碼來源:Helper.java

示例3: create3dContent

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public Node create3dContent() {

        Xform sceneRoot = new Xform();

        cubeXform = new Xform[128];
        cube = new Cube[128];

        int i;
        for (i = 0; i < 128; i++) {
            cubeXform[i] = new Xform();
            cubeXform[i].setTranslateX((double) 2);
            cube[i] = new Cube(1.0, Color.hsb((double) i*1.2, 1.0, 1.0, 0.3), 1.0);
            if (i == 0) {
                sceneRoot.getChildren().add(cubeXform[i]);
            }
            else if (i >= 1) {
                cubeXform[i-1].getChildren().add(cubeXform[i]);
            }
            cubeXform[i].getChildren().add(cube[i]);
        }

        audioSpectrumListener = this;
        getAudioMediaPlayer().setAudioSpectrumListener(audioSpectrumListener);
        getAudioMediaPlayer().play();
        getAudioMediaPlayer().setAudioSpectrumInterval(0.02);
        getAudioMediaPlayer().setAudioSpectrumNumBands(128);
        getAudioMediaPlayer().setCycleCount(Timeline.INDEFINITE);

        sceneRoot.setRotationAxis(Rotate.X_AXIS);
        sceneRoot.setRotate(180.0);
        sceneRoot.setTranslateY(-100.0);

        return sceneRoot;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:AudioVisualizer3D.java

示例4: SimpleHSBColorPicker

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public SimpleHSBColorPicker() {
    getChildren().addAll(hsbRect,lightRect);
    lightRect.setStroke(Color.GRAY);
    lightRect.setStrokeType(StrokeType.OUTSIDE);
    EventHandler<MouseEvent> ml = new EventHandler<MouseEvent>() {
        @Override public void handle(MouseEvent e) {
            double w = getWidth();
            double h = getHeight();
            double x = Math.min(w, Math.max(0, e.getX()));
            double y = Math.min(h, Math.max(0, e.getY()));
            double hue = (360/w)*x;
            double vert = (1/h)*y;
            double sat = 0;
            double bright = 0;
            if (vert<0.5) {
                bright = 1;
                sat = vert * 2;
            } else {
                bright = sat = 1- ((vert-0.5)*2);
            }
            // convert back to color
            Color c =  Color.hsb((int)hue,sat,bright);
            color.set(c);
            e.consume();
        }
    };
    lightRect.setOnMouseDragged(ml);
    lightRect.setOnMouseClicked(ml);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:30,代碼來源:SimpleHSBColorPicker.java

示例5: buildHueBar

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private LinearGradient buildHueBar() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 1.0, 1.0));
    }
    return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:SimpleHSBColorPicker.java

示例6: createIconContent

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static Node createIconContent() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 0.8, 0.9));
    }
    Rectangle rect = new Rectangle(80,80,
            new LinearGradient(0f, 0f, 1f, 1f, true, CycleMethod.NO_CYCLE, stops));
    rect.setArcWidth(20);
    rect.setArcHeight(20);
    return rect;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:15,代碼來源:ColorSample.java

示例7: create3dContent

import javafx.scene.paint.Color; //導入方法依賴的package包/類
@Override public Node create3dContent() {

        Xform sceneRoot = new Xform();

        cubeXform = new Xform[128];
        cube = new Cube[128];

        int i;
        for (i = 0; i < 128; i++) {
            cubeXform[i] = new Xform();
            cubeXform[i].setTranslateX((double) 2);
            cube[i] = new Cube(1.0, Color.hsb((double) i*1.2, 1.0, 1.0, 0.3), 1.0);
            if (i == 0) {
                sceneRoot.getChildren().add(cubeXform[i]);
            }
            else if (i >= 1) {
                cubeXform[i-1].getChildren().add(cubeXform[i]);
            }
            cubeXform[i].getChildren().add(cube[i]);
        }

        audioSpectrumListener = this;
        getAudioMediaPlayer().setAudioSpectrumListener(audioSpectrumListener);
        getAudioMediaPlayer().play();
        getAudioMediaPlayer().setAudioSpectrumInterval(0.02);
        getAudioMediaPlayer().setAudioSpectrumNumBands(128);
        getAudioMediaPlayer().setCycleCount(Timeline.INDEFINITE);

        sceneRoot.setRotationAxis(Rotate.X_AXIS);
        sceneRoot.setRotate(180.0);
        sceneRoot.setTranslateY(-100.0);

        return sceneRoot;
    }
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:35,代碼來源:AudioVisualizerSample.java

示例8: createHueGradient

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private static LinearGradient createHueGradient() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int x = 0; x < 255; x++) {
        offset = 1.0 / 255 * x;
        int h = (int) ((x / 255.0) * 360);
        stops[x] = new Stop(offset, Color.hsb(h, 1, 1));
    }
    return new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
}
 
開發者ID:rmfisher,項目名稱:fx-animation-editor,代碼行數:11,代碼來源:ColorPickerComponent.java

示例9: createHueGradient

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private static LinearGradient createHueGradient() {
    final Stop[] stops = new Stop[255];
    for (int x = 0; x < 255; x++) {
        final double offset = (1.0 / 255.0) * x;
        final int hue = (int)((x / 255.0) * 360);
        stops[x] = new Stop(offset, Color.hsb(hue, 1.0, 1.0));
    }
    return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
 
開發者ID:aNNiMON,項目名稱:HotaruFX,代碼行數:10,代碼來源:ColorPickerBox.java

示例10: annotate

import javafx.scene.paint.Color; //導入方法依賴的package包/類
@Override
public void annotate(GLAutoDrawable drawable) {
    if (!isFilterEnabled()) {
        return;
    }

    GL2 gl = drawable.getGL().getGL2();
    gl.glPushMatrix();

    for (int c=0; c<numCameras; c++){
        medianTrackers[c].annotate(drawable);
        Float hue= (float) c*360/numCameras; // conversion in hue value, dependindin on the number of cameras
        Color color=Color.hsb(hue, 0.5f, 1f);
        gl.glColor3d(color.getRed(), color.getGreen(), color.getBlue());
        gl.glLineWidth(4);
        gl.glBegin(GL2.GL_LINE_LOOP);
        Point2D p = medianTrackers[c].getMedianPoint();
        Point2D s = medianTrackers[c].getStdPoint();
        int sx=chip.getSizeX();
        int sy=chip.getSizeY();
        gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() - s.getY());
        gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() - s.getY());
        gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() + s.getY());
        gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() + s.getY());
        gl.glEnd();
    }
    gl.glPopMatrix();
    
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:30,代碼來源:ZebrafishMedianTracker.java

示例11: getComplementaryColor

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final Color getComplementaryColor(final Color COLOR) {
    return Color.hsb(COLOR.getHue() + 180, COLOR.getSaturation(), COLOR.getBrightness());
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:4,代碼來源:Helper.java

示例12: updateUI

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private Color updateUI(double hue, double saturation, double brightness, double alpha) {

        // Position the picker dot
        double xSat = picker_region.getWidth() * saturation; // Saturation is on x axis
        double yBri = picker_region.getHeight() * (1.0 - brightness); // Brightness is on y axis (reversed as white is top)
        double xPos = (picker_region.getBoundsInParent().getMinX() + xSat) - picker_handle_stackpane.getWidth() / 2;
        double yPos = (picker_region.getBoundsInParent().getMinY() + yBri) - picker_handle_stackpane.getHeight() / 2;
        xPos = ColorEncoder.clamp(xPos, 0, picker_region.getPrefWidth() - (picker_handle_stackpane.getWidth()));
        yPos = ColorEncoder.clamp(yPos, 0, picker_region.getPrefHeight() - (picker_handle_stackpane.getHeight()));
        picker_handle_stackpane.setLayoutX(xPos);
        picker_handle_stackpane.setLayoutY(yPos);

        // update the HSB values so they are within range
        saturation = ColorEncoder.clamp(0, saturation, 1);
        brightness = ColorEncoder.clamp(0, brightness, 1);
      //  alpha = PaintPickerController.clamp(0, alpha, 1);

        // make an rgb color from the hsb
        final Color color = Color.hsb(hue, saturation, brightness, alpha);
        int red = (int) (color.getRed() * 255);
        int green = (int) (color.getGreen() * 255);
        int blue = (int) (color.getBlue() * 255);

        String hexa = ColorEncoder.encodeColor(color);

        // Set TextFields value
        hue_textfield.setText(String.valueOf((int) hue));
        saturation_textfield.setText(String.valueOf((int) (saturation * 100)));
        brightness_textfield.setText(String.valueOf((int) (brightness * 100)));

        alpha_textfield.setText(Double.toString(alpha));
        red_textfield.setText(Integer.toString(red));
        green_textfield.setText(Integer.toString(green));
        blue_textfield.setText(Integer.toString(blue));
        hexa_textfield.setText(hexa.toUpperCase());

        final String chipStyle = "-fx-background-color: " + hexa; //NOI18N
        chip_region.setStyle(chipStyle);
        picker_handle_chip_circle.setFill(Color.rgb(red, green, blue));
        final String alphaChipStyle = "-fx-background-color: " //NOI18N
                + "linear-gradient(to right, transparent, " + hexa + ")"; //NOI18N
        alpha_slider.setAlphaChipCSS(alphaChipStyle);

        // Set the background color of the picker region
        // (force saturation and brightness to 100% - don't add opacity)
        final String pickerRegionStyle = "-fx-background-color: hsb(" //NOI18N
                + hue + ", 100%, 100%, 1.0);"; //NOI18N
        picker_region.setStyle(pickerRegionStyle);

        return color;
    }
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:52,代碼來源:ColorPickerControl.java

示例13: SanFranciscoFireworks

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public SanFranciscoFireworks() {
    // create a color palette of 180 colors
    colors = new Paint[181];
    colors[0] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, 
                new Stop(0, Color.WHITE),
                new Stop(0.2, Color.hsb(59, 0.38, 1)),
                new Stop(0.6, Color.hsb(59, 0.38, 1,0.1)),
                new Stop(1, Color.hsb(59, 0.38, 1,0))
                );
    for (int h=0;h<360;h+=2) {
        colors[1+(h/2)] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, 
                new Stop(0, Color.WHITE),
                new Stop(0.2, Color.hsb(h, 1, 1)),
                new Stop(0.6, Color.hsb(h, 1, 1,0.1)),
                new Stop(1, Color.hsb(h, 1, 1,0))
                );
    }
    // create canvas
    canvas = new Canvas(1024, 500);

    canvas.setBlendMode(BlendMode.ADD);
    canvas.setEffect(new Reflection(0,0.4,0.15,0));
    background = new ImageView(getClass().getResource("sf.jpg").toExternalForm());
    getChildren().addAll(background,canvas);
    // create animation timer that will be called every frame
    // final AnimationTimer timer = new AnimationTimer() {
    timer = new AnimationTimer() {

        @Override public void handle(long now) {
            GraphicsContext gc = canvas.getGraphicsContext2D();
            // clear area with transparent black
            gc.setFill(Color.rgb(0, 0, 0, 0.2));
            gc.fillRect(0, 0, 1024, 708);
            // draw fireworks
            drawFireworks(gc);
            // countdown to launching the next firework
            if (countDownTillNextFirework == 0) {
                countDownTillNextFirework = 10 + (int)(Math.random()*30);
                fireParticle();
            }
            countDownTillNextFirework --;
        }
    };
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:45,代碼來源:FireworksSample.java

示例14: getRegionalPaint

import javafx.scene.paint.Color; //導入方法依賴的package包/類
protected static Paint getRegionalPaint(int region)
{
	RAND.setSeed(region);
	return Color.hsb(RAND.nextInt(360), 0.5, 0.7);
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:6,代碼來源:DungeonTile.java


注:本文中的javafx.scene.paint.Color.hsb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。