Skip to content

Commit

Permalink
Update to Julia 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Feb 2, 2018
1 parent d3ee1df commit 7837a28
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 354 deletions.
15 changes: 10 additions & 5 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using BinDeps

using Compat
import Compat.Libdl
import Compat.Sys
using Pkg

@BinDeps.setup

using Compat

# check for cairo version
# check for cairo version
function validate_cairo_version(name,handle)
f = Libdl.dlsym_e(handle, "cairo_version")
f == C_NULL && return false
v = ccall(f, Int32,())
v = ccall(f, Int32,())
return v > 10800
end

Expand All @@ -28,7 +33,7 @@ deps = [
zlib = library_dependency("zlib", aliases = ["libzlib","zlib1"], os = :Windows, group = group)
]

if is_windows()
if Sys.iswindows()
using WinRPM
provides(WinRPM.RPM,"libpango-1_0-0",[pango,pangocairo],os = :Windows)
provides(WinRPM.RPM,["glib2", "libgobject-2_0-0"],gobject,os = :Windows)
Expand Down Expand Up @@ -79,7 +84,7 @@ provides(Yum,
"libpng" => libpng,
"gettext-libs" => gettext
))

provides(Zypper,
Dict(
"libcairo" => cairo,
Expand Down Expand Up @@ -107,7 +112,7 @@ provides(Sources,
URI("http://zlib.net/zlib-1.2.7.tar.gz") => zlib
))

xx(t...) = (is_windows() ? t[1] : (is_linux() || length(t) == 2) ? t[2] : t[3])
xx(t...) = (Sys.iswindows() ? t[1] : (is_linux() || length(t) == 2) ? t[2] : t[3])

provides(BuildProcess,
Dict(
Expand Down
37 changes: 19 additions & 18 deletions samples/sample_alpha_paint.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## header to provide surface and context
using Cairo
using Colors
using Compat

c = CairoRGBSurface(256,256);
cr = CairoContext(c);
c = CairoRGBSurface(256,256)
cr = CairoContext(c)

save(cr);
save(cr)

z = Array{RGB24}(2,2)
z = Array{RGB24}(uninitialized, 2, 2)
c1 = convert(RGB24,colorant"grey20")
c2 = convert(RGB24,colorant"grey80")
z[1,1] = c1
Expand All @@ -16,18 +17,18 @@ z[2,1] = c2
z[2,2] = c1

img = CairoImageSurface(z)
pattern = CairoPattern(img);
pattern_set_extend(pattern, Cairo.EXTEND_REPEAT);
pattern_set_filter(pattern, Cairo.FILTER_BILINEAR);
pattern = CairoPattern(img)
pattern_set_extend(pattern, Cairo.EXTEND_REPEAT)
pattern_set_filter(pattern, Cairo.FILTER_BILINEAR)

m = CairoMatrix(1/8.0,0,0,1/8.0,0,0);
m = CairoMatrix(1/8.0,0,0,1/8.0,0,0)

set_matrix(pattern, m);
set_source(cr, pattern);
paint(cr);
restore(cr);
set_matrix(pattern, m)
set_source(cr, pattern)
paint(cr)
restore(cr)

save(cr);
save(cr)

# 5 uses of set_source

Expand Down Expand Up @@ -75,8 +76,8 @@ restore(cr)


## mark picture with current date
restore(cr);
move_to(cr,0.0,12.0);
set_source_rgb(cr, 0,0,0);
show_text(cr,Libc.strftime(time()));
write_to_png(c,"sample_alpha_paint.png");
restore(cr)
move_to(cr,0.0,12.0)
set_source_rgb(cr, 0,0,0)
show_text(cr,Libc.strftime(time()))
write_to_png(c,"sample_alpha_paint.png")
7 changes: 4 additions & 3 deletions samples/sample_arc.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## header to provide surface and context
using Cairo

c = CairoRGBSurface(256,256);
cr = CairoContext(c);

Expand All @@ -13,14 +14,14 @@ restore(cr);
xc = 128.0;
yc = 128.0;
radius = 100.0;
angle1 = 45.0 * (pi/180.0); # angles are specified
angle2 = 180.0 * (pi/180.0); # in radians
angle1 = 45.0 * (pi/180.0); # angles are specified
angle2 = 180.0 * (pi/180.0); # in radians

set_line_width(cr, 10.0);
arc(cr, xc, yc, radius, angle1, angle2);
stroke(cr);

# draw helping lines
# draw helping lines
set_source_rgba(cr, 1, 0.2, 0.2, 0.6);
set_line_width(cr, 6.0);

Expand Down
6 changes: 3 additions & 3 deletions samples/sample_arc_negative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ restore(cr);
xc = 128.0;
yc = 128.0;
radius = 100.0;
angle1 = 45.0 * (pi/180.0); # angles are specified
angle2 = 180.0 * (pi/180.0); # in radians
angle1 = 45.0 * (pi/180.0); # angles are specified
angle2 = 180.0 * (pi/180.0); # in radians

set_line_width(cr, 10.0);
arc_negative(cr, xc, yc, radius, angle1, angle2);
stroke(cr);

# draw helping lines
# draw helping lines
set_source_rgba(cr, 1, 0.2, 0.2, 0.6);
set_line_width(cr, 6.0);

Expand Down
2 changes: 1 addition & 1 deletion samples/sample_copy_path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function example_copy_path(cr)
s1 = repr(x.points)
move_to(cr,100.0,14.0*l)
l += 1
show_text(cr,s0*s1); #
show_text(cr,s0*s1)
end
nothing
end
Expand Down
45 changes: 23 additions & 22 deletions samples/sample_copy_path_flat.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
## header to provide surface and context
using Cairo
c = CairoRGBSurface(256,256);
cr = CairoContext(c);

save(cr);
set_source_rgb(cr,0.8,0.8,0.8); # light gray
rectangle(cr,0.0,0.0,256.0,256.0); # background
fill(cr);
restore(cr);
c = CairoRGBSurface(256,256)
cr = CairoContext(c)

save(cr);
save(cr)
set_source_rgb(cr,0.8,0.8,0.8) # light gray
rectangle(cr,0.0,0.0,256.0,256.0) # background
fill(cr)
restore(cr)

save(cr)

## original example, following here
move_to(cr, 16.0, 32.0);
curve_to(cr, 16.0, 16.0, 16.0, 16.0, 32.0, 16.0);
move_to(cr, 16.0, 32.0)
curve_to(cr, 16.0, 16.0, 16.0, 16.0, 32.0, 16.0)

opath = Cairo.convert_cairo_path_data(Cairo.copy_path(cr));
dx,dy,ex,ey = path_extents(cr);
opath = Cairo.convert_cairo_path_data(Cairo.copy_path(cr))
dx,dy,ex,ey = path_extents(cr)

fpath = Cairo.convert_cairo_path_data(Cairo.copy_path_flat(cr));
fpath = Cairo.convert_cairo_path_data(Cairo.copy_path_flat(cr))

stroke(cr);
stroke(cr)

restore(cr);
restore(cr)

l = 2 # something like a line counter

Expand All @@ -40,7 +41,7 @@ for x in opath
s1 = repr(x.points)
move_to(cr,10.0,16.0+(14.0*l))
l += 1
show_text(cr,s0*s1); #
show_text(cr,s0*s1)
end

l = 2 # something like a line counter
Expand All @@ -59,15 +60,15 @@ for x in fpath
s1 = repr(x.points)
move_to(cr,10.0,50.0+(14.0*l))
l += 1
show_text(cr,s0*s1); #
show_text(cr,s0*s1)
end


## mark picture with current date
restore(cr);
restore(cr)

move_to(cr,0.0,12.0);
set_source_rgb(cr, 0,0,0);
show_text(cr,Libc.strftime(time()));
move_to(cr,0.0,12.0)
set_source_rgb(cr, 0,0,0)
show_text(cr,Libc.strftime(time()))

write_to_png(c,"sample_copy_path_flat.png");
write_to_png(c,"sample_copy_path_flat.png")
4 changes: 2 additions & 2 deletions samples/sample_pango_text.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## header to provide surface and context
using Cairo
using Cairo, Compat, Printf
c = CairoRGBSurface(256,256);
cr = CairoContext(c);

Expand All @@ -19,7 +19,7 @@ text(cr,16.0,104.0,"Text<b>Bold</b><i>Italic</i><sup>super-2</sup>",markup=true)

text(cr,40.0,224.0,"Es geht <span foreground=\"white\" background=\"blue\">aufwärts</span> !",markup=true,angle=30.0)

#using textwidth and height
#using textwidth and height

set_font_face(cr, "Sans 12")

Expand Down
Loading

0 comments on commit 7837a28

Please sign in to comment.