Search in sources :

Example 1 with ImageBrush

use of com.fastasyncworldedit.core.command.tool.brush.ImageBrush in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method imageBrush.

@Command(name = "image", desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.image")
public void imageBrush(LocalSession session, InjectedValueAccess context, @Arg(desc = "Image URL (imgur only)") String imageURL, @Arg(desc = "The size of the brush", def = "5") Expression radius, @Arg(def = "1", desc = "scale height") double yscale, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut) throws WorldEditException, IOException {
    URL url = new URL(imageURL);
    if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
        throw new IOException("Only i.imgur.com links are allowed!");
    }
    BufferedImage image = MainUtil.readImage(url);
    worldEdit.checkMaxBrushRadius(radius);
    if (yscale != 1) {
        ImageUtil.scaleAlpha(image, yscale);
        alpha = true;
    }
    if (fadeOut) {
        ImageUtil.fadeAlpha(image);
        alpha = true;
    }
    ImageBrush brush = new ImageBrush(image, session, alpha);
    set(context, brush, "worldedit.brush.image").setSize(radius);
}
Also used : ImageBrush(com.fastasyncworldedit.core.command.tool.brush.ImageBrush) IOException(java.io.IOException) URL(java.net.URL) BufferedImage(java.awt.image.BufferedImage) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

ImageBrush (com.fastasyncworldedit.core.command.tool.brush.ImageBrush)1 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Command (org.enginehub.piston.annotation.Command)1