ruby-libgd 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b6cf8d1607c8305b9baba3d94a36342d57543c5efb89bcac12a3887ea8a589d
4
- data.tar.gz: 59620a7dbd30ec7c875c0ea69839170e7d76505dc7a8283514e83b7203e2e495
3
+ metadata.gz: 4654b62899e8c7bc35cded648fdc90b550121c5b0652ec7a53ccf7548afac59b
4
+ data.tar.gz: c3bb9bdb80cde240e99fef79a554e5a5765e64171ee9934f3e48e93798dc85df
5
5
  SHA512:
6
- metadata.gz: 50e8dac738245acb26f3b4e95d35d2a2f79f319e15dbd056fd4dc0492b12d6ae29b0393407d4e01bc62a447ac5ed19501a8660ec3b16721a37d026fd6b08a63f
7
- data.tar.gz: 3c3d1ef951a980be572ea48c5ec02804f40510421e03599ad3297836fc35927f4ede3c19392129b2d18b2c5208e61b9de33766977672357ac742fc3af31c150a
6
+ metadata.gz: 94789cb7afd59af7207cc9884a18d3fa38e031ad9a8b0e6ba989a15ffc760eb9331a08402a21ad0106ddf643bd2a0e33a1ae9b4e430fdc457243b4836e8e4234
7
+ data.tar.gz: 671827da51d580b188e3d0344ee2e1218a09e11c37ab879d2f70d56a12d45483cd85813ec69fdfd9985122d3a4836b71a4377b43dfd59e0ed19e0c5b21504c4b
data/ext/gd/Makefile ADDED
@@ -0,0 +1,269 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ V0 = $(V:0=)
7
+ Q1 = $(V:1=)
8
+ Q = $(Q1:0=@)
9
+ ECHO1 = $(V:1=@ :)
10
+ ECHO = $(ECHO1:0=@ echo)
11
+ NULLCMD = :
12
+
13
+ #### Start of system configuration section. ####
14
+
15
+ srcdir = .
16
+ topdir = /usr/local/include/ruby-3.3.0
17
+ hdrdir = $(topdir)
18
+ arch_hdrdir = /usr/local/include/ruby-3.3.0/x86_64-linux
19
+ PATH_SEPARATOR = :
20
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
21
+ prefix = $(DESTDIR)/usr/local
22
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
23
+ rubyarchprefix = $(rubylibprefix)/$(arch)
24
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
25
+ exec_prefix = $(prefix)
26
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
27
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
28
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
29
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
30
+ sitehdrdir = $(rubyhdrdir)/site_ruby
31
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
32
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
33
+ vendorlibdir = $(vendordir)/$(ruby_version)
34
+ vendordir = $(rubylibprefix)/vendor_ruby
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ sitelibdir = $(sitedir)/$(ruby_version)
37
+ sitedir = $(rubylibprefix)/site_ruby
38
+ rubyarchdir = $(rubylibdir)/$(arch)
39
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
40
+ sitearchincludedir = $(includedir)/$(sitearch)
41
+ archincludedir = $(includedir)/$(arch)
42
+ sitearchlibdir = $(libdir)/$(sitearch)
43
+ archlibdir = $(libdir)/$(arch)
44
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
45
+ mandir = $(datarootdir)/man
46
+ localedir = $(datarootdir)/locale
47
+ libdir = $(exec_prefix)/lib
48
+ psdir = $(docdir)
49
+ pdfdir = $(docdir)
50
+ dvidir = $(docdir)
51
+ htmldir = $(docdir)
52
+ infodir = $(datarootdir)/info
53
+ docdir = $(datarootdir)/doc/$(PACKAGE)
54
+ oldincludedir = $(DESTDIR)/usr/include
55
+ includedir = $(prefix)/include
56
+ runstatedir = $(localstatedir)/run
57
+ localstatedir = $(prefix)/var
58
+ sharedstatedir = $(prefix)/com
59
+ sysconfdir = $(prefix)/etc
60
+ datadir = $(datarootdir)
61
+ datarootdir = $(prefix)/share
62
+ libexecdir = $(exec_prefix)/libexec
63
+ sbindir = $(exec_prefix)/sbin
64
+ bindir = $(exec_prefix)/bin
65
+ archdir = $(rubyarchdir)
66
+
67
+
68
+ CC_WRAPPER =
69
+ CC = gcc
70
+ CXX = g++
71
+ LIBRUBY = $(LIBRUBY_SO)
72
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
73
+ LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
74
+ LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static $(MAINLIBS)
75
+ empty =
76
+ OUTFLAG = -o $(empty)
77
+ COUTFLAG = -o $(empty)
78
+ CSRCFLAG = $(empty)
79
+
80
+ RUBY_EXTCONF_H =
81
+ cflags = $(optflags) $(debugflags) $(warnflags)
82
+ cxxflags =
83
+ optflags = -O3 -fno-fast-math
84
+ debugflags = -ggdb3
85
+ warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wmisleading-indentation -Wundef
86
+ cppflags =
87
+ CCDLFLAGS = -fPIC
88
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
89
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
90
+ DEFS =
91
+ CPPFLAGS = $(DEFS) $(cppflags)
92
+ CXXFLAGS = $(CCDLFLAGS) $(ARCH_FLAG)
93
+ ldflags = -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed
94
+ dldflags = -Wl,--compress-debug-sections=zlib
95
+ ARCH_FLAG =
96
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
97
+ LDSHARED = $(CC) -shared
98
+ LDSHAREDXX = $(CXX) -shared
99
+ AR = gcc-ar
100
+ EXEEXT =
101
+
102
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
103
+ RUBY_SO_NAME = ruby
104
+ RUBYW_INSTALL_NAME =
105
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
106
+ RUBYW_BASE_NAME = rubyw
107
+ RUBY_BASE_NAME = ruby
108
+
109
+ arch = x86_64-linux
110
+ sitearch = $(arch)
111
+ ruby_version = 3.3.0
112
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
113
+ RUBY = $(ruby)
114
+ BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
115
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
116
+
117
+ RM = rm -f
118
+ RM_RF = rm -fr
119
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
120
+ MAKEDIRS = /usr/bin/mkdir -p
121
+ INSTALL = /usr/bin/install -c
122
+ INSTALL_PROG = $(INSTALL) -m 0755
123
+ INSTALL_DATA = $(INSTALL) -m 644
124
+ COPY = cp
125
+ TOUCH = exit >
126
+
127
+ #### End of system configuration section. ####
128
+
129
+ preload =
130
+ libpath = . $(libdir)
131
+ LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir)
132
+ DEFFILE =
133
+
134
+ CLEANFILES = mkmf.log
135
+ DISTCLEANFILES =
136
+ DISTCLEANDIRS =
137
+
138
+ extout =
139
+ extout_prefix =
140
+ target_prefix = /gd
141
+ LOCAL_LIBS =
142
+ LIBS = $(LIBRUBYARG_SHARED) -lm -lgd -lm -lpthread -lc
143
+ ORIG_SRCS = arc.c blit.c char.c circle.c clip.c color.c draw_line.c ellipse.c encode.c fill.c filter.c gd.c image.c pixel.c polygon.c rectangle.c text.c transform.c version.c
144
+ SRCS = $(ORIG_SRCS)
145
+ OBJS = arc.o blit.o char.o circle.o clip.o color.o draw_line.o ellipse.o encode.o fill.o filter.o gd.o image.o pixel.o polygon.o rectangle.o text.o transform.o version.o
146
+ HDRS = $(srcdir)/clip.h $(srcdir)/ruby_gd.h
147
+ LOCAL_HDRS =
148
+ TARGET = gd
149
+ TARGET_NAME = gd
150
+ TARGET_ENTRY = Init_$(TARGET_NAME)
151
+ DLLIB = $(TARGET).so
152
+ EXTSTATIC =
153
+ STATIC_LIB =
154
+
155
+ TIMESTAMP_DIR = .
156
+ BINDIR = $(bindir)
157
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
158
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
159
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
160
+ HDRDIR = $(sitehdrdir)$(target_prefix)
161
+ ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
162
+ TARGET_SO_DIR =
163
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
164
+ CLEANLIBS = $(TARGET_SO) false
165
+ CLEANOBJS = $(OBJS) *.bak
166
+ TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.-.gd.time
167
+
168
+ all: $(DLLIB)
169
+ static: $(STATIC_LIB)
170
+ .PHONY: all install static install-so install-rb
171
+ .PHONY: clean clean-so clean-static clean-rb
172
+
173
+ clean-static::
174
+ clean-rb-default::
175
+ clean-rb::
176
+ clean-so::
177
+ clean: clean-so clean-static clean-rb-default clean-rb
178
+ -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
179
+
180
+ distclean-rb-default::
181
+ distclean-rb::
182
+ distclean-so::
183
+ distclean-static::
184
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
185
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
186
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
187
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
188
+
189
+ realclean: distclean
190
+ install: install-so install-rb
191
+
192
+ install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
193
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
194
+ clean-static::
195
+ -$(Q)$(RM) $(STATIC_LIB)
196
+ install-rb: pre-install-rb do-install-rb install-rb-default
197
+ install-rb-default: pre-install-rb-default do-install-rb-default
198
+ pre-install-rb: Makefile
199
+ pre-install-rb-default: Makefile
200
+ do-install-rb:
201
+ do-install-rb-default:
202
+ pre-install-rb-default:
203
+ @$(NULLCMD)
204
+ $(TARGET_SO_DIR_TIMESTAMP):
205
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
206
+ $(Q) $(TOUCH) $@
207
+
208
+ site-install: site-install-so site-install-rb
209
+ site-install-so: install-so
210
+ site-install-rb: install-rb
211
+
212
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
213
+
214
+ .cc.o:
215
+ $(ECHO) compiling $(<)
216
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
217
+
218
+ .cc.S:
219
+ $(ECHO) translating $(<)
220
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
221
+
222
+ .mm.o:
223
+ $(ECHO) compiling $(<)
224
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
225
+
226
+ .mm.S:
227
+ $(ECHO) translating $(<)
228
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
229
+
230
+ .cxx.o:
231
+ $(ECHO) compiling $(<)
232
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
233
+
234
+ .cxx.S:
235
+ $(ECHO) translating $(<)
236
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
237
+
238
+ .cpp.o:
239
+ $(ECHO) compiling $(<)
240
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
241
+
242
+ .cpp.S:
243
+ $(ECHO) translating $(<)
244
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
245
+
246
+ .c.o:
247
+ $(ECHO) compiling $(<)
248
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
249
+
250
+ .c.S:
251
+ $(ECHO) translating $(<)
252
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
253
+
254
+ .m.o:
255
+ $(ECHO) compiling $(<)
256
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
257
+
258
+ .m.S:
259
+ $(ECHO) translating $(<)
260
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
261
+
262
+ $(TARGET_SO): $(OBJS) Makefile
263
+ $(ECHO) linking shared-object gd/$(DLLIB)
264
+ -$(Q)$(RM) $(@)
265
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
266
+
267
+
268
+
269
+ $(OBJS): $(HDRS) $(ruby_headers)
data/ext/gd/arc.c CHANGED
@@ -1,52 +1,64 @@
1
1
  #include "ruby_gd.h"
2
2
 
3
- static VALUE gd_image_arc(VALUE self,
4
- VALUE vcx, VALUE vcy,
5
- VALUE vw, VALUE vh,
6
- VALUE vstart, VALUE vend,
7
- VALUE vcolor
8
- ) {
9
- gd_image_wrapper *wrap;
10
- TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
11
-
12
- int cx = NUM2INT(vcx);
13
- int cy = NUM2INT(vcy);
14
- int w = NUM2INT(vw);
15
- int h = NUM2INT(vh);
16
- int s = NUM2INT(vstart);
17
- int e = NUM2INT(vend);
18
-
19
- int c = color_to_gd(wrap->img, vcolor);
20
-
21
- gdImageArc(wrap->img, cx, cy, w, h, s, e, c);
22
-
23
- return self;
3
+ static VALUE
4
+ gd_image_arc(int argc, VALUE *argv, VALUE self)
5
+ {
6
+ VALUE vcx, vcy, vw, vh, vstart, vend, vcolor, opts;
7
+ VALUE thickness = Qnil;
8
+ opts = Qnil;
9
+
10
+ rb_scan_args(argc, argv, "7:", &vcx, &vcy, &vw, &vh, &vstart, &vend, &vcolor, &opts);
11
+
12
+ if (!NIL_P(opts)) {
13
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
14
+ }
15
+
16
+ gd_image_wrapper *wrap;
17
+ TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
18
+
19
+ int cx = NUM2INT(vcx);
20
+ int cy = NUM2INT(vcy);
21
+ int w = NUM2INT(vw);
22
+ int h = NUM2INT(vh);
23
+ int s = NUM2INT(vstart);
24
+ int e = NUM2INT(vend);
25
+ int c = color_to_gd(wrap->img, vcolor);
26
+
27
+ int t = NIL_P(thickness) ? 1 : NUM2INT(thickness);
28
+ int half = t / 2;
29
+
30
+ for (int i = -half; i <= half; i++) {
31
+ gdImageArc(wrap->img, cx + i, cy, w, h, s, e, c);
32
+ }
33
+
34
+ return self;
24
35
  }
25
36
 
26
- static VALUE gd_image_filled_arc(VALUE self,
27
- VALUE vcx, VALUE vcy,
28
- VALUE vw, VALUE vh,
29
- VALUE vstart, VALUE vend,
30
- VALUE vcolor
31
- ) {
32
- gd_image_wrapper *wrap;
33
- TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
37
+ static VALUE
38
+ gd_image_filled_arc(int argc, VALUE *argv, VALUE self)
39
+ {
40
+ VALUE vcx, vcy, vw, vh, vstart, vend, vcolor;
41
+ rb_scan_args(argc, argv, "7", &vcx, &vcy, &vw, &vh, &vstart, &vend, &vcolor);
34
42
 
35
- int cx = NUM2INT(vcx);
36
- int cy = NUM2INT(vcy);
37
- int w = NUM2INT(vw);
38
- int h = NUM2INT(vh);
39
- int s = NUM2INT(vstart);
40
- int e = NUM2INT(vend);
43
+ gd_image_wrapper *wrap;
44
+ TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
41
45
 
42
- int c = color_to_gd(wrap->img, vcolor);
46
+ int cx = NUM2INT(vcx);
47
+ int cy = NUM2INT(vcy);
48
+ int w = NUM2INT(vw);
49
+ int h = NUM2INT(vh);
50
+ int s = NUM2INT(vstart);
51
+ int e = NUM2INT(vend);
52
+ int c = color_to_gd(wrap->img, vcolor);
43
53
 
44
- gdImageFilledArc(wrap->img, cx, cy, w, h, s, e, c, gdArc);
54
+ gdImageFilledArc(wrap->img, cx, cy, w, h, s, e, c, gdArc);
45
55
 
46
- return self;
56
+ return self;
47
57
  }
48
58
 
49
- void gd_define_arc(VALUE cGDImage) {
50
- rb_define_method(cGDImage, "arc", gd_image_arc, 7);
51
- rb_define_method(cGDImage, "filled_arc", gd_image_filled_arc, 7);
59
+ void
60
+ gd_define_arc(VALUE cGDImage)
61
+ {
62
+ rb_define_method(cGDImage, "arc", gd_image_arc, -1);
63
+ rb_define_method(cGDImage, "filled_arc", gd_image_filled_arc, -1);
52
64
  }
data/ext/gd/arc.o ADDED
Binary file
data/ext/gd/blit.o ADDED
Binary file
data/ext/gd/char.o ADDED
Binary file
data/ext/gd/circle.c CHANGED
@@ -1,33 +1,82 @@
1
1
  #include "ruby_gd.h"
2
2
 
3
- static VALUE gd_image_circle(VALUE self, VALUE cx, VALUE cy, VALUE r, VALUE color) {
3
+ static VALUE gd_image_circle(int argc, VALUE *argv, VALUE self)
4
+ {
5
+ VALUE vcx, vcy, vradius, vcolor, opts;
6
+ VALUE thickness = Qnil;
7
+ opts = Qnil;
8
+
9
+ rb_scan_args(argc, argv, "4:", &vcx, &vcy, &vradius, &vcolor, &opts);
10
+
11
+ if (!NIL_P(opts)) {
12
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
13
+ }
14
+
4
15
  gd_image_wrapper *wrap;
5
16
  TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
6
17
 
7
- int c = color_to_gd(wrap->img, color);
18
+ int cx = NUM2INT(vcx);
19
+ int cy = NUM2INT(vcy);
20
+ int r = NUM2INT(vradius);
21
+ int c = color_to_gd(wrap->img, vcolor);
8
22
 
9
- gdImageArc(wrap->img,
10
- NUM2INT(cx), NUM2INT(cy),
11
- NUM2INT(r)*2, NUM2INT(r)*2,
12
- 0, 360,
13
- c);
14
- return Qnil;
23
+ int t = NIL_P(thickness) ? 1 : NUM2INT(thickness);
24
+ int half = t / 2;
25
+
26
+ for (int i = -half; i <= half; i++) {
27
+ gdImageArc(wrap->img,
28
+ cx, cy,
29
+ (r + i) * 2, (r + i) * 2,
30
+ 0, 360,
31
+ c);
32
+ }
33
+
34
+ return self;
15
35
  }
16
36
 
17
- static VALUE gd_image_filled_circle(VALUE self, VALUE cx, VALUE cy, VALUE r, VALUE color) {
37
+ static VALUE gd_image_filled_circle(int argc, VALUE *argv, VALUE self)
38
+ {
39
+ VALUE vcx, vcy, vradius, vcolor, opts;
40
+ VALUE thickness = Qnil;
41
+ opts = Qnil;
42
+
43
+ rb_scan_args(argc, argv, "4:", &vcx, &vcy, &vradius, &vcolor, &opts);
44
+
45
+ if (!NIL_P(opts)) {
46
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
47
+ }
48
+
18
49
  gd_image_wrapper *wrap;
19
50
  TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
20
51
 
21
- int c = color_to_gd(wrap->img, color);
52
+ int cx = NUM2INT(vcx);
53
+ int cy = NUM2INT(vcy);
54
+ int r = NUM2INT(vradius);
55
+ int c = color_to_gd(wrap->img, vcolor);
22
56
 
57
+ /* Fill */
23
58
  gdImageFilledEllipse(wrap->img,
24
- NUM2INT(cx), NUM2INT(cy),
25
- NUM2INT(r)*2, NUM2INT(r)*2,
59
+ cx, cy,
60
+ r * 2, r * 2,
26
61
  c);
27
- return Qnil;
62
+
63
+ /* Stroke */
64
+ int t = NIL_P(thickness) ? 1 : NUM2INT(thickness);
65
+ int half = t / 2;
66
+
67
+ for (int i = -half; i <= half; i++) {
68
+ gdImageArc(wrap->img,
69
+ cx, cy,
70
+ (r + i) * 2, (r + i) * 2,
71
+ 0, 360,
72
+ c);
73
+ }
74
+
75
+ return self;
28
76
  }
29
77
 
30
- void gd_define_circle(VALUE cGDImage) {
31
- rb_define_method(cGDImage, "circle", gd_image_circle, 4);
32
- rb_define_method(cGDImage, "filled_circle", gd_image_filled_circle, 4);
78
+ void gd_define_circle(VALUE cGDImage)
79
+ {
80
+ rb_define_method(cGDImage, "circle", gd_image_circle, -1);
81
+ rb_define_method(cGDImage, "filled_circle", gd_image_filled_circle, -1);
33
82
  }
data/ext/gd/circle.o ADDED
Binary file
data/ext/gd/clip.o ADDED
Binary file
data/ext/gd/color.o ADDED
Binary file
data/ext/gd/draw_line.c CHANGED
@@ -2,7 +2,17 @@
2
2
  #include "ruby_gd.h"
3
3
  #include "clip.h"
4
4
 
5
- static VALUE gd_image_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) {
5
+ static VALUE gd_image_line(int argc, VALUE *argv, VALUE self) {
6
+ VALUE x1, y1, x2, y2, color, opts;
7
+ opts = Qnil;
8
+
9
+ rb_scan_args(argc, argv, "5:", &x1, &y1, &x2, &y2, &color, &opts);
10
+
11
+ VALUE thickness = Qnil;
12
+ if (!NIL_P(opts)) {
13
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
14
+ }
15
+
6
16
  gd_image_wrapper *wrap;
7
17
  TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
8
18
 
@@ -39,11 +49,17 @@ static VALUE gd_image_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, V
39
49
  }
40
50
 
41
51
  int c = color_to_gd(wrap->img, color);
52
+ int old = 1;
53
+
54
+ if (!NIL_P(thickness)) {
55
+ gdImageSetThickness(wrap->img, NUM2INT(thickness));
56
+ }
42
57
  gdImageLine(wrap->img, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), c);
58
+ gdImageSetThickness(wrap->img, old);
43
59
 
44
60
  return Qnil;
45
61
  }
46
62
 
47
63
  void gd_define_line(VALUE cGDImage) {
48
- rb_define_method(cGDImage, "line", gd_image_line, 5);
64
+ rb_define_method(cGDImage, "line", gd_image_line, -1);
49
65
  }
Binary file
data/ext/gd/ellipse.c CHANGED
@@ -2,3 +2,83 @@
2
2
  - [ ] imageellipse — Draw an ellipse
3
3
  - [ ] imagefilledellipse — Draw a filled ellipse
4
4
  */
5
+ #include "ruby_gd.h"
6
+
7
+ static VALUE gd_image_ellipse(int argc, VALUE *argv, VALUE self)
8
+ {
9
+ VALUE vcx, vcy, vw, vh, vcolor, opts;
10
+ VALUE thickness = Qnil;
11
+ opts = Qnil;
12
+
13
+ rb_scan_args(argc, argv, "5:", &vcx, &vcy, &vw, &vh, &vcolor, &opts);
14
+
15
+ if (!NIL_P(opts)) {
16
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
17
+ }
18
+
19
+ gd_image_wrapper *wrap;
20
+ TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
21
+
22
+ int cx = NUM2INT(vcx);
23
+ int cy = NUM2INT(vcy);
24
+ int w = NUM2INT(vw);
25
+ int h = NUM2INT(vh);
26
+ int c = color_to_gd(wrap->img, vcolor);
27
+
28
+ int t = NIL_P(thickness) ? 1 : NUM2INT(thickness);
29
+ int half = t / 2;
30
+
31
+ for (int i = -half; i <= half; i++) {
32
+ gdImageArc(wrap->img,
33
+ cx, cy,
34
+ w + i * 2, h + i * 2,
35
+ 0, 360,
36
+ c);
37
+ }
38
+
39
+ return self;
40
+ }
41
+
42
+ static VALUE gd_image_filled_ellipse(int argc, VALUE *argv, VALUE self)
43
+ {
44
+ VALUE vcx, vcy, vw, vh, vcolor, opts;
45
+ VALUE thickness = Qnil;
46
+ opts = Qnil;
47
+
48
+ rb_scan_args(argc, argv, "5:", &vcx, &vcy, &vw, &vh, &vcolor, &opts);
49
+
50
+ if (!NIL_P(opts)) {
51
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
52
+ }
53
+
54
+ gd_image_wrapper *wrap;
55
+ TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
56
+
57
+ int cx = NUM2INT(vcx);
58
+ int cy = NUM2INT(vcy);
59
+ int w = NUM2INT(vw);
60
+ int h = NUM2INT(vh);
61
+ int c = color_to_gd(wrap->img, vcolor);
62
+
63
+ /* Fill */
64
+ gdImageFilledEllipse(wrap->img, cx, cy, w, h, c);
65
+
66
+ /* Stroke */
67
+ int t = NIL_P(thickness) ? 1 : NUM2INT(thickness);
68
+ int half = t / 2;
69
+
70
+ for (int i = -half; i <= half; i++) {
71
+ gdImageArc(wrap->img,
72
+ cx, cy,
73
+ w + i * 2, h + i * 2,
74
+ 0, 360,
75
+ c);
76
+ }
77
+
78
+ return self;
79
+ }
80
+
81
+ void gd_define_ellipse(VALUE cGDImage) {
82
+ rb_define_method(cGDImage, "ellipse", gd_image_ellipse, -1);
83
+ rb_define_method(cGDImage, "filled_ellipse", gd_image_filled_ellipse, -1);
84
+ }
data/ext/gd/ellipse.o ADDED
Binary file
data/ext/gd/encode.o ADDED
Binary file
data/ext/gd/fill.o ADDED
Binary file
data/ext/gd/filter.c CHANGED
@@ -1,6 +1,29 @@
1
1
  #include "ruby_gd.h"
2
2
  #include <string.h>
3
3
 
4
+ static void gd_image_apply_sepia(gdImagePtr img) {
5
+ int x, y;
6
+ for (y = 0; y < img->sy; y++) {
7
+ for (x = 0; x < img->sx; x++) {
8
+ int c = gdImageGetTrueColorPixel(img, x, y);
9
+
10
+ int r = gdTrueColorGetRed(c);
11
+ int g = gdTrueColorGetGreen(c);
12
+ int b = gdTrueColorGetBlue(c);
13
+
14
+ int tr = (int)(0.393*r + 0.769*g + 0.189*b);
15
+ int tg = (int)(0.349*r + 0.686*g + 0.168*b);
16
+ int tb = (int)(0.272*r + 0.534*g + 0.131*b);
17
+
18
+ if (tr > 255) tr = 255;
19
+ if (tg > 255) tg = 255;
20
+ if (tb > 255) tb = 255;
21
+
22
+ gdImageSetPixel(img, x, y, gdTrueColor(tr, tg, tb));
23
+ }
24
+ }
25
+ }
26
+
4
27
  static VALUE gd_image_filter(int argc, VALUE *argv, VALUE self) {
5
28
  VALUE type, arg1, arg2, arg3, arg4;
6
29
  rb_scan_args(argc, argv, "14", &type, &arg1, &arg2, &arg3, &arg4);
@@ -58,6 +81,9 @@ static VALUE gd_image_filter(int argc, VALUE *argv, VALUE self) {
58
81
  NUM2INT(arg2)
59
82
  );
60
83
  }
84
+ else if (strcmp(name, "sepia") == 0) {
85
+ gd_image_apply_sepia(wrap->img);
86
+ }
61
87
  else {
62
88
  rb_raise(rb_eArgError, "unknown filter");
63
89
  }
data/ext/gd/filter.o ADDED
Binary file
data/ext/gd/gd.c CHANGED
@@ -72,8 +72,9 @@ void Init_gd(void) {
72
72
  gd_define_pixel(cGDImage);
73
73
  gd_define_line(cGDImage);
74
74
  gd_define_arc(cGDImage);
75
- gd_define_rect(cGDImage);
75
+ gd_define_rectangle(cGDImage);
76
76
  gd_define_circle(cGDImage);
77
+ gd_define_ellipse(cGDImage);
77
78
  gd_define_polygon(cGDImage);
78
79
 
79
80
  gd_define_text(cGDImage);
data/ext/gd/gd.o ADDED
Binary file
data/ext/gd/gd.so CHANGED
Binary file
data/ext/gd/image.o ADDED
Binary file
data/ext/gd/pixel.o ADDED
Binary file
data/ext/gd/polygon.o ADDED
Binary file
data/ext/gd/rectangle.c CHANGED
@@ -3,31 +3,58 @@
3
3
  - [ ] imagerectangle — Draw a rectangle
4
4
  - [ ] imagefilledrectangle — Draw a filled rectangle
5
5
  */
6
- static VALUE gd_image_rect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) {
6
+ static VALUE gd_image_rectangle(int argc, VALUE *argv, VALUE self) {
7
+ VALUE x1, y1, x2, y2, color, opts;
8
+ VALUE thickness = Qnil;
9
+ opts = Qnil;
10
+
11
+ rb_scan_args(argc, argv, "5:", &x1, &y1, &x2, &y2, &color, &opts);
12
+ if (!NIL_P(opts)) {
13
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
14
+ }
15
+
7
16
  gd_image_wrapper *wrap;
8
17
  TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
9
18
 
10
19
  int c = color_to_gd(wrap->img, color);
20
+
21
+ if (!NIL_P(thickness)) {
22
+ gdImageSetThickness(wrap->img, NUM2INT(thickness));
23
+ }
11
24
  gdImageRectangle(wrap->img,
12
25
  NUM2INT(x1), NUM2INT(y1),
13
26
  NUM2INT(x2), NUM2INT(y2),
14
27
  c);
28
+ gdImageSetThickness(wrap->img, 1);
15
29
  return Qnil;
16
30
  }
17
31
 
18
- static VALUE gd_image_filled_rect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) {
32
+ static VALUE gd_image_filled_rectangle(int argc, VALUE *argv, VALUE self) {
33
+ VALUE x1, y1, x2, y2, color, opts;
34
+ VALUE thickness = Qnil;
35
+ opts = Qnil;
36
+
37
+ rb_scan_args(argc, argv, "5:", &x1, &y1, &x2, &y2, &color, &opts);
38
+ if (!NIL_P(opts)) {
39
+ thickness = rb_hash_aref(opts, ID2SYM(rb_intern("thickness")));
40
+ }
41
+
19
42
  gd_image_wrapper *wrap;
20
43
  TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
21
44
 
22
45
  int c = color_to_gd(wrap->img, color);
46
+ if (!NIL_P(thickness)) {
47
+ gdImageSetThickness(wrap->img, NUM2INT(thickness));
48
+ }
23
49
  gdImageFilledRectangle(wrap->img,
24
50
  NUM2INT(x1), NUM2INT(y1),
25
51
  NUM2INT(x2), NUM2INT(y2),
26
52
  c);
53
+ gdImageSetThickness(wrap->img, 1);
27
54
  return Qnil;
28
55
  }
29
56
 
30
- void gd_define_rect(VALUE cGDImage) {
31
- rb_define_method(cGDImage, "rect", gd_image_rect, 5);
32
- rb_define_method(cGDImage, "filled_rect", gd_image_filled_rect, 5);
57
+ void gd_define_rectangle(VALUE cGDImage) {
58
+ rb_define_method(cGDImage, "rectangle", gd_image_rectangle, -1);
59
+ rb_define_method(cGDImage, "filled_rectangle", gd_image_filled_rectangle, -1);
33
60
  }
Binary file
data/ext/gd/ruby_gd.h CHANGED
@@ -21,8 +21,9 @@ void gd_define_fill(VALUE cGDImage);
21
21
  void gd_define_pixel(VALUE cGDImage);
22
22
  void gd_define_line(VALUE cGDImage);
23
23
  void gd_define_arc(VALUE cGDImage);
24
- void gd_define_rect(VALUE cGDImage);
24
+ void gd_define_rectangle(VALUE cGDImage);
25
25
  void gd_define_circle(VALUE cGDImage);
26
+ void gd_define_ellipse(VALUE cGDImage);
26
27
  void gd_define_polygon(VALUE cGDImage);
27
28
 
28
29
  void gd_define_text(VALUE cGDImage);
data/ext/gd/text.o ADDED
Binary file
Binary file
data/ext/gd/version.o ADDED
Binary file
data/lib/gd.rb CHANGED
@@ -1,2 +1,16 @@
1
1
  require "gd/gd"
2
2
 
3
+ class GD::Image
4
+ DEFAULT_FONT = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
5
+ DEFAULT_FONT_SIZE = 12
6
+
7
+ def draw_string(x, y, text, color, size: DEFAULT_FONT_SIZE, font: DEFAULT_FONT)
8
+ self.text(text, {
9
+ x: x,
10
+ y: y,
11
+ size: size,
12
+ color: color,
13
+ font: font
14
+ })
15
+ end
16
+ end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-libgd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Germán Alberto Giménez Silva
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-01-06 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: High-performance native Ruby bindings to libgd for image generation,
13
14
  drawing, filters, alpha blending, and transformations.
@@ -19,35 +20,56 @@ extensions:
19
20
  extra_rdoc_files: []
20
21
  files:
21
22
  - README.md
23
+ - ext/gd/Makefile
22
24
  - ext/gd/arc.c
25
+ - ext/gd/arc.o
23
26
  - ext/gd/blit.c
27
+ - ext/gd/blit.o
24
28
  - ext/gd/char.c
29
+ - ext/gd/char.o
25
30
  - ext/gd/circle.c
31
+ - ext/gd/circle.o
26
32
  - ext/gd/clip.c
27
33
  - ext/gd/clip.h
34
+ - ext/gd/clip.o
28
35
  - ext/gd/color.c
36
+ - ext/gd/color.o
29
37
  - ext/gd/draw_line.c
38
+ - ext/gd/draw_line.o
30
39
  - ext/gd/ellipse.c
40
+ - ext/gd/ellipse.o
31
41
  - ext/gd/encode.c
42
+ - ext/gd/encode.o
32
43
  - ext/gd/extconf.rb
33
44
  - ext/gd/fill.c
45
+ - ext/gd/fill.o
34
46
  - ext/gd/filter.c
47
+ - ext/gd/filter.o
35
48
  - ext/gd/gd.c
49
+ - ext/gd/gd.o
36
50
  - ext/gd/gd.so
37
51
  - ext/gd/image.c
52
+ - ext/gd/image.o
38
53
  - ext/gd/mkmf.log
39
54
  - ext/gd/pixel.c
55
+ - ext/gd/pixel.o
40
56
  - ext/gd/polygon.c
57
+ - ext/gd/polygon.o
41
58
  - ext/gd/rectangle.c
59
+ - ext/gd/rectangle.o
42
60
  - ext/gd/ruby_gd.h
43
61
  - ext/gd/text.c
62
+ - ext/gd/text.o
44
63
  - ext/gd/transform.c
64
+ - ext/gd/transform.o
45
65
  - ext/gd/version.c
66
+ - ext/gd/version.o
46
67
  - lib/gd.rb
47
68
  homepage: https://github.com/ggerman/ruby-libgd
48
69
  licenses:
49
70
  - MIT
50
71
  metadata: {}
72
+ post_install_message:
51
73
  rdoc_options: []
52
74
  require_paths:
53
75
  - lib
@@ -63,7 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
85
  - !ruby/object:Gem::Version
64
86
  version: '0'
65
87
  requirements: []
66
- rubygems_version: 4.0.3
88
+ rubygems_version: 3.5.22
89
+ signing_key:
67
90
  specification_version: 4
68
91
  summary: Native Ruby bindings for libgd
69
92
  test_files: []