Search in sources :

Example 1 with IImage

use of de.mossgrabers.framework.graphics.IImage in project DrivenByMoss by git-moss.

the class GraphicsContextImpl method maskImage.

/**
 * {@inheritDoc}
 */
@Override
public void maskImage(final IImage icon, final double x, final double y, final ColorEx maskColor) {
    final ImageImpl imageImpl = (ImageImpl) icon;
    try {
        this.setColor(maskColor);
        final Image image = imageImpl.image();
        this.gc.mask(image, x, y);
        this.gc.fill();
    } catch (final RuntimeException ex) {
        ex.printStackTrace();
    }
}
Also used : Image(com.bitwig.extension.api.graphics.Image) IImage(de.mossgrabers.framework.graphics.IImage)

Example 2 with IImage

use of de.mossgrabers.framework.graphics.IImage in project DrivenByMoss by git-moss.

the class ChannelComponent method drawButton.

/**
 * Draws a button a gradient background.
 *
 * @param gc The graphics context
 * @param left The left bound of the drawing area
 * @param top The top bound of the drawing area
 * @param width The width of the drawing area
 * @param height The height of the drawing area
 * @param backgroundColor The background color
 * @param isOnColor The color if the button is on
 * @param textColor The color of the buttons text
 * @param isOn True if the button is on
 * @param iconName The name of the buttons icon
 * @param configuration The layout settings
 * @param radius The radius of the surrounding border rectangle
 */
private void drawButton(final IGraphicsContext gc, final double left, final double top, final double width, final double height, final ColorEx backgroundColor, final ColorEx isOnColor, final ColorEx textColor, final boolean isOn, final String iconName, final IGraphicsConfiguration configuration, final double radius) {
    final ColorEx borderColor = this.modifyIfOff(configuration.getColorBorder());
    gc.fillRoundedRectangle(left, top, width, height, radius, borderColor);
    if (isOn)
        gc.fillRoundedRectangle(left + 1, top + 1, width - 2, height - 2, radius, isOnColor);
    else
        gc.fillGradientRoundedRectangle(left + 1, top + 1, width - 2, height - 2, radius, backgroundColor, ColorEx.brighter(backgroundColor));
    final IImage icon = ResourceHandler.getSVGImage(iconName);
    gc.maskImage(icon, left + (width - icon.getWidth()) / 2, top + (height - icon.getHeight()) / 2, isOn ? borderColor : textColor);
}
Also used : ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IImage(de.mossgrabers.framework.graphics.IImage)

Example 3 with IImage

use of de.mossgrabers.framework.graphics.IImage in project DrivenByMoss by git-moss.

the class LabelComponent method drawSeparateColorLayout.

/**
 * Draws the label in the SEPARATE_COLOR layout.
 *
 * @param info All necessary information to draw the component
 */
protected void drawSeparateColorLayout(final IGraphicsInfo info) {
    final IGraphicsContext gc = info.getContext();
    final IGraphicsDimensions dimensions = info.getDimensions();
    final IGraphicsConfiguration configuration = info.getConfiguration();
    final double left = info.getBounds().left();
    final double width = info.getBounds().width();
    final double top = info.getBounds().top();
    final double height = info.getBounds().height();
    final double unit = dimensions.getUnit();
    final double doubleUnit = dimensions.getDoubleUnit();
    // Draw the background
    final ColorEx bgColor = this.modifyIfOff(configuration.getColorBackground());
    gc.fillRectangle(left, top + 1, width, height - unit - 1, this.isSelected() ? this.modifyIfOff(configuration.getColorBackgroundLighter()) : bgColor);
    // The tracks icon and name
    final String iconName = this.getIcon();
    final int trackRowHeight = (int) (1.6 * unit);
    final double textTop = top + height - trackRowHeight - unit;
    if (iconName != null) {
        final IImage image = ResourceHandler.getSVGImage(iconName);
        final ColorEx maskColor = this.modifyIfOff(this.getMaskColor(configuration));
        if (maskColor == null)
            gc.drawImage(image, left + (doubleUnit - image.getWidth()) / 2, textTop + (trackRowHeight - image.getHeight()) / 2.0);
        else
            gc.maskImage(image, left + (doubleUnit - image.getWidth()) / 2, textTop + (trackRowHeight - image.getHeight()) / 2.0, maskColor);
    }
    gc.drawTextInBounds(this.text, left + doubleUnit, textTop, width - doubleUnit, trackRowHeight, Align.LEFT, this.modifyIfOff(configuration.getColorText()), 1.2 * unit);
    // The track color section
    final ColorEx infoColor = this.backgroundColor;
    gc.fillRectangle(left, top + height - unit, width, unit, this.isActive ? infoColor : ColorEx.evenDarker(infoColor));
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IImage(de.mossgrabers.framework.graphics.IImage) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

Aggregations

IImage (de.mossgrabers.framework.graphics.IImage)3 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)2 Image (com.bitwig.extension.api.graphics.Image)1 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)1 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)1 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)1