Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to pdlua graphics #45

Merged
merged 10 commits into from
Jul 15, 2024
18 changes: 10 additions & 8 deletions pd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ function pd.Clock:destruct()
end

function pd.Clock:dispatch()
local m = self._target[self._method]
if type(m) == "function" then
return m(self._target)
else
self._target:error(
"no method for `" .. self._method ..
"' at clock of Lua object `" .. self._name .. "'"
)
if pd._objects[self._target] then
local m = self._target[self._method]
if type(m) == "function" then
return m(self._target)
else
self._target:error(
"no method for `" .. self._method ..
"' at clock of Lua object `" .. self._name .. "'"
)
end
end
end

Expand Down
8 changes: 6 additions & 2 deletions pdlua.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,32 @@

#include "m_pd.h"

#if !PLUGDATA
typedef enum {SCALE, TRANSLATE} transform_type;

typedef struct _gfx_transform
{
transform_type type;
float x, y;
} gfx_transform;
#endif

typedef struct _pdlua_gfx
{
// Size variables
int width, height;
void *object;

#if !PLUGDATA
char object_tag[128]; // Tcl/tk tag that is attached to all drawings
char order_tag[64]; // Tag for invisible line, used to preserve correct object ordering
char current_item_tag[64]; // Tcl/tk tag that is only attached to the current drawing in progress
gfx_transform* transforms;
int num_transforms;
char current_color[8]; // Keep track of current color

// Variables to keep track of mouse button state and drag position
int mouse_drag_x, mouse_drag_y, mouse_down;
int first_draw;

#else
void(*plugdata_draw_callback)(void*, t_symbol*, int, t_atom*); // Callback to perform drawing in plugdata
#endif
Expand Down
Loading
Loading