public static AreaEffects createRandom(Random rand) { AreaEffects ae = new AreaEffects(); float f = rand.nextFloat(); if(f < 0.25f) { ae.setNeonBorderEffect(new NeonBorderEffect()); } else if(f < 0.5f) { ae.setDropShadowEffect(new ShadowPathEffect(1.0f)); } else if(f < 0.75f) { ae.setInnerGlowEffect(new InnerGlowPathEffect(1.0f)); } else { ae.setGlowEffect(new GlowPathEffect(1.0f)); } return ae; }
private void updateDropShadowFromGUI(AreaEffects effects) { ShadowPathEffect dropShadowEffect = null; if (dropShadowPanel.isSelected()) { dropShadowEffect = new ShadowPathEffect(dropShadowPanel.getOpacity()); dropShadowPanel.updateEffectColorAndBrush(dropShadowEffect); dropShadowEffect.setOffset(dropShadowPanel.getOffset()); } effects.setDropShadowEffect(dropShadowEffect); }
@Test public void testShadowPathEffect() { ShadowPathEffect effect = new ShadowPathEffect(); assertEquals(Color.BLACK, effect.getBrushColor()); assertEquals(10, effect.getBrushSteps()); assertEquals(8, effect.getEffectWidth()); assertEquals(new Point(3,3), effect.getOffset()); assertFalse(effect.isRenderInsideShape()); assertTrue(effect.isShouldFillShape()); } @Test
private static ImageLayer addRasterizedTextLayer(Composition comp, String text, Color textColor, Font font, int translationY, BlendingMode blendingMode, float opacity, boolean dropShadow) { ImageLayer layer = addNewLayer(comp, text); TextFilter textFilter = TextFilter.getInstance(); AreaEffects effects = null; if (dropShadow) { effects = new AreaEffects(); effects.setDropShadowEffect(new ShadowPathEffect(1.0f)); } TextSettings settings = new TextSettings(text, font, textColor, effects, AbstractLayoutPainter.HorizontalAlignment.CENTER, AbstractLayoutPainter.VerticalAlignment.CENTER, false, 0); textFilter.setSettings(settings); textFilter.startOn(layer, FILTER_WITHOUT_DIALOG); layer.startMovement(); layer.moveWhileDragging(0, translationY); layer.endMovement(); layer.enlargeImage(layer.getComp().getCanvasImBounds()); layer.setOpacity(opacity, true, true, true); layer.setBlendingMode(blendingMode, true, true, true); return layer; }