Canvas Image: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (→‎Properties: http://flightgear.org/forums/viewtopic.php?f=71&t=20401#p186916)
Line 3: Line 3:


= Properties =
= Properties =
== z-index ==
in cases when the restriction bounds are not rectangles, then make a path that masks it and use the z-index property to order the clipped item below and unclipped items above (e.g. for the image of the PFD, there would be the virtual horizon with the lowest z-index, say 0, a black background above that, and all of the other instruments will be higher than the black). To use:
<pre>
canvasElement.set("z-index", 0);
</pre>


== file ==
== file ==

Revision as of 16:57, 15 October 2013


Properties

z-index

in cases when the restriction bounds are not rectangles, then make a path that masks it and use the z-index property to order the clipped item below and unclipped items above (e.g. for the image of the PFD, there would be the virtual horizon with the lowest z-index, say 0, a black background above that, and all of the other instruments will be higher than the black). To use:

canvasElement.set("z-index", 0);

file

# Use file inside default search paths
img.set("file", "gui/dialogs/images/exit.png");

# Show canvas with index 3
img.set("file", "canvas://by-index/texture[3]");

# Show canvas available as object
img.set("file", my_canvas.getPath());

x/y

size

fill

  • Format: <color> (#rrggbb, rbg(r,g,b), rgba(r,g,b,a) [r,g,b -> 0-255; a -> 0.0-1.0])
  • Default: #ffffff (white)

Image background color. Each pixel is modulated with the background color. If the image shall be displayed unchanged use white as background color.

# White with alpha of 0.5 (=half transparent)
img.set("fill", "rgba(255,255,255,0.5)");

# red completely opaque
img.set("fill", "#ff0000");

slice

  • Format: [<number>%?]{1,4} fill?
  • Default: (empty) (disabled)

Image slicing (or scale-9, 9-slice) is a technique for dividing an image into nine regions. While scaling such an image the four corner regions will be shown undistorted, whereas the other regions are scaled to fit into the remaining parts. See the CSS3 border-image-slice property for more information.

# Top/bottom offset 10%, left/right offset 5%, fill center
img.set("slice", "10% 5% fill");

# All offsets 8 pixels, only draw border and do not fill center
img.set("slice", "8");

# Disable slicing
img.set("slice", "");

outset

  • Format: [<number>%?]{1,4}
  • Default: (empty) (disabled)

Let the image extend outside its specified size. The areas extending outside the original dimensions are just drawn but not included in the bounding box, and therefore ignored for event handling and distance/margin calculations. This could be used, for example, to draw a shadow around an element which is ignored for handling events.

# Top outset 10%, left/right outset 5%, bottom outset 10 pixels
img.set("outset", "10% 5% 10");

# All offsets 8 pixels
img.set("outset", "8");

# Disable outset
img.set("outset", "");