.. default-domain:: http .. highlight:: json Image ===== .. _http-UI.Image: .. rubric:: Image A picture, or a plain colored rectangle. Added to a :ref:`Canvas ` or a :ref:`Panel `. A ``Image`` object is passed and returned as its identifier, a number. A path that acts on an object takes it as ``(id)``. .. http:get:: /ui/image/(id)/rect-transform The rect transform for the UI object. :param id: The identifier of the :ref:`Image ` object. :resjson UI.RectTransform value: .. http:get:: /ui/image/(id)/layout-element How much space the UI object asks a layout for. .. note:: Only has an effect when the object is in a panel that has a layout. A canvas is not inside a layout and does not have one. :param id: The identifier of the :ref:`Image ` object. :resjson UI.LayoutElement value: .. http:get:: /ui/image/(id)/visible Whether the UI object is visible. .. note:: This is the object's own setting, which is what it was last set to. An object is only drawn when everything it is inside is visible as well, so an interface can be built with its parts visible, inside a panel that is not, and shown all at once by making that panel visible. :param id: The identifier of the :ref:`Image ` object. :resjson bool value: .. http:put:: /ui/image/(id)/visible Whether the UI object is visible. .. note:: This is the object's own setting, which is what it was last set to. An object is only drawn when everything it is inside is visible as well, so an interface can be built with its parts visible, inside a panel that is not, and shown all at once by making that panel visible. :param id: The identifier of the :ref:`Image ` object. :reqjson bool value: The new value. .. http:get:: /ui/image/(id)/content The picture to show, as the contents of a PNG or JPEG file. Set it to an empty array to show a plain rectangle instead. .. note:: Reading this returns what was last set, not what is on the screen, and returns an empty array if no picture has been set. A picture drawn with :http:post:`/ui/image/(id)/set-pixels` is not returned here either. :param id: The identifier of the :ref:`Image ` object. :resjson bytes value: .. http:put:: /ui/image/(id)/content The picture to show, as the contents of a PNG or JPEG file. Set it to an empty array to show a plain rectangle instead. .. note:: Reading this returns what was last set, not what is on the screen, and returns an empty array if no picture has been set. A picture drawn with :http:post:`/ui/image/(id)/set-pixels` is not returned here either. :param id: The identifier of the :ref:`Image ` object. :reqjson bytes value: The new value. .. http:post:: /ui/image/(id)/set-pixels Draw the picture from raw pixels rather than a file, so that a client can draw whatever it likes, a graph for instance, and redraw it as often as it likes. .. note:: Redrawing at an unchanged size draws into the picture already there, so a picture redrawn every update does not build a new one each time. :param id: The identifier of the :ref:`Image ` object. :reqjson bytes data: The pixels, 4 bytes per pixel: red, green, blue and alpha, each 0 to 255. Pixels run left to right and rows run top to bottom, the way image files store them, so the array must hold width times height times 4 bytes. :reqjson int32 width: How many pixels wide the picture is. :reqjson int32 height: How many pixels tall the picture is. .. http:post:: /ui/image/(id)/update-pixels Redraw part of a picture drawn with :http:post:`/ui/image/(id)/set-pixels`: a block of the given size, with its top left corner x pixels in from the left edge and y pixels down from the top. The rest of the picture is left as it is, so a change to a small part of a large picture, one new column of a scrolling graph for instance, only sends the part that changed. .. note:: The image must already be showing a picture drawn from raw pixels, which is what sets the size, and the block must fit inside it. A picture loaded from a file cannot be redrawn this way: the file contents a client reads back would no longer be what is on the screen. :param id: The identifier of the :ref:`Image ` object. :reqjson bytes data: The pixels of the block, laid out as for :http:post:`/ui/image/(id)/set-pixels`: 4 bytes per pixel, rows top to bottom, width times height times 4 bytes in all. :reqjson int32 x: How many pixels the block sits in from the left edge. :reqjson int32 y: How many pixels the block sits down from the top. :reqjson int32 width: How many pixels wide the block is. :reqjson int32 height: How many pixels tall the block is. .. http:get:: /ui/image/(id)/color The color the image is tinted with, or the color of the rectangle when no picture is set. :param id: The identifier of the :ref:`Image ` object. :resjson StdLib.ColorRGBA value: .. http:put:: /ui/image/(id)/color The color the image is tinted with, or the color of the rectangle when no picture is set. :param id: The identifier of the :ref:`Image ` object. :reqjson StdLib.ColorRGBA value: The new value. .. http:post:: /ui/image/(id)/remove Remove the UI object. :param id: The identifier of the :ref:`Image ` object.