How do I create an inner drop shadow in text with php Imagick please? - shadow

I'm at the beginning of the learning curve with ImageMagick.
I have successfully created some text on a patterned background with outer light drop shadow to give the nice appearance of cut-out text.
To finish off the effect I need to give the text and inner dark drop shadow.
Are there any ImageMagick experts out there who can help with the php please?
This is my code so far which I'm happy with.
<?php
header('Content-type: image/jpeg');
$background_layer = new Imagick('test_background.jpg'); # background image
$d = $background_layer->getImageGeometry();
$w = $d['width'];
$h = $d['height'];
$text_layer = new Imagick();
$text_layer->newImage($w, $h, new ImagickPixel('none'));
$text_layer->setImageFormat('png');
$ImagickDraw = new ImagickDraw();
$ImagickDraw->setFillColor('#484848');
$ImagickDraw->setFont('Helvetica-Bold');
$ImagickDraw->setFontSize( 40 );
$ImagickDraw->setTextAlignment(2); // centre
$text_layer->annotateImage( $ImagickDraw, $w / 2, 50, 0, "Stuart's\niPhone" );
// create white drop shadow on it's own layer
$shadow_layer_white = $text_layer->clone();
$shadow_layer_white->setImageBackgroundColor( new ImagickPixel( 'white' ) );
$shadow_layer_white->shadowImage( 70, .3, 1, 1 );
// composite original text_layer onto shadow_layer
$shadow_layer_white->compositeImage( $text_layer, Imagick::COMPOSITE_OVER, 0, 0 );
// composite shadow_layer (which now has text AND the shadow) onto image_layer
$background_layer->compositeImage( $shadow_layer_white, Imagick::COMPOSITE_OVER, 0, 0 );
echo($background_layer);
?>
I'm too new to post images so you can see what I have so far at
http://www.avforums.com/images/temptest.php
Any help you can give to add an internal dark drop shadow in the text would be appreciated.
Thanks

You are using Imagick not Imagemagick directly and may want to add that tag as well.
I do not use Imagick but shadeimage should do what you want in one go?

Related

mxGraph how to use edge in different way

I trying to create a network architecture using vertex and edge objects from mxGraph.
Now in first image ZCU_08_01 is connected to ZCU_01_01 as you see.
Is possible the modification using edges like in next image ? And if possible, how? (of course assuming straight line sections not "hand made" :) )
The edge is defined:
var E33 = graph.insertEdge(parent, null, '', ID618, ID620,'strokeColor=#FF0000;');
and the style definition for edges is:
style = graph.getStylesheet().getDefaultEdgeStyle();
style[mxConstants.STYLE_EDGE] = mxConstants.EDGESTYLE_ORTHOGONAL;
style[mxConstants.STYLE_EDGE] = mxConstants.EDGESTYLE_SIDETOSIDE;
style[mxConstants.STYLE_ENDARROW] = mxConstants.NONE;
style[mxConstants.STYLE_ROUNDED] = true;
Thank in advance

Shadow with transparent background in Jetpack Compose

Can anyone explain this?
And how to make the center rectangle with the color of the background disappear?
the result here
I've tried many ways but still can't understand the logic here. (different from Flutter UI)
Box(
modifier = Modifier
.fillMaxWidth()
.shadow(elevation = 3.dp, shape = RoundedCornerShape(28.dp))
.background(
MaterialTheme.colors.primary.copy(alpha = 0.8f),
shape = RoundedCornerShape(28.dp)
)
.padding(16.dp)
)
use like this -
.background(
MaterialTheme.colors.primary.copy(alpha = 0.8f).compositeOver(Color.White),
shape = RoundedCornerShape(28.dp)
)
the background basically shows for elevation and shadow, if you remove them then it will be gone, since you are using transparent color that's why you are seeing this. but make the color solid but light using compositeOver , then it will work fine.

cocos2d-x Why i can't set sprite hierarchy when using SpriteBatchNode?

Hey i try to set sprite hierarchy to parent root , taking the example from SpriteTest.cpp
from SpriteSkewNegativeScaleChildren example.
but in my code i allso add the sprites to SpriteBatchNode .
like this :
auto cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("leds/sprites.plist", "leds/sprites.png");
auto batch = SpriteBatchNode::create("leds/sprites.png");
Sprite* Sprite_all_side_connector = Sprite::createWithSpriteFrameName("all_side_connector.png");
batch->addChild(Sprite_all_side_connector);
Sprite* Sprite_one_side_connector = Sprite::createWithSpriteFrameName("one_side_connector.png");
batch->addChild(Sprite_one_side_connector);
Sprite* Sprite_purple_stick = Sprite::createWithSpriteFrameName("purple_stick.png");
batch->addChild(Sprite_purple_stick);
Sprite* Sprite_red_stick = Sprite::createWithSpriteFrameName("red_stick.png");
batch->addChild(Sprite_red_stick);
Sprite* Sprite_yellow_ball = Sprite::createWithSpriteFrameName("yellow_ball.png");
batch->addChild(Sprite_yellow_ball);
addChild(batch, 0, TAGS::SPRITEBATCHNODE);
Sprite_all_side_connector->setPosition(ccp(winSize.width/2,winSize.height/2));
auto parent = Node::create();
addChild(parent);
parent->addChild(Sprite_all_side_connector);
but im getting exception , when i remove the SpriteBatchNode every thing working fine .
i want to use the SpriteBatchNode feature for OpenGL one draw call .
the exception is in :
parent->addChild(Sprite_all_side_connector);
You will need to create another instance of Sprite_all_side_connector and add that to the scene. Sprites can only be added once. Change your code to:
parent->addChild(Sprite::createWithSpriteFrameName("all_side_connector.png"));
That should clean up the assertion.

Tabris UI Controls Demo Indication error on IPad and IPhone

I'm validating the Tabris framework at the moment and stumbled about a few indication errors when I tried the UI Control Code Snippets.
I added the VisualGuideDemo.java to my HelloWorld-Project and added a table to the display with the createTable function. In my browser it is displaying the expected output with 3 columns and 128 rows. When I test the application on an IPad mini or the IPhone Simulator ...
only the first Column is displayed,
it is not possible to scroll through the whole list (i can scroll about 60 items down, then the list "jumps" back)
and the width of the table does not adjust to the fullwidth of the screen.
See attached Screenshots
I also tried to add a TabFolder which uses the full width of the screen. I used the 'createTabFolder' method:
private void createTabFolder() {
final Shell shell = new Shell( display, SWT.NONE );
shell.setLayout( new FillLayout() );
final TabFolder tabFolder = new TabFolder( shell, SWT.NONE );
final TabItem tab0 = new TabItem( tabFolder, SWT.NONE );
tab0.setText( "Tab0" );
final TabItem tab1 = new TabItem( tabFolder, SWT.NONE );
tab1.setText( "Tab1" );
final TabItem tab2 = new TabItem( tabFolder, SWT.NONE );
tab2.setText( "Tab2" );
//shell.setSize( 300, 100 );
shell.open();
}
I uncommented the setSize function, but the TabFolder does not adjust to the full width of the screen (not in browser or on iOS device).
I'm new to SWT, RAP/Tabris so I am wondering if I miss something basic.
EDIT:
I guess several columns in one table are not supported in the mobile clients, but maybe it would be a nice feature to add the missing columns to the end of the list, seperated by listdividers. Is my assumption correct?
I found the solution to the width problem, I just had to call shell.setMaximized(true);

erasing a layer where mouse is over it

I got the following question.
i added the following elements to the stage:
homeBg = new HomeBg();
homeMask = new HomeDrawBg();
addChild(homeBg);
addChild(homeMask);
I allready instantiated them in the beginning of the document. But my problem is the following. the homeBg layer is a image, the homeMask layer is the same image but it has a pencil scetch look. What i want is that wherever i move my mouse, the homemask layer should be erased so the bottom layer becomes visible(only where the mask is erased). So how can i tell the mask layer to erase itself if the mouse is over it?
Answer attempt 2
You can use the blendMode property of a display object to achieve this. Here's the code (tested):
// set the eraser width (diameter)
var eraserWidth:int = 20;
//get the HomeMask library item
var homeMask:HomeMask = new HomeDrawBg();
homeMask.blendMode = BlendMode.LAYER;
addChild(homeMask);
// create the eraser shape
var eraser:Shape = new Shape();
eraser.graphics.beginFill(0x000000);
eraser.graphics.drawCircle(0,0,eraserWidth/2);
eraser.blendMode = BlendMode.ERASE;
homeMask.addChild(eraser);
homeMask.addEventListener(MouseEvent.MOUSE_MOVE,mouseOverMask);
function mouseOverMask(evt:MouseEvent):void
{
eraser.x = homeMask.mouseX;
eraser.y = homeMask.mouseY;
}
There are a couple of important bits here.
Firstly, you must set the blendMode of the thing you want to erase to BlendMode.LAYER.
Secondly (and this is what has tricked me before) your eraser, with BlendMode.ERASE, must be a child of the object you're wanting to erase.
Have a look on the following:http://www.piterwilson.com/personal/2008/05/07/bitmapdata-erasing-in-as3-with-custom-brush-shape/