GithubHelp home page GithubHelp logo

oliver-loeffler / derivecolorsfx Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 1.0 349 KB

A small tools to play with JavaFX Color.derive() function - allows to create custom colors and to save those in color palettes.

License: Apache License 2.0

Batchfile 3.38% Shell 2.11% Java 91.21% CSS 3.30%

derivecolorsfx's People

Contributors

oliver-loeffler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lvxingtu

derivecolorsfx's Issues

Snapshot

Maybe I can help you with your snapshot problem.

public static WritableImage renderScaleAwareSnapshot(Canvas canvas, double renderScale) {
	return renderScaleAwareSnapshot(canvas, renderScale, null, 0.0, 0.0, canvas.getWidth(), canvas.getHeight());
}

public static WritableImage renderScaleAwareCanvasSnapshot(Canvas canvas, double renderScale,
		WritableImage writableImage) {
	return renderScaleAwareSnapshot(canvas, renderScale, writableImage, 0.0, 0.0, canvas.getWidth(),
			canvas.getHeight());
}

public static WritableImage renderScaleAwareSnapshot(Node node, double renderScale, WritableImage writableImage,
		double x, double y, double width, double height) {
	int renderWidth = (int) Math.rint(renderScale * width);
	int renderHeight = (int) Math.rint(renderScale * height);
	if (writableImage == null || (int) Math.rint(writableImage.getWidth()) != renderWidth
			|| (int) Math.rint(writableImage.getHeight()) != renderHeight) {
		writableImage = new WritableImage(renderWidth, renderHeight);
	}
	SnapshotParameters spa = new SnapshotParameters();
	spa.setViewport(new Rectangle2D(x * renderScale, y * renderScale, width, height));
	spa.setTransform(Transform.scale(renderScale, renderScale));
	return node.snapshot(spa, writableImage);
}

This code does a canvas snapshot but the principle is the same for any kind of node. You can see how I handle the renderScale (2.0 for Retina).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.