Skip to content

Commit

Permalink
initial format
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Dec 31, 2022
1 parent 9d117e0 commit 3e58ffe
Show file tree
Hide file tree
Showing 208 changed files with 4,212 additions and 4,186 deletions.
2 changes: 1 addition & 1 deletion CairoMakie/src/CairoMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Makie: spaces, is_data_space, is_pixel_space, is_relative_space, is_clip_s
using Makie: numbers_to_colors

# re-export Makie, including deprecated names
for name in names(Makie, all=true)
for name in names(Makie, all = true)
if Base.isexported(Makie, name)
@eval using Makie: $(name)
@eval export $(name)
Expand Down
10 changes: 5 additions & 5 deletions CairoMakie/src/cairo-extension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ end
function show_glyph(ctx, glyph, x, y)
cg = Ref(CairoGlyph(glyph, x, y))
ccall((:cairo_show_glyphs, Cairo.libcairo),
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint),
ctx.ptr, cg, 1)
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint),
ctx.ptr, cg, 1)
end

function glyph_path(ctx, glyph, x, y)
cg = Ref(CairoGlyph(glyph, x, y))
ccall((:cairo_glyph_path, Cairo.libcairo),
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint),
ctx.ptr, cg, 1)
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint),
ctx.ptr, cg, 1)
end

function surface_set_device_scale(surf, device_x_scale, device_y_scale=device_x_scale)
function surface_set_device_scale(surf, device_x_scale, device_y_scale = device_x_scale)
# this sets a scaling factor on the lowest level that is "hidden" so its even
# enabled when the drawing space is reset for strokes
# that means it can be used to increase or decrease the image resolution
Expand Down
10 changes: 5 additions & 5 deletions CairoMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ function display_path(type::String)
return abspath(joinpath(@__DIR__, "display." * type))
end

function Base.display(screen::Screen, scene::Scene; connect=false)
function Base.display(screen::Screen, scene::Scene; connect = false)
# Nothing to do, since drawing is done in the other functions
# TODO write to file and implement upenurl
return screen
end

function Base.display(screen::Screen{IMAGE}, scene::Scene; connect=false)
function Base.display(screen::Screen{IMAGE}, scene::Scene; connect = false)
path = display_path("png")
Makie.push_screen!(scene, screen)
cairo_draw(screen, scene)
Expand Down Expand Up @@ -133,7 +133,7 @@ end
Converts anything like `"png", :png, "image/png", MIME"image/png"()` to `"image/png"`.
"""
function to_mime_string(mime::Union{String, Symbol, MIME})
function to_mime_string(mime::Union{String,Symbol,MIME})
if mime isa MIME
mime_str = string(mime)
if !(mime_str in SUPPORTED_MIMES)
Expand All @@ -156,7 +156,7 @@ The default is automatic, which lets the display system figure out the best mime
If set to any other valid mime, will result in `showable(any_other_mime, figurelike)` to return false and only return true for `showable(preferred_mime, figurelike)`.
Depending on the display system used, this may result in nothing getting displayed.
"""
function disable_mime!(mimes::Union{String, Symbol, MIME}...)
function disable_mime!(mimes::Union{String,Symbol,MIME}...)
empty!(DISABLED_MIMES) # always start from 0
if isempty(mimes)
# Reset disabled mimes when called with no arguments
Expand All @@ -170,7 +170,7 @@ function disable_mime!(mimes::Union{String, Symbol, MIME}...)
return
end

function enable_only_mime!(mimes::Union{String, Symbol, MIME}...)
function enable_only_mime!(mimes::Union{String,Symbol,MIME}...)
empty!(DISABLED_MIMES) # always start from 0
if isempty(mimes)
# Reset disabled mimes when called with no arguments
Expand Down
4 changes: 2 additions & 2 deletions CairoMakie/src/infrastructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ function draw_background(screen::Screen, scene::Scene)
Cairo.save(cr)
if scene.clear[]
bg = scene.backgroundcolor[]
Cairo.set_source_rgba(cr, red(bg), green(bg), blue(bg), alpha(bg));
Cairo.set_source_rgba(cr, red(bg), green(bg), blue(bg), alpha(bg))
r = pixelarea(scene)[]
Cairo.rectangle(cr, origin(r)..., widths(r)...) # background
fill(cr)
end
Cairo.restore(cr)
foreach(child_scene-> draw_background(screen, child_scene), scene.children)
foreach(child_scene -> draw_background(screen, child_scene), scene.children)
end

function draw_plot(scene::Scene, screen::Screen, primitive::Combined)
Expand Down
14 changes: 7 additions & 7 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2})
end

# when color is a Makie.AbstractPattern, we don't need to go to Mesh
function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2}, color::Union{Colorant, Makie.AbstractPattern},
model, strokecolor, strokewidth)
function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2}, color::Union{Colorant,Makie.AbstractPattern},
model, strokecolor, strokewidth)
space = to_value(get(poly, :space, :data))
points = project_position.(Ref(scene), space, points, Ref(model))
Cairo.move_to(screen.context, points[1]...)
Expand All @@ -49,7 +49,7 @@ function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2},
Cairo.close_path(screen.context)
if color isa Makie.AbstractPattern
cairopattern = Cairo.CairoPattern(color)
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT);
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT)
Cairo.set_source(screen.context, cairopattern)
else
Cairo.set_source_rgba(screen.context, rgbatuple(to_color(color))...)
Expand All @@ -66,7 +66,7 @@ function draw_poly(scene::Scene, screen::Screen, poly, points_list::Vector{<:Vec
strokecolor = to_color(poly.strokecolor[])
broadcast_foreach(points_list, color,
strokecolor, poly.strokewidth[], Ref(poly.model[])) do points, color, strokecolor, strokewidth, model
draw_poly(scene, screen, poly, points, color, model, strokecolor, strokewidth)
draw_poly(scene, screen, poly, points, color, model, strokecolor, strokewidth)
end
end

Expand All @@ -85,7 +85,7 @@ function draw_poly(scene::Scene, screen::Screen, poly, rects::Vector{<:Rect2})
color = to_color(color)
elseif color isa Makie.AbstractPattern
cairopattern = Cairo.CairoPattern(color)
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT);
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT)
end
strokecolor = poly.strokecolor[]
if strokecolor isa AbstractArray{<:Number}
Expand Down Expand Up @@ -168,7 +168,7 @@ end
################################################################################

function draw_plot(scene::Scene, screen::Screen,
band::Band{<:Tuple{<:AbstractVector{<:Point2},<:AbstractVector{<:Point2}}})
band::Band{<:Tuple{<:AbstractVector{<:Point2},<:AbstractVector{<:Point2}}})

if !(band.color[] isa AbstractArray)
upperpoints = band[1][]
Expand Down Expand Up @@ -215,7 +215,7 @@ function draw_plot(scene::Scene, screen::Screen, tric::Tricontourf)
function draw_tripolys(polys, colornumbers, colors)
for (i, (pol, colnum, col)) in enumerate(zip(polys, colornumbers, colors))
polypath(screen.context, pol)
if i == length(colornumbers) || colnum != colornumbers[i+1]
if i == length(colornumbers) || colnum != colornumbers[i + 1]
Cairo.set_source_rgba(screen.context, rgbatuple(col)...)
Cairo.fill(screen.context)
end
Expand Down
Loading

0 comments on commit 3e58ffe

Please sign in to comment.