Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sanket Bhukan
purr-data
Commits
2feaa840
"README.md" did not exist on "abb047bae4d6a711e3ca7209a88a807941937891"
Commit
2feaa840
authored
8 years ago
by
Jonathan Wilkes
Browse files
Options
Downloads
Patches
Plain Diff
improve whitespace and indentation
parent
0cb861db
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
externals/moonlib/image.c
+28
-47
28 additions, 47 deletions
externals/moonlib/image.c
with
28 additions
and
47 deletions
externals/moonlib/image.c
+
28
−
47
View file @
2feaa840
...
@@ -32,12 +32,11 @@ const char *image_get_filename(t_image *x,char *file)
...
@@ -32,12 +32,11 @@ const char *image_get_filename(t_image *x,char *file)
static
char
fname
[
MAXPDSTRING
];
static
char
fname
[
MAXPDSTRING
];
char
*
bufptr
;
char
*
bufptr
;
int
fd
;
int
fd
;
fd
=
open_via_path
(
canvas_getdir
(
glist_getcanvas
(
x
->
x_glist
))
->
s_name
,
fd
=
open_via_path
(
canvas_getdir
(
glist_getcanvas
(
x
->
x_glist
))
->
s_name
,
file
,
""
,
fname
,
&
bufptr
,
MAXPDSTRING
,
1
);
file
,
""
,
fname
,
&
bufptr
,
MAXPDSTRING
,
1
);
if
(
fd
>
0
)
if
(
fd
>
0
)
{
{
fname
[
strlen
(
fname
)]
=
'/'
;
fname
[
strlen
(
fname
)]
=
'/'
;
close
(
fd
);
close
(
fd
);
return
fname
;
return
fname
;
}
}
...
@@ -54,7 +53,7 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
...
@@ -54,7 +53,7 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
x
->
x_type
=
1
;
x
->
x_type
=
1
;
pd_error
(
x
,
"[image]: no image found"
);
pd_error
(
x
,
"[image]: no image found"
);
}
}
if
(
x
->
x_type
)
if
(
x
->
x_type
)
{
{
sys_vgui
(
".x%lx.c create image %d %d -tags %xS
\n
"
,
sys_vgui
(
".x%lx.c create image %d %d -tags %xS
\n
"
,
glist_getcanvas
(
glist
),
glist_getcanvas
(
glist
),
...
@@ -70,8 +69,10 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
...
@@ -70,8 +69,10 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
sys_vgui
(
"image create photo img%x
\n
"
,
x
);
sys_vgui
(
"image create photo img%x
\n
"
,
x
);
x
->
x_localimage
=
1
;
x
->
x_localimage
=
1
;
}
}
if
(
fname
)
if
(
fname
)
{
sys_vgui
(
"::moonlib::image::configure .x%lx img%x {%s}
\n
"
,
x
,
x
,
fname
);
sys_vgui
(
"::moonlib::image::configure .x%lx img%x {%s}
\n
"
,
x
,
x
,
fname
);
}
sys_vgui
(
".x%lx.c create image %d %d -image img%x -tags %xS
\n
"
,
sys_vgui
(
".x%lx.c create image %d %d -image img%x -tags %xS
\n
"
,
glist_getcanvas
(
glist
),
glist_getcanvas
(
glist
),
text_xpix
(
&
x
->
x_obj
,
glist
),
text_ypix
(
&
x
->
x_obj
,
glist
),
x
,
x
);
text_xpix
(
&
x
->
x_obj
,
glist
),
text_ypix
(
&
x
->
x_obj
,
glist
),
x
,
x
);
...
@@ -82,12 +83,10 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
...
@@ -82,12 +83,10 @@ void image_drawme(t_image *x, t_glist *glist, int firsttime)
}
}
else
else
{
{
sys_vgui
(
".x%lx.c coords %xS \
sys_vgui
(
".x%lx.c coords %xS %d %d
\n
"
,
%d %d
\n
"
,
glist_getcanvas
(
glist
),
x
,
glist_getcanvas
(
glist
),
x
,
text_xpix
(
&
x
->
x_obj
,
glist
),
text_ypix
(
&
x
->
x_obj
,
glist
));
text_xpix
(
&
x
->
x_obj
,
glist
),
text_ypix
(
&
x
->
x_obj
,
glist
));
}
}
}
}
...
@@ -97,17 +96,14 @@ void image_erase(t_image *x,t_glist *glist)
...
@@ -97,17 +96,14 @@ void image_erase(t_image *x,t_glist *glist)
}
}
/* ------------------------ image widgetbehaviour -------------------------- */
/* ------------------------ image widgetbehaviour----------------------------- */
static
void
image_getrect
(
t_gobj
*
z
,
t_glist
*
glist
,
static
void
image_getrect
(
t_gobj
*
z
,
t_glist
*
glist
,
int
*
xp1
,
int
*
yp1
,
int
*
xp2
,
int
*
yp2
)
int
*
xp1
,
int
*
yp1
,
int
*
xp2
,
int
*
yp2
)
{
{
int
width
,
height
;
int
width
,
height
;
t_image
*
x
=
(
t_image
*
)
z
;
t_image
*
x
=
(
t_image
*
)
z
;
width
=
x
->
x_width
;
width
=
x
->
x_width
;
height
=
x
->
x_height
;
height
=
x
->
x_height
;
*
xp1
=
text_xpix
(
&
x
->
x_obj
,
glist
);
*
xp1
=
text_xpix
(
&
x
->
x_obj
,
glist
);
...
@@ -117,7 +113,7 @@ static void image_getrect(t_gobj *z, t_glist *glist,
...
@@ -117,7 +113,7 @@ static void image_getrect(t_gobj *z, t_glist *glist,
}
}
static
void
image_displace
(
t_gobj
*
z
,
t_glist
*
glist
,
static
void
image_displace
(
t_gobj
*
z
,
t_glist
*
glist
,
int
dx
,
int
dy
)
int
dx
,
int
dy
)
{
{
t_image
*
x
=
(
t_image
*
)
z
;
t_image
*
x
=
(
t_image
*
)
z
;
x
->
x_obj
.
te_xpix
+=
dx
;
x
->
x_obj
.
te_xpix
+=
dx
;
...
@@ -148,12 +144,8 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
...
@@ -148,12 +144,8 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
sys_vgui
(
".x%lx.c delete %xSEL
\n
"
,
sys_vgui
(
".x%lx.c delete %xSEL
\n
"
,
glist_getcanvas
(
glist
),
x
);
glist_getcanvas
(
glist
),
x
);
}
}
}
}
static
void
image_activate
(
t_gobj
*
z
,
t_glist
*
glist
,
int
state
)
static
void
image_activate
(
t_gobj
*
z
,
t_glist
*
glist
,
int
state
)
{
{
/* t_text *x = (t_text *)z;
/* t_text *x = (t_text *)z;
...
@@ -167,7 +159,6 @@ static void image_delete(t_gobj *z, t_glist *glist)
...
@@ -167,7 +159,6 @@ static void image_delete(t_gobj *z, t_glist *glist)
canvas_deletelinesfor
(
glist
,
x
);
canvas_deletelinesfor
(
glist
,
x
);
}
}
static
void
image_vis
(
t_gobj
*
z
,
t_glist
*
glist
,
int
vis
)
static
void
image_vis
(
t_gobj
*
z
,
t_glist
*
glist
,
int
vis
)
{
{
t_image
*
s
=
(
t_image
*
)
z
;
t_image
*
s
=
(
t_image
*
)
z
;
...
@@ -182,15 +173,18 @@ static void image_vis(t_gobj *z, t_glist *glist, int vis)
...
@@ -182,15 +173,18 @@ static void image_vis(t_gobj *z, t_glist *glist, int vis)
static
void
image_save
(
t_gobj
*
z
,
t_binbuf
*
b
)
static
void
image_save
(
t_gobj
*
z
,
t_binbuf
*
b
)
{
{
t_image
*
x
=
(
t_image
*
)
z
;
t_image
*
x
=
(
t_image
*
)
z
;
binbuf_addv
(
b
,
"ssiissi"
,
gensym
(
"#X"
),
gensym
(
"obj"
),
binbuf_addv
(
b
,
"ssiissi"
,
x
->
x_obj
.
te_xpix
,
x
->
x_obj
.
te_ypix
,
gensym
(
"#X"
),
gensym
(
"obj"
),
x
->
x_obj
.
te_xpix
,
x
->
x_obj
.
te_ypix
,
atom_getsymbol
(
binbuf_getvec
(
x
->
x_obj
.
te_binbuf
)),
atom_getsymbol
(
binbuf_getvec
(
x
->
x_obj
.
te_binbuf
)),
x
->
x_image
,
x
->
x_type
);
x
->
x_image
,
x
->
x_type
);
binbuf_addv
(
b
,
";"
);
binbuf_addv
(
b
,
";"
);
}
}
t_widgetbehavior
image_widgetbehavior
;
t_widgetbehavior
image_widgetbehavior
;
void
image_size
(
t_image
*
x
,
t_floatarg
w
,
t_floatarg
h
)
void
image_size
(
t_image
*
x
,
t_floatarg
w
,
t_floatarg
h
)
{
{
...
@@ -211,22 +205,21 @@ void image_open(t_gobj *z,t_symbol *file)
...
@@ -211,22 +205,21 @@ void image_open(t_gobj *z,t_symbol *file)
const
char
*
fname
;
const
char
*
fname
;
int
oldtype
=
x
->
x_type
;
int
oldtype
=
x
->
x_type
;
fname
=
image_get_filename
(
x
,
file
->
s_name
);
fname
=
image_get_filename
(
x
,
file
->
s_name
);
if
(
fname
)
if
(
fname
)
{
{
x
->
x_image
=
file
;
x
->
x_image
=
file
;
x
->
x_type
=
0
;
x
->
x_type
=
0
;
if
(
glist_isvisible
(
x
->
x_glist
))
if
(
glist_isvisible
(
x
->
x_glist
))
{
{
if
(
!
x
->
x_localimage
)
if
(
!
x
->
x_localimage
)
{
{
sys_vgui
(
"image create photo img%x
\n
"
,
x
);
sys_vgui
(
"image create photo img%x
\n
"
,
x
);
x
->
x_localimage
=
1
;
x
->
x_localimage
=
1
;
}
}
sys_vgui
(
"img%x blank
\n
"
,
x
);
sys_vgui
(
"img%x blank
\n
"
,
x
);
sys_vgui
(
"::moonlib::image::configure .x%lx img%x {%s}
\n
"
,
x
,
x
,
fname
);
sys_vgui
(
"::moonlib::image::configure .x%lx img%x {%s}
\n
"
,
x
,
x
,
fname
);
if
(
oldtype
)
sys_vgui
(
".x%lx.c itemconfigure %xS -image img%x
\n
"
,
if
(
oldtype
)
sys_vgui
(
".x%lx.c itemconfigure %xS -image img%x
\n
"
,
glist_getcanvas
(
x
->
x_glist
),
x
,
x
);
glist_getcanvas
(
x
->
x_glist
),
x
,
x
);
}
}
}
}
...
@@ -238,25 +231,21 @@ void image_load(t_gobj *z,t_symbol *image,t_symbol *file)
...
@@ -238,25 +231,21 @@ void image_load(t_gobj *z,t_symbol *image,t_symbol *file)
{
{
t_image
*
x
=
(
t_image
*
)
z
;
t_image
*
x
=
(
t_image
*
)
z
;
const
char
*
fname
;
const
char
*
fname
;
fname
=
image_get_filename
(
x
,
file
->
s_name
);
fname
=
image_get_filename
(
x
,
file
->
s_name
);
if
(
fname
)
if
(
fname
)
sys_vgui
(
"::moonlib::image::create_photo .x%lx %s {%s}
\n
"
,
x
,
image
->
s_name
,
fname
);
sys_vgui
(
"::moonlib::image::create_photo .x%lx %s {%s}
\n
"
,
x
,
image
->
s_name
,
fname
);
}
}
void
image_set
(
t_gobj
*
z
,
t_symbol
*
image
)
void
image_set
(
t_gobj
*
z
,
t_symbol
*
image
)
{
{
t_image
*
x
=
(
t_image
*
)
z
;
t_image
*
x
=
(
t_image
*
)
z
;
x
->
x_image
=
image
;
x
->
x_image
=
image
;
x
->
x_type
=
1
;
x
->
x_type
=
1
;
if
(
glist_isvisible
(
x
->
x_glist
))
if
(
glist_isvisible
(
x
->
x_glist
))
sys_vgui
(
".x%lx.c itemconfigure %xS -image %s
\n
"
,
sys_vgui
(
".x%lx.c itemconfigure %xS -image %s
\n
"
,
glist_getcanvas
(
x
->
x_glist
),
x
,
x
->
x_image
->
s_name
);
glist_getcanvas
(
x
->
x_glist
),
x
,
x
->
x_image
->
s_name
);
}
}
static
void
image_setwidget
(
void
)
static
void
image_setwidget
(
void
)
{
{
image_widgetbehavior
.
w_getrectfn
=
image_getrect
;
image_widgetbehavior
.
w_getrectfn
=
image_getrect
;
...
@@ -274,13 +263,11 @@ static void image_setwidget(void)
...
@@ -274,13 +263,11 @@ static void image_setwidget(void)
#endif
#endif
}
}
static
void
*
image_new
(
t_symbol
*
image
,
t_float
type
)
static
void
*
image_new
(
t_symbol
*
image
,
t_float
type
)
{
{
t_image
*
x
=
(
t_image
*
)
pd_new
(
image_class
);
t_image
*
x
=
(
t_image
*
)
pd_new
(
image_class
);
x
->
x_glist
=
(
t_glist
*
)
canvas_getcurrent
();
x
->
x_glist
=
(
t_glist
*
)
canvas_getcurrent
();
x
->
x_width
=
15
;
x
->
x_width
=
15
;
x
->
x_height
=
15
;
x
->
x_height
=
15
;
if
(
type
!=
0
)
if
(
type
!=
0
)
...
@@ -298,7 +285,6 @@ void image_setup(void)
...
@@ -298,7 +285,6 @@ void image_setup(void)
{
{
image_class
=
class_new
(
gensym
(
"image"
),
(
t_newmethod
)
image_new
,
0
,
image_class
=
class_new
(
gensym
(
"image"
),
(
t_newmethod
)
image_new
,
0
,
sizeof
(
t_image
),
0
,
A_DEFSYM
,
A_DEFFLOAT
,
0
);
sizeof
(
t_image
),
0
,
A_DEFSYM
,
A_DEFFLOAT
,
0
);
/*
/*
class_addmethod(image_class, (t_method)image_size, gensym("size"),
class_addmethod(image_class, (t_method)image_size, gensym("size"),
A_FLOAT, A_FLOAT, 0);
A_FLOAT, A_FLOAT, 0);
...
@@ -306,23 +292,18 @@ void image_setup(void)
...
@@ -306,23 +292,18 @@ void image_setup(void)
class_addmethod(image_class, (t_method)image_color, gensym("color"),
class_addmethod(image_class, (t_method)image_color, gensym("color"),
A_SYMBOL, 0);
A_SYMBOL, 0);
*/
*/
class_addmethod
(
image_class
,
(
t_method
)
image_open
,
gensym
(
"open"
),
class_addmethod
(
image_class
,
(
t_method
)
image_open
,
gensym
(
"open"
),
A_SYMBOL
,
0
);
A_SYMBOL
,
0
);
class_addmethod
(
image_class
,
(
t_method
)
image_set
,
gensym
(
"set"
),
class_addmethod
(
image_class
,
(
t_method
)
image_set
,
gensym
(
"set"
),
A_SYMBOL
,
0
);
A_SYMBOL
,
0
);
class_addmethod
(
image_class
,
(
t_method
)
image_load
,
gensym
(
"load"
),
class_addmethod
(
image_class
,
(
t_method
)
image_load
,
gensym
(
"load"
),
A_SYMBOL
,
A_SYMBOL
,
0
);
A_SYMBOL
,
A_SYMBOL
,
0
);
image_setwidget
();
image_setwidget
();
class_setwidget
(
image_class
,
&
image_widgetbehavior
);
class_setwidget
(
image_class
,
&
image_widgetbehavior
);
#if PD_MINOR_VERSION >= 37
#if PD_MINOR_VERSION >= 37
class_setsavefn
(
image_class
,
&
image_save
);
class_setsavefn
(
image_class
,
&
image_save
);
#endif
#endif
sys_vgui
(
"eval [read [open {%s/%s.tcl}]]
\n
"
,
sys_vgui
(
"eval [read [open {%s/%s.tcl}]]
\n
"
,
image_class
->
c_externdir
->
s_name
,
image_class
->
c_externdir
->
s_name
,
image_class
->
c_name
->
s_name
);
image_class
->
c_name
->
s_name
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment