use of javafx.scene.image.PixelWriter in project processing by processing.
the class PGraphicsFX2D method flushPixels.
protected void flushPixels() {
boolean hasPixels = modified && pixels != null;
if (hasPixels) {
// If the user has been manipulating individual pixels,
// the changes need to be copied to the screen before
// drawing any new geometry.
int mx1 = getModifiedX1();
int mx2 = getModifiedX2();
int my1 = getModifiedY1();
int my2 = getModifiedY2();
int mw = mx2 - mx1;
int mh = my2 - my1;
PixelWriter pw = context.getPixelWriter();
pw.setPixels(mx1, my1, mw, mh, argbFormat, pixels, mx1 + my1 * pixelWidth, pixelWidth);
}
modified = false;
}
use of javafx.scene.image.PixelWriter in project FXyzLib by Birdasaur.
the class Palette method createPalette.
public Image createPalette(boolean save) {
if (numColors < 1) {
return null;
}
// try to create a square image
width = (int) Math.sqrt(numColors);
height = numColors / width;
imgPalette = new WritableImage(width, height);
PixelWriter pw = ((WritableImage) imgPalette).getPixelWriter();
AtomicInteger count = new AtomicInteger();
IntStream.range(0, height).boxed().forEach(y -> IntStream.range(0, width).boxed().forEach(x -> pw.setColor(x, y, getColor(count.getAndIncrement()))));
if (save) {
saveImage();
}
return imgPalette;
}
use of javafx.scene.image.PixelWriter in project JFoenix by jfoenixadmin.
the class JFXColorPickerUI method getSLCricle.
private Image getSLCricle(int width, int height, List<Stop> stops) {
WritableImage raster = new WritableImage(width, height);
PixelWriter pixelWriter = raster.getPixelWriter();
Point2D center = new Point2D((double) width / 2, (double) height / 2);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double dy = x - center.getX();
double dx = y - center.getY();
pixelWriter.setColor(x, y, getColor(dx, dy));
}
}
return raster;
}
use of javafx.scene.image.PixelWriter in project JFoenix by jfoenixadmin.
the class JFXColorPickerUI method getHuesCircle.
private Image getHuesCircle(int width, int height, List<Stop> stops) {
WritableImage raster = new WritableImage(width, height);
PixelWriter pixelWriter = raster.getPixelWriter();
Point2D center = new Point2D((double) width / 2, (double) height / 2);
double rsmall = 0.8 * width / 2;
double rbig = (double) width / 2;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
double dx = x - center.getX();
double dy = y - center.getY();
double distance = Math.sqrt((dx * dx) + (dy * dy));
double o = Math.atan2(dy, dx);
if (distance > rsmall && distance < rbig) {
double H = map(o, -Math.PI, Math.PI, 0, 255);
double S = 255;
double L = 152;
pixelWriter.setColor(x, y, HSL2RGB(H, S, L));
}
}
}
return raster;
}
use of javafx.scene.image.PixelWriter in project processing by processing.
the class PGraphicsFX2D method setImpl.
@Override
protected void setImpl(PImage sourceImage, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY) {
sourceImage.loadPixels();
int sourceOffset = sourceX + sourceImage.pixelWidth * sourceY;
PixelWriter pw = context.getPixelWriter();
pw.setPixels(targetX, targetY, sourceWidth, sourceHeight, argbFormat, sourceImage.pixels, sourceOffset, sourceImage.pixelWidth);
// Let's keep them loaded
if (loaded) {
int sourceStride = sourceImage.pixelWidth;
int targetStride = pixelWidth;
int targetOffset = targetX + targetY * targetStride;
for (int i = 0; i < sourceHeight; i++) {
System.arraycopy(sourceImage.pixels, sourceOffset + i * sourceStride, pixels, targetOffset + i * targetStride, sourceWidth);
}
}
}
Aggregations