On setting certain foregroundColor, I'm gettting a inner shadow on the text - no other attributes are set.
span = new spanModule.Span();
span.foregroundColor = new colorModule.Color("green");
span.text = "test";
formattedString.spans.push(span);
Funny thing is that it happens with certain colors only.
So far, cyan, blue and green.
This is on Android - not tested on iOS.
In the image both "10" and "D" are part of the same formattedString but different spans - the difference is the foregroundColor and in the "D" the fontSize has been set. Actually if I change the color of the "D" to cyan also - there's a shadow. Even if I take out the fontSize.
Related
I have drawn some ink strokes on an InkCanvas and am now wanting to change the pen colour. I can change the colour of any additional strokes I draw using CopyDefaultDrawingAttributes and UpdateDefaultDrawingAttributes and that works fine. But how do I alter the color of the strokes that are already present StrokeContainer? I've tried:
foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes())
{
stroke.DrawingAttributes.Color = strokeColour;
};
This code executes with no exceptions, but stroke.DrawingAttributes.Color still shows the previous colour.
Any ideas?
Thanks...
Robert
You cannot set the DrawingAttributes property of the stroke directly. You must create a copy of the InkDrawingAttributes of the stroke, set the desired values for that InkDrawingAttributes object, and then assign the new InkDrawingAttributes to the DrawingAttributes of the stroke.
So you can code for example like this:
foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes())
{
//stroke.DrawingAttributes.Color = Windows.UI.Colors.Yellow;
InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
drawingAttributes.Color = Windows.UI.Colors.Yellow;
stroke.DrawingAttributes = drawingAttributes;
}
For more information, you can refer to InkStroke.DrawingAttributes | drawingAttributes property.
Since iOS 9 I got a problem with the background of the UIPopoverPresentationController. It seems the shape and color are broken.
In the code below I define a popover in the prepareForSegue function and I set its preferred content size and background color. The size is shown correctly but with some mistakes in the shape of the background view. Also the color is not set (the arrow and the broken shape are white instead of dark gray (picture)). In iOS 8 it has worked as expected.
The subclassing of the UIPopoverBackgroundView should be the last option, because I just want to change the color of it, nothing else.
Any ideas?
let vc = segue.destinationViewController as! StatisticSettings_TVC
vc.preferredContentSize = CGSizeMake(300.0, 400.0)
vc.view.backgroundColor = app.COLOR_STAT_LEGEND_BACKGROUND
if let ppc = vc.popoverPresentationController {
ppc.delegate = self
ppc.backgroundColor = app.COLOR_STAT_LEGEND_BACKGROUND
}
I generated some fonts in Hiero. If I set the font color with :
fontFPS.setColor(Color.YELLOW);
the text color it is drawn correctly.
But if I set it with
Color fpsColor = new Color(74f, 112f, 139f, 160f);
fontFPS.setColor(fpsColor);
then I only get white color with no alpha. What is the problem?
First of all float values inside that method should be from 0f to 1f. So your color should be (values I put in constructor are calculated by dividing your original values with 255)
Color fpsColor = new Color(0.29f, 0.43f, 0.54f, 0.66f);
Also you should enable blending like this (I'm not sure if you already did that)
Gdx.gl.glEnable(GL10.GL_BLEND);
Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA)
Ive searched for hours ... but Im at a loss !
I have imported an image int Mathematica -> dimensions 2x2cm at 72DPI.
I am trying to "label" the image with a text string that:
- has font color "fontColor"
- has a black outline, so it contrasts to any underlying color
- sits in the bottom right corner of the imported image
- has size h/w in cm
- optionally sits in a text box with a white background
This is how far ive come:
MathCode:
image = Import["myimg.jpg"];
inchFactor = 2.54;(* 1 inch = 2.54cm *)
docRes = 72;
pixelConverter = docRes/inchFactor/2;
myText = First[
First[ImportString[
ExportString[
Style["glorious label string here", Bold, FontSize -> 15,
FontFamily -> "Verdana"], "PDF"], "PDF",
"TextMode" -> "Outlines"]]];
myTextGraphic =
Graphics[{EdgeForm[Directive[Black, Thickness[0.01]]], White,
myText}, Background -> White,
ImageSize -> {10*pixelConverter, 2*pixelConverter}];
myTextGraphic = Rasterize[myTextGraphic];
combined = SetAlphaChannel[myTextGraphic, myTextGraphicAlphaVersion];
I found the above method (PDF wrapper) for the black outline of the text string.
I am adding an AlphaChannel to the graphic of the text string using a version of it that only uses black/white.
I then try to combine the images with Overlay.
As none of this seems to work concerning the outputted image size and positioning, Im kindly asking for help.
ThereĀ“s no need to "fix" that messy code.
Maybe you could point me to a script or tutorial - all I really want is to add and position a text string or text box to an underlying image.
Thanks a lot !
Have a look at this. There are other ways too.
img = Import["http://todayinsci.com/H/Hilbert_David/HilbertDavidThm.jpg"];
Column[{
img,
Text[Style["Professor Hilbert", Red]]
}]
imgCtr = Round[ImageDimensions[img]/2];
overlay = Framed[Graphics[{Text[Style["Professor Hilbert", Red, 9], imgCtr]},ImageSize-> {66, 14}], FrameStyle -> Green]
Overlay[{img, overlay}, Alignment -> Center]
It's late here so this is only the beginning of a solution for you but here's a simple way to add a text label to an image:
lbl = Graphics[Text[Style["Bottom", Red, Large]]]
which creates an image with the text 'Bottom' in red in a large font. Next, given an image called img1
ImageCompose[img1,lbl]
puts the text in the centre of the image. ImageCompose has options to allow you to position the second image (ie the label) wrt the first image. You can put the label on a coloured background like this:
lbl = Graphics[Text[Style["Bottom", Red, Large, Background -> Blue]]]
I haven't figured out, yet, how to write the text with a coloured outline.
So, tired of always seeing the bright orange default regular polygons, I'm trying to learn to style OpenLayers.
I've had some success with:
var layer_style = OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);
layer_style.fillColor = "#000000";
layer_style.strokeColor = "#000000";
polygonLayer = new OpenLayers.Layer.Vector("PolygonLayer");
polygonLayer.style = layer_style;
But sine I am drawing my polygons with DrawFeature, my style only takes effect once I've finished drawing, and seeing it snap from bright orange to grey is sort of disconcerting. So, I learned about temporary styles, and tried:
var layer_style = new OpenLayers.Style({"default": {fillColor: "#000000"}, "temporary": {fillColor: "#000000"}})
polygonLayer = new OpenLayers.Layer.Vector("PolygonLayer");
polygonLayer.style = layer_style;
This got me a still orange square--until I stopped drawing, when it snapped into completely opaque black. I figured maybe I had to explicitly set the fillOpacity...no dice. Even when I changed both fill colors to be pink and blue, respectively, I still saw only orange and opaque black.
I've tried messing with StyleMaps, since I read that if you only add one style to a style map, it uses the default one for everything, including the temporary style.
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
var style_map = new OpenLayers.StyleMap(layer_style);
polygonLayer = new OpenLayers.Layer.Vector("PolygonLayer");
polygonLayer.style = style_map;
That got me the black opaque square, too. (Even though that layer style works when not given to a map). Passing the map to the layer itself like so:
polygonLayer = new OpenLayers.Layer.Vector("PolygonLayer", style_map);
Didn't get me anything at all. Orange all the way, even after drawn.
polygonLayer = new OpenLayers.Layer.Vector("PolygonLayer", {styleMap: style_map});
Is a lot more succesful: Orange while drawing, translucent black with black outline when drawn. Just like when I didn't use a map. Problem is, still no temporary...
So, I tried initializing my map this way:
var style_map = new OpenLayers.StyleMap({"default": layer_style, "temporary": layer_style});
No opaque square, but no dice for the temporary, either... Still orange snapping to black transparent. Even if I make a new Style (layer_style2), and set temporary to that, still no luck. And no luck with setting "select" style, either.
What am I doing wrong? Temporary IS for styling things that are currently being sketched, correct? Is there some other way specific to the drawFeature Controller?
Edit: setting extendDefault to be true doesn't seem to help, either...
var style_map = new OpenLayers.StyleMap({"default": layer_style, "temporary": layer_style}, {"extendDefault": "true"});
I've found two solutions for this problem. In both solution, you have to change some parameters of DrawFeature to get the functionality you wish.
1.Change handler style of the DrawFeature. Function drawFeature in OpenLayers.Handler.Polygon uses parameter style of the handler for the feature. So you have to change this style.
When creating Feature use:
var drawPolygon = new OpenLayers.Control.DrawFeature(polygonLayer, OpenLayers.Handler.Polygon, {handlerOptions:{style:myStyle}});
Later, you can change it by:
drawPolygon.handler.style = myStyle;
2.Change create callback of the DrawFeature. Change style of the newly created temporary feature in create callback.
var drawPolygon = new OpenLayers.Control.DrawFeature(polygonLayer, OpenLayers.Handler.Polygon, {
callbacks:{create: function(vertex, feature) {
feature.style = myStyle;
this.layer.events.triggerEvent("sketchstarted", {vertex:vertex,feature:feature})
}}});
Similarly, you can change the callback later.
If you want all vectors to be of a constant style, but not the boring orange then try this:
vecLayer = new OpenLayers.Layer.Vector(
"Route Layer", //layer name
{styleMap: new OpenLayers.StyleMap({
pointRadius: "6",
fillColor: "#666666"
}),
renderers:renderer}
);
You have loads of properties you can mess about with, have a look at these pages:
dev.openlayers (check the Constants section)
docs.openlayers (more useful info)