Skip to content

Commit

Permalink
support in bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonMiraj committed Jul 7, 2024
1 parent 67085f7 commit 041c6ed
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/backends/raster/bitmap_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module fig_bitmap_utils
use cairo
use fig_config
implicit none
real(kind=8),parameter :: kappa = 0.55228474983079339840

contains

Expand Down
3 changes: 1 addition & 2 deletions src/backends/raster/shapes/bitmap_circle.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ subroutine write_circle(canva, cr, circ)
type(c_ptr), intent(inout):: cr
type(circle), intent(in) :: circ
type(canvas_point) :: c
real(kind=8) :: left , top , right , bottom , kappa, cpx,cpy
real(kind=8) :: left , top , right , bottom , cpx, cpy

c = to_canvas ( circ%center , canva%size)

kappa = 0.55228474983079339840
left = c%x - circ%r;
top = c%y - circ%r;
right = c%x + circ%r;
Expand Down
3 changes: 1 addition & 2 deletions src/backends/raster/shapes/bitmap_ellipse.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ subroutine write_ellipse(canva, cr, ellip)
type(c_ptr), intent(inout):: cr
type(ellipse), intent(in) :: ellip
type(canvas_point) :: c
real(kind=8) :: left , top , right , bottom , kappa, cpx,cpy
real(kind=8) :: left , top , right , bottom , cpx, cpy

c = to_canvas ( ellip%center , canva%size)

kappa = 0.55228474983079339840
left = c%x - ellip%rx;
top = c%y - ellip%ry;
right = c%x + ellip%rx;
Expand Down
28 changes: 25 additions & 3 deletions src/backends/raster/shapes/bitmap_rect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,37 @@ subroutine write_rectangle(canva, cr, rect)
type(c_ptr), intent(inout):: cr
type(rectangle), intent(in) :: rect
type(canvas_point) :: p
real(kind=8) :: right , bottom
real(kind=8) :: rx, ry, cpx,cpy

p = to_canvas ( rect%upper_left , canva%size)


call cairo_rectangle(cr, p%x, p%y, rect%width, rect%height)
call fill(cr,rect)
call stroke(cr,rect)
if (rect%rx<1.or.rect%ry<1) then
call cairo_rectangle(cr, p%x, p%y, rect%width, rect%height)
else
rx=min(rect%rx, rect%width * 0.5)
ry=min(rect%ry, rect%height * 0.5)

right = p%x +rect%width
bottom = p%y +rect%height
cpx = rx * kappa
cpy = ry * kappa

call cairo_move_to(cr, p%x, p%y+ry);
call cairo_curve_to(cr, p%x, p%y+ry-cpy, p%x+rx-cpx, p%y, p%x+rx, p%y);
call cairo_line_to(cr, right-rx, p%y);
call cairo_curve_to(cr, right-rx+cpx,p%y, right,p%y+ry-cpy, right,p%y+ry);
call cairo_line_to(cr, right, bottom-ry);
call cairo_curve_to(cr, right, bottom-ry+cpy, right-rx+cpx, bottom, right-rx, bottom);
call cairo_line_to(cr, p%x+rx, bottom);
call cairo_curve_to(cr, p%x+rx-cpx, bottom,p%x, bottom-ry+cpy, p%x, bottom-ry);
call cairo_line_to(cr, p%x, p%y+ry);
call cairo_close_path(cr);
end if

call fill(cr,rect)
call stroke(cr,rect)
end subroutine write_rectangle

end module fig_bitmap_rect

0 comments on commit 041c6ed

Please sign in to comment.