mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-13 01:13:22 +00:00
[lua] Change GraphicsContext.opacity to an integer value from 0..255
To match the opacity of Layer and Cel.
This commit is contained in:
parent
de307ba6b0
commit
f6df07ada6
@ -22,6 +22,8 @@
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
|
||||
namespace app {
|
||||
@ -416,15 +418,15 @@ int GraphicsContext_set_blendMode(lua_State* L)
|
||||
int GraphicsContext_get_opacity(lua_State* L)
|
||||
{
|
||||
auto gc = get_obj<GraphicsContext>(L, 1);
|
||||
lua_pushnumber(L, gc->opacity());
|
||||
lua_pushinteger(L, gc->opacity());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GraphicsContext_set_opacity(lua_State* L)
|
||||
{
|
||||
auto gc = get_obj<GraphicsContext>(L, 1);
|
||||
const float opacity = lua_tonumber(L, 2);
|
||||
gc->opacity(opacity);
|
||||
const int opacity = lua_tointeger(L, 2);
|
||||
gc->opacity(std::clamp(opacity, 0, 255));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,11 @@ public:
|
||||
void strokeWidth(float value) { m_paint.strokeWidth(value); }
|
||||
|
||||
#if LAF_SKIA
|
||||
float opacity() const { return m_paint.skPaint().getAlphaf(); }
|
||||
void opacity(float value) { m_paint.skPaint().setAlphaf(value); }
|
||||
int opacity() const { return m_paint.skPaint().getAlpha(); }
|
||||
void opacity(int value) { m_paint.skPaint().setAlpha(value); }
|
||||
#else
|
||||
float opacity() const { return 1.0f; }
|
||||
void opacity(float) { }
|
||||
int opacity() const { return 255; }
|
||||
void opacity(int) { }
|
||||
#endif
|
||||
|
||||
os::BlendMode blendMode() const { return m_paint.blendMode(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user