DxGetBlendMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("myBlendMode", function()
-- Function to draw a rectangle with the current blend mode displayed
     outputChatBox( dxGetBlendMode() )
function renderBlendModeExample()
end)
    -- Get the current blend mode
    local blendMode = dxGetBlendMode()
   
    -- Draw a background rectangle
    dxDrawRectangle(100, 100, 300, 200, tocolor(0, 0, 255, 100))
 
    -- Draw some text on top of the rectangle
     dxDrawText("Current Blend Mode: " .. blendMode, 110, 110, 390, 190, tocolor(255, 255, 255, 255), 1.5, "default-bold")
end
 
-- Add an event handler to render the rectangle and text every frame
addEventHandler("onClientRender", root, renderBlendModeExample)
</syntaxhighlight>
</syntaxhighlight>



Revision as of 14:14, 29 August 2024

Accessories-text-editor.png Script Example Missing Function DxGetBlendMode needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.


This function returns the current blend mode for the dxDraw functions. The blend mode is set using dxSetBlendMode

Syntax

string dxGetBlendMode ( )

Returns

Returns the current blend mode, which can be one of:

  • blend
  • add
  • modulate_add
  • overwrite

Example

-- Function to draw a rectangle with the current blend mode displayed
function renderBlendModeExample()
    -- Get the current blend mode
    local blendMode = dxGetBlendMode()
    
    -- Draw a background rectangle
    dxDrawRectangle(100, 100, 300, 200, tocolor(0, 0, 255, 100))

    -- Draw some text on top of the rectangle
    dxDrawText("Current Blend Mode: " .. blendMode, 110, 110, 390, 190, tocolor(255, 255, 255, 255), 1.5, "default-bold")
end

-- Add an event handler to render the rectangle and text every frame
addEventHandler("onClientRender", root, renderBlendModeExample)

Requirements

This template will be deleted.

See Also