xrvg 0.0.1 → 0.0.2
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.
- data/CHANGES +34 -0
- data/README +2 -2
- data/Rakefile +111 -29
- data/examples/bezierbasic.rb +7 -0
- data/examples/bezierbasicvector.rb +7 -0
- data/examples/foreach.rb +1 -1
- data/examples/geodash.rb +8 -0
- data/examples/geodash2.rb +8 -0
- data/examples/hellocrown.rb +1 -1
- data/examples/hellocrown2.rb +1 -1
- data/examples/hellocrownrecurse.rb +1 -1
- data/examples/multibezierbasic.rb +8 -0
- data/examples/randomdash.rb +8 -0
- data/examples/range_examples.rb +16 -0
- data/examples/range_examples2.rb +10 -0
- data/examples/sample.rb +4 -2
- data/examples/simpledash.rb +8 -0
- data/examples/uplets.rb +1 -1
- data/lib/bezier.rb +461 -0
- data/lib/bezierspline.rb +266 -0
- data/lib/color.rb +44 -5
- data/lib/geometry2D.rb +116 -90
- data/lib/interpolation.rb +4 -2
- data/lib/samplation.rb +16 -10
- data/lib/shape.rb +101 -53
- data/lib/style.rb +13 -12
- data/lib/utils.rb +4 -3
- data/lib/xrvg.rb +2 -3
- data/test/test_bezier.rb +151 -0
- data/test/test_geometry2D.rb +38 -25
- data/test/test_shape.rb +67 -0
- data/test/test_utils.rb +45 -0
- metadata +28 -14
- data/examples/helloworld.rb +0 -5
data/CHANGES
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= CHANGES
|
2
|
+
== => v 0.0.2
|
3
|
+
=== Content
|
4
|
+
==== New features
|
5
|
+
- bezier curve !!
|
6
|
+
==== Refactoring
|
7
|
+
- replace Vector extension (which was incoherent as some methods were specific 2D) by new 2D class V2D
|
8
|
+
- Color no longer inherits from Vector
|
9
|
+
- optimize bezier point computation
|
10
|
+
- optimize sampling by using result "containers" (must be consolidated)
|
11
|
+
- simplify Bezier builders, by defining new builders and removing previous builder versatility
|
12
|
+
- refactor Style to be less SVG-mapped
|
13
|
+
==== Bug fixing
|
14
|
+
- range examples correction, and added to unitary tests
|
15
|
+
- Range .complement correction
|
16
|
+
- Range split correction
|
17
|
+
=== TODO
|
18
|
+
- unitary tests to be completed (generate them from doc ?)
|
19
|
+
- Shape Line and Circle interfaces must be completed to fill Curve abstract interface.
|
20
|
+
- mabe bezier tutorial
|
21
|
+
|
22
|
+
|
23
|
+
== => 0.0.1
|
24
|
+
=== Content
|
25
|
+
- First delivery. Contains utilitary classes (utils, samplable, interpolation, attributable), render, color, style, shape.
|
26
|
+
- But no bezier yet.
|
27
|
+
- Rakefile nearly ready.
|
28
|
+
- Some unitary tests
|
29
|
+
=== TODO for 0.0.2
|
30
|
+
- unitary tests to be completed (generate them from doc ?)
|
31
|
+
- Shape Line and Circle interfaces must be completed to fill Curve abstract interface.
|
32
|
+
- add bezier services, and make bezier documentation (both rdoc and tutorials)
|
33
|
+
|
34
|
+
|
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= XRVG -- X Ruby Vector Graphics
|
2
2
|
|
3
|
-
Supporting XRVG version: 0.0.
|
3
|
+
Supporting XRVG version: 0.0.2
|
4
4
|
|
5
5
|
This package contains XRVG, a Ruby vector graphic programming library.
|
6
6
|
|
@@ -35,7 +35,7 @@ XRVG comes with a Rakefile. To launch XRVG tests, simply go into XRVG install di
|
|
35
35
|
|
36
36
|
=== Road Map
|
37
37
|
|
38
|
-
|
38
|
+
See CHANGES
|
39
39
|
|
40
40
|
== Simple Example
|
41
41
|
|
data/Rakefile
CHANGED
@@ -25,6 +25,7 @@ RUBYFORGE_USER = ENV["RUBYFORGE_USER"] || "jblondinet"
|
|
25
25
|
|
26
26
|
# Directory on RubyForge where your website's files should be uploaded.
|
27
27
|
WEBSITE_DIR = "www"
|
28
|
+
WEBSITE_DIR_IMAGES = "#{WEBSITE_DIR}/images"
|
28
29
|
|
29
30
|
# Output directory for the rdoc html files.
|
30
31
|
# If you don't have a custom homepage, and want to use the RDoc
|
@@ -45,13 +46,7 @@ $LOAD_PATH.concat(REQUIRE_PATHS)
|
|
45
46
|
# This library file defines the RAKEVERSION constant.
|
46
47
|
require "#{UNIX_NAME}"
|
47
48
|
PROJECT_VERSION = eval("\"#{XRVG_VERSION}\"") # e.g. "1.0.2"
|
48
|
-
#---
|
49
|
-
# Clobber object files and Makefiles generated by extconf.rb.
|
50
|
-
CLOBBER.include("#{EXT_DIR}/**/*.{so,dll,o}", "#{EXT_DIR}/**/Makefile")
|
51
|
-
# Clobber .config generated by setup.rb.
|
52
|
-
CLOBBER.include(".config")
|
53
49
|
|
54
|
-
CLEAN.include("test/**/*.svg", "examples/**/*.svg")
|
55
50
|
#---
|
56
51
|
# Options common to RDocTask AND Gem::Specification.
|
57
52
|
# The --main argument specifies which file appears on the index.html page
|
@@ -61,27 +56,33 @@ GENERAL_RDOC_OPTS = {
|
|
61
56
|
}
|
62
57
|
|
63
58
|
# Additional RDoc formatted files, besides the Ruby source files.
|
64
|
-
RDOC_FILES = FileList["README"]
|
59
|
+
RDOC_FILES = FileList["README", "CHANGES"]
|
65
60
|
# Remove the following line if you don't want to extract RDoc from
|
66
61
|
# the extension C sources.
|
67
62
|
# RDOC_FILES.include(EXT_SOURCES)
|
68
63
|
|
69
64
|
# Ruby library code.
|
70
65
|
LIB_DIR = "lib"
|
71
|
-
PRE_LIB_FILES = FileList["assertion.rb", "attributable.rb", "color.rb", "frame.rb", "geometry2D.rb", "interpolation.rb", "render.rb", "samplation.rb", "shape.rb", "style.rb", "trace.rb", "utils.rb", "xrvg.rb"]
|
66
|
+
PRE_LIB_FILES = FileList["assertion.rb", "attributable.rb", "color.rb", "frame.rb", "geometry2D.rb", "interpolation.rb", "render.rb", "samplation.rb", "shape.rb", "style.rb", "trace.rb", "utils.rb", "bezier.rb", "bezierspline.rb", "xrvg.rb"]
|
72
67
|
LIB_FILES = FileList["#{LIB_DIR}/*.rb"]
|
73
68
|
|
69
|
+
# Example code.
|
70
|
+
EXAMPLE_DIR = "examples"
|
71
|
+
EXAMPLE_FILES = FileList["#{EXAMPLE_DIR}/*.rb"]
|
72
|
+
|
74
73
|
# Filelist with Test::Unit test cases.
|
75
|
-
|
74
|
+
TEST_DIR = "test"
|
75
|
+
PRE_TEST_FILES = FileList["test_bezier.rb", "test_attributable.rb", "test_color.rb", "test_frame.rb", "test_geometry2D.rb", "test_render.rb", "test_style.rb", "test_utils.rb", "test_shape.rb"]
|
76
|
+
TEST_FILES = FileList["test/*.rb"]
|
76
77
|
|
77
78
|
# Executable scripts, all non-garbage files under bin/.
|
78
79
|
BIN_FILES = FileList["bin/*"]
|
79
80
|
|
80
81
|
# This filelist is used to create source packages.
|
81
82
|
# Include all Ruby and RDoc files.
|
82
|
-
DIST_FILES = FileList["
|
83
|
+
DIST_FILES = FileList["Rakefile", "LICENCE"]
|
83
84
|
DIST_FILES.include(LIB_FILES)
|
84
|
-
DIST_FILES.include(
|
85
|
+
DIST_FILES.include(EXAMPLE_FILES)
|
85
86
|
DIST_FILES.include(BIN_FILES)
|
86
87
|
# DIST_FILES.include("data/**/*", "test/data/**/*")
|
87
88
|
# DIST_FILES.include("#{WEBSITE_DIR}/**/*.{html,css}", "man/*.[0-9]")
|
@@ -97,11 +98,19 @@ DIST_FILES.exclude(/^(\.\/)?pkg(\/|$)/)
|
|
97
98
|
# Run the tests if rake is invoked without arguments.
|
98
99
|
task "default" => ["test"]
|
99
100
|
|
100
|
-
|
101
|
-
Rake::TestTask.new(test_task_name) do |t|
|
101
|
+
Rake::TestTask.new("run-tests") do |t|
|
102
102
|
t.test_files = TEST_FILES
|
103
103
|
t.libs = REQUIRE_PATHS
|
104
104
|
end
|
105
|
+
|
106
|
+
task "test" => ["lib"] do
|
107
|
+
remove_dir TEST_DIR
|
108
|
+
mkdir TEST_DIR
|
109
|
+
PRE_TEST_FILES.to_a.each {|fn| cp( fn, TEST_DIR ) }
|
110
|
+
Rake::Task["run-tests"].invoke
|
111
|
+
end
|
112
|
+
|
113
|
+
|
105
114
|
#---
|
106
115
|
# Set an environment variable with any configuration options you want to
|
107
116
|
# be passed through to "setup.rb config".
|
@@ -124,6 +133,16 @@ if HAVE_EXT
|
|
124
133
|
Rake::Task["run-tests"].invoke
|
125
134
|
end
|
126
135
|
end
|
136
|
+
|
137
|
+
#---
|
138
|
+
# Clobber object files and Makefiles generated by extconf.rb.
|
139
|
+
CLOBBER.include("#{EXT_DIR}/**/*.{so,dll,o}", "#{EXT_DIR}/**/Makefile")
|
140
|
+
# Clobber .config generated by setup.rb.
|
141
|
+
CLOBBER.include(".config")
|
142
|
+
CLOBBER.include("#{WEBSITE_DIR}/*.html", "#{WEBSITE_DIR}/images/*.png", "#{WEBSITE_DIR}/images", "#{WEBSITE_DIR}/example_list.rb")
|
143
|
+
|
144
|
+
CLEAN.include("test/**/*.svg", "#{WEBSITE_DIR}/*~", "#{WEBSITE_DIR}/example_list.rb", "#{EXAMPLE_DIR}/**/*.svg")
|
145
|
+
|
127
146
|
#---
|
128
147
|
# The "rdoc" task generates API documentation.
|
129
148
|
Rake::RDocTask.new("rdoc") do |t|
|
@@ -155,17 +174,35 @@ end
|
|
155
174
|
|
156
175
|
# Now we can generate the package-related tasks.
|
157
176
|
Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
|
158
|
-
|
159
|
-
|
177
|
+
pkg.need_zip = false
|
178
|
+
pkg.need_tar = false
|
160
179
|
end
|
180
|
+
|
161
181
|
#---
|
162
|
-
desc "Upload website to RubyForge
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
182
|
+
desc "Upload website to RubyForge with WinSCP"
|
183
|
+
task "upload-website" do
|
184
|
+
sh "winscp.exe /console /script=winscp_script.txt"
|
185
|
+
end
|
186
|
+
|
187
|
+
#---
|
188
|
+
desc "Regenerate website"
|
189
|
+
task "gen-website" do
|
190
|
+
Rake::Task["clobber"].invoke
|
191
|
+
Rake::Task["muse"].invoke
|
192
|
+
Rake::Task["examples"].invoke
|
193
|
+
Rake::Task["rdoc"].invoke
|
194
|
+
Rake::Task["finish"].invoke
|
195
|
+
end
|
196
|
+
|
197
|
+
#---
|
198
|
+
desc "Regenerate website and upload it to RubyForge"
|
199
|
+
task "publish-website" do
|
200
|
+
# rubyforge_path = "/var/www/gforge-projects/#{UNIX_NAME}/"
|
201
|
+
# sh "scp -r #{WEBSITE_DIR}/* " +
|
202
|
+
# "#{RUBYFORGE_USER}@rubyforge.org:#{rubyforge_path}",
|
203
|
+
# :verbose => true
|
204
|
+
Rake::Task["gen-website"].invoke
|
205
|
+
Rake::Task["upload-website"].invoke
|
169
206
|
end
|
170
207
|
#---
|
171
208
|
task "rubyforge-setup" do
|
@@ -175,7 +212,7 @@ task "rubyforge-setup" do
|
|
175
212
|
puts "to your RubyForge username and RubyForge password!"
|
176
213
|
puts "Press ENTER to continue."
|
177
214
|
$stdin.gets
|
178
|
-
sh "rubyforge setup", :verbose => true
|
215
|
+
sh "ruby rubyforge setup", :verbose => true
|
179
216
|
end
|
180
217
|
end
|
181
218
|
|
@@ -198,10 +235,11 @@ task "publish-packages" => ["package", "rubyforge-login"] do
|
|
198
235
|
"#{PROJECT_VERSION} #{UNIX_NAME}-#{PROJECT_VERSION}"
|
199
236
|
cd "pkg" do
|
200
237
|
sh(cmd + ".gem", :verbose => true)
|
201
|
-
|
202
|
-
|
238
|
+
# sh(cmd + ".tgz", :verbose => true)
|
239
|
+
# sh(cmd + ".zip", :verbose => true)
|
203
240
|
end
|
204
241
|
end
|
242
|
+
|
205
243
|
#---
|
206
244
|
# The "lib" task copy selected files in PRE_LIB_FILES into LIB_DIR directory
|
207
245
|
desc "Copy source files to create ./lib directory"
|
@@ -211,16 +249,62 @@ task "lib" do
|
|
211
249
|
PRE_LIB_FILES.to_a.each {|fn| cp( fn, LIB_DIR ) }
|
212
250
|
end
|
213
251
|
|
252
|
+
#---
|
253
|
+
# The "muse" task generates html documentation by using emacs
|
254
|
+
# It also generates a "example_list.txt" file, that must list every XRVG example used in the doc
|
255
|
+
# This list is used in "examples" task, to generate and copy example sources
|
256
|
+
desc "Copy example source files to create ./examples directory"
|
257
|
+
task "muse" do
|
258
|
+
sh "emacs -u \"\" g:/emacs/emacs/plans/xrvgwebsite.muse -l g:/emacs/emacs/perso/xrvg-publish-exe.el -kill", :verbose => true
|
259
|
+
end
|
260
|
+
|
261
|
+
#---
|
262
|
+
# The "finish" task removes some generated files
|
263
|
+
task "finish" do
|
264
|
+
FINISH_FILES = FileList["#{WEBSITE_DIR}/example_list.rb", "#{EXAMPLE_DIR}/**/*.svg" ]
|
265
|
+
FINISH_FILES.include( "#{WEBSITE_DIR}/*o" )
|
266
|
+
FINISH_FILES.each do |fn|
|
267
|
+
puts "try to remove #{fn}"
|
268
|
+
if File.exists? fn
|
269
|
+
rm_r fn
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
#---
|
275
|
+
# The "example" task copy selected example files into EXAMPLE_DIR directory
|
276
|
+
desc "Copy example source files to create ./examples directory"
|
277
|
+
task "examples" => ["muse"] do
|
278
|
+
remove_dir EXAMPLE_DIR
|
279
|
+
mkdir EXAMPLE_DIR
|
280
|
+
mkdir "#{WEBSITE_DIR}/images"
|
281
|
+
require 'www/example_list'
|
282
|
+
example_list.each do |fn|
|
283
|
+
source = fn
|
284
|
+
svg = String.new(fn)
|
285
|
+
svg["\.rb"] = ".svg"
|
286
|
+
png = String.new(fn)
|
287
|
+
png["\.rb"] = ".png"
|
288
|
+
cp( fn, EXAMPLE_DIR )
|
289
|
+
sh "ruby #{fn}"
|
290
|
+
if File.exist?(svg)
|
291
|
+
sh "ruby svg2png.rb #{svg} 2.0"
|
292
|
+
cp( png, WEBSITE_DIR_IMAGES )
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
214
297
|
#---
|
215
298
|
# The "prepare-release" task makes sure your tests run, and then generates
|
216
299
|
# files for a new release.
|
217
300
|
desc "Run tests, generate RDoc and create packages."
|
218
|
-
task "prepare-release"
|
301
|
+
task "prepare-release" do
|
219
302
|
puts "Preparing release of #{PROJECT} version #{VERSION}"
|
303
|
+
Rake::Task["clobber"].invoke
|
220
304
|
Rake::Task["lib"].invoke
|
221
305
|
Rake::Task["test"].invoke
|
222
|
-
Rake::Task["rdoc"].invoke
|
223
306
|
Rake::Task["package"].invoke
|
307
|
+
Rake::Task["gen-website"].invoke
|
224
308
|
end
|
225
309
|
|
226
310
|
# The "publish" task is the overarching task for the whole project. It
|
@@ -258,6 +342,4 @@ end
|
|
258
342
|
#---
|
259
343
|
|
260
344
|
# TODO
|
261
|
-
# - add task example checking
|
262
345
|
# - add effective upload with winscp
|
263
|
-
# - add xrvg tutorial documentation publishing (emacs process ?)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "bezierbasicvector.svg" ]
|
4
|
+
bezier = Bezier.vector( V2D[0.0, 1.0], V2D[1.0, 0.0], V2D[1.0, 0.0], V2D[-1.0, 0.0] )
|
5
|
+
render.add( bezier, Style[ :stroke, "blue", :strokewidth, 0.1 ] )
|
6
|
+
bezier.gdebug( render )
|
7
|
+
render.end
|
data/examples/foreach.rb
CHANGED
@@ -2,8 +2,8 @@ require 'xrvg'
|
|
2
2
|
|
3
3
|
render = SVGRender[ :filename, "foreach.svg", :background, "white" ]
|
4
4
|
Circle[].samples(10).foreach do |p1,p2|
|
5
|
+
render.add( Line[ :points, [p1,p2] ], Style[ :stroke, "black", :strokewidth, 0.1 ] )
|
5
6
|
render.add( Circle[:center, p1, :radius, 0.1], Style[ :fill, Color.red ] )
|
6
7
|
render.add( Circle[:center, p2, :radius, 0.2], Style[ :fill, Color.blue ] )
|
7
|
-
render.add( Line[ :exts, [p1,p2] ] )
|
8
8
|
end
|
9
9
|
render.end
|
data/examples/geodash.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "geodash.svg" ]
|
4
|
+
bezier = Bezier.raw( V2D[0.0, 1.0], V2D[1.0, 1.0], V2D[0.0, 0.0], V2D[1.0, 0.0] )
|
5
|
+
bezier.geo(2.0).splits( 30 ).foreach do |drawn,dum|
|
6
|
+
render.add( drawn, Style[ :stroke, "blue", :strokewidth, 0.1 ] )
|
7
|
+
end
|
8
|
+
render.end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "geodash2.svg" ]
|
4
|
+
bezier = Bezier.raw( V2D[0.0, 1.0], V2D[1.0, 1.0], V2D[0.0, 0.0], V2D[1.0, 0.0] )
|
5
|
+
[bezier.geo(2.0).splits( 30 ), (0.1..0.0).samples(30)].forzip do |drawn,width,dum,dum|
|
6
|
+
render.add( drawn, Style[ :stroke, "blue", :strokewidth, width ] )
|
7
|
+
end
|
8
|
+
render.end
|
data/examples/hellocrown.rb
CHANGED
@@ -2,6 +2,6 @@ require 'xrvg'
|
|
2
2
|
|
3
3
|
render = SVGRender[ :filename, "hellocrown.svg" ]
|
4
4
|
Circle[].samples( 8 ) do |point|
|
5
|
-
render.add( Circle[:center, point, :radius, 0.2 ], Style[ :fill, Color.
|
5
|
+
render.add( Circle[:center, point, :radius, 0.2 ], Style[ :fill, Color.blue ] )
|
6
6
|
end
|
7
7
|
render.end
|
data/examples/hellocrown2.rb
CHANGED
@@ -2,6 +2,6 @@ require 'xrvg'
|
|
2
2
|
|
3
3
|
render = SVGRender[ :filename, "hellocrown2.svg" ]
|
4
4
|
[Circle[], (0.2..0.1)].samples( 10 ) do |point, radius|
|
5
|
-
render.add( Circle[:center, point, :radius, radius ], Style[ :fill, Color.
|
5
|
+
render.add( Circle[:center, point, :radius, radius ], Style[ :fill, Color.blue( 0.5 ) ] )
|
6
6
|
end
|
7
7
|
render.end
|
@@ -3,7 +3,7 @@ require 'xrvg'
|
|
3
3
|
render = SVGRender[ :filename, "hellocrownrecurse.svg" ]
|
4
4
|
Circle[].samples( 8 ) do |point|
|
5
5
|
Circle[:center, point, :radius, 0.2 ].samples( 8 ) do |point|
|
6
|
-
render.add( Circle[:center, point, :radius, 0.05 ], Style[ :fill, Color.
|
6
|
+
render.add( Circle[:center, point, :radius, 0.05 ], Style[ :fill, Color.blue ] )
|
7
7
|
end
|
8
8
|
end
|
9
9
|
render.end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "multibezierbasic.svg" ]
|
4
|
+
bezier = Bezier.multi( [[:vector, V2D[0.0, 1.0], V2D[1.0, 0.0], V2D[1.0, 0.0], V2D[-1.0, 0.0]],
|
5
|
+
[:vector, V2D[1.0, 0.0], V2D[1.0, 0.0], V2D[2.0, 1.0], V2D[-1.0, 0.0]]] )
|
6
|
+
render.add( bezier, Style[ :stroke, "blue", :strokewidth, 0.1 ] )
|
7
|
+
bezier.gdebug( render )
|
8
|
+
render.end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "randomdash.svg" ]
|
4
|
+
bezier = Bezier.raw( V2D[0.0, 1.0], V2D[1.0, 1.0], V2D[0.0, 0.0], V2D[1.0, 0.0] )
|
5
|
+
[bezier.ssort.random.splits( 30 ), (0.1..0.0).rand(30)].forzip do |drawn,width,dum,dum|
|
6
|
+
render.add( drawn, Style[ :stroke, "blue", :strokewidth, width ] )
|
7
|
+
end
|
8
|
+
render.end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
# Samplable module
|
4
|
+
(1.0..2.0).sample(0.5); #=> 1.5
|
5
|
+
(1.0..2.0).samples( 3 ); #=> [1.0, 1.5, 2.0]
|
6
|
+
(1.0..2.0).mean; #=> 1.5; equiv to sample(0.5)
|
7
|
+
(1.0..2.0).middle; #=> alias for previous
|
8
|
+
(1.0..2.0).rand; #=> random value in range
|
9
|
+
(1.0..2.0).rand( 2 ); #=> [rand1, rand2] in range
|
10
|
+
(1.0..2.0).complement(1.2); #=> 1.8
|
11
|
+
(1.0..2.0).abscissa(1.2); #=> 0.2; inverse of sample
|
12
|
+
|
13
|
+
# Splittable module
|
14
|
+
(1.0..2.0).split(0.2,0.3); #=> (1.2..1.3)
|
15
|
+
(1.0..2.0).splits( 2 ); #=> [(1.0..1.5),(1.5..2.0)]
|
16
|
+
|
data/examples/sample.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'xrvg'
|
2
2
|
|
3
|
-
render = SVGRender[ :filename, "
|
3
|
+
render = SVGRender[ :filename, "sample.svg" ]
|
4
4
|
|
5
|
-
palette = Palette[ :colorlist, [ Color.
|
5
|
+
palette = Palette[ :colorlist, [ Color.blue, 0.0, Color.orange, 0.25,
|
6
|
+
Color.yellow, 0.5, Color.green, 0.75,
|
7
|
+
Color.blue, 1.0 ] ]
|
6
8
|
[Circle[], palette, (0.1..0.02).random()].samples(25) do |point, color, radius|
|
7
9
|
render.add( Circle[ :center, point, :radius, radius ], Style[ :fill, color ])
|
8
10
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'xrvg'
|
2
|
+
|
3
|
+
render = SVGRender[ :filename, "simpledash.svg" ]
|
4
|
+
bezier = Bezier.raw( V2D[0.0, 1.0], V2D[1.0, 1.0], V2D[0.0, 0.0], V2D[1.0, 0.0] )
|
5
|
+
bezier.splits( 30 ).foreach do |drawn,dummy|
|
6
|
+
render.add( drawn, Style[ :stroke, "blue", :strokewidth, 0.1 ] )
|
7
|
+
end
|
8
|
+
render.end
|
data/examples/uplets.rb
CHANGED
@@ -2,8 +2,8 @@ require 'xrvg'
|
|
2
2
|
|
3
3
|
render = SVGRender[ :filename, "uplets.svg", :background, "white" ]
|
4
4
|
Circle[].samples(10).uplets do |p1,p2|
|
5
|
+
render.add( Line[ :points, [p1,p2]], Style[ :stroke, "black", :strokewidth, 0.1 ] )
|
5
6
|
render.add( Circle[:center, p1, :radius, 0.1], Style[ :fill, Color.red ] )
|
6
7
|
render.add( Circle[:center, p2, :radius, 0.2], Style[ :fill, Color.blue ] )
|
7
|
-
render.add( Line[ :exts, [p1,p2] ] )
|
8
8
|
end
|
9
9
|
render.end
|