Garry's Mod Wiki

Garry's Mod Wiki

Description

DImage is an advanced, more robust version of the Material panel.

See DImageButton for a click-able version of this panel.

View source

Parent

Derives methods, etc not listed on this page from DPanel.

Methods

DImage:DoLoadMaterial()
This is used internally - although you're able to use it you probably shouldn't. Actually loads the IMaterial to render it. Called from DImage:LoadMaterial.
This is used internally - although you're able to use it you probably shouldn't. "Fixes" the current material of the DImage if it has VertexLit shader by creating a new one with the same name and a prefix of "_DImage" and automatically calling DImage:SetMaterial with the new material. This fixes the problem where using materials using shaders that expect lighting information causing "weird" flickering when displayed in 2D/Unlit environment.
This is used internally - although you're able to use it you probably shouldn't. Returns the texture path set by DImage:SetFailsafeMatName.
string DImage:GetImage()
Returns the image loaded in the image panel.
Returns the color override of the image panel.
Returns whether the DImage should keep the aspect ratio of its image when being resized. See DImage:SetKeepAspect for more info on how it works.
Returns the current Material of the DImage.
This is used internally - although you're able to use it you probably shouldn't. Returns the texture path set by DImage:SetMatName.
DImage:LoadMaterial()
This is used internally - although you're able to use it you probably shouldn't. Initializes the loading process of the material to render if it is not loaded yet. You do not need to call this function. It is done for you automatically.
DImage:PaintAt( number posX, number posY, number width, number height )
Paints a ghost copy of the DImage panel at the given position and dimensions. This function overrides Panel:PaintAt.
DImage:SetFailsafeMatName( string backupMat )
This is used internally - although you're able to use it you probably shouldn't. Sets the backup material to be loaded when the image is first rendered. Used by DImage:SetOnViewMaterial.
DImage:SetImage( string strImage, string strBackup = "nil" )
Sets the image to load into the frame. If the first image can't be loaded and strBackup is set, that image will be loaded instead. This eventually calls DImage:SetMaterial.
DImage:SetImageColor( table col )
Sets the image's color override.
DImage:SetKeepAspect( boolean keep )
Sets whether the DImage should keep the aspect ratio of its image when being resized. Note that this will not try to fit the image inside the button, but instead it will fill the button with the image.
DImage:SetMaterial( IMaterial mat )
Sets a Material directly as an image.
DImage:SetMatName( string mat )
This is used internally - although you're able to use it you probably shouldn't. Sets the material to be loaded when the image is first rendered. Used by DImage:SetOnViewMaterial.
DImage:SetOnViewMaterial( string mat, string backupMat )
Similar to DImage:SetImage, but will only do the expensive part of actually loading the textures/material if the material is about to be rendered/viewed. Useful for cases like DIconBrowser, where there are hundreds of small icons in 1 panel in a list that do not need all to be loaded at the same time.
boolean DImage:Unloaded()
Returns true if the image is not yet loaded.

Example

Creates a DImage of Dr. Breen inside a DFrame panel.

-- Frame Frame = vgui.Create("DFrame") Frame:SetSize(200, 200) Frame:Center() Frame:SetTitle("Image of Dr. Breen") -- Title of window Frame:MakePopup() -- Image panel of Dr. Breen local breen_img = vgui.Create("DImage", Frame) -- Add image to Frame breen_img:SetPos(10, 35) -- Move it into frame breen_img:SetSize(150, 150) -- Size it to 150x150 -- Set material relative to "garrysmod/materials/" breen_img:SetImage("scripted/breen_fakemonitor_1")

Example

Creates three DImage panels and arranges them into a new image.

-- Container panel BGPanel = vgui.Create("DPanel") BGPanel:SetSize(400, 400) BGPanel:Center() BGPanel:SetDrawBackground(false) -- Wood background local img_bg = vgui.Create("DImage", BGPanel) img_bg:SetSize(BGPanel:GetSize()) img_bg:SetImage("models/props_foliage/oak_tree01") -- Blurred out screenshot of Construct local img_construct = vgui.Create("DImage", BGPanel) img_construct:SetPos(10, 10) img_construct:SetSize(380, 380) img_construct:SetImage("hlmv/background") -- Flatgrass sign local img_text = vgui.Create("DImage", BGPanel) img_text:SetPos(10, 20) img_text:SetSize(380, 130) img_text:SetImage("gm_construct/flatsign")
Output:

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...