Skip to content

Commit

Permalink
final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonMiraj committed Jul 6, 2024
1 parent 674cf12 commit 5020f2f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/backends/fig_types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ elemental type(canvas_point) function to_canvas(p, sz) result(pxl)
type(point), intent(in) :: p
type(canvas_size), intent(in) :: sz

pxl%x = nint(p%x * sz%width, kind=pixel)
pxl%y = nint(p%y * sz%height, kind=pixel)
pxl%x = p%x * sz%width
pxl%y = p%y * sz%height
end function to_canvas

end module fig_types
22 changes: 11 additions & 11 deletions src/backends/raster/bitmap_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ function normalize_ch(ch) result(res)
res= real(ch,kind=8)/real(2**rgb_bit_depth-1,kind=8)
end function normalize_ch

subroutine fill(cr,color)
subroutine fill(cr,sh)
type(c_ptr), intent(inout) :: cr
type(RGB) :: color
if (color%a .ne. 0) then
call set_rgba(cr,color)
class(shape), intent(in) :: sh
if (sh%fill_color%a .ne. 0) then
call set_rgba(cr,sh%fill_color)
call cairo_fill_preserve(cr)
end if
end if
end subroutine fill

subroutine stroke(cr,color,width)
subroutine stroke(cr,sh)
type(c_ptr), intent(inout) :: cr
type(RGB) :: color
real(kind=8) :: width
if (color%a .ne. 0) then
call set_rgba(cr,color)
call cairo_set_line_width(cr,width)
class(shape), intent(in) :: sh

if (sh%stroke_color%a .ne. 0) then
call set_rgba(cr,sh%stroke_color)
call cairo_set_line_width(cr,sh%stroke_width)
call cairo_stroke(cr)
else
call cairo_new_path(cr)
Expand Down
4 changes: 2 additions & 2 deletions src/backends/raster/shapes/bitmap_circle.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ subroutine write_circle(canva, cr, circ)
call cairo_curve_to(cr, c%x - cpx, bottom, left, c%y + cpy, left, c%y);
call cairo_curve_to(cr, left, c%y - cpy, c%x - cpx, top, c%x, top);
call cairo_close_path(cr);
call fill(cr,circ%fill_color)
call stroke(cr,circ%stroke_color,circ%stroke_width)
call fill(cr,circ)
call stroke(cr,circ)

end subroutine write_circle

Expand Down
4 changes: 2 additions & 2 deletions src/backends/raster/shapes/bitmap_ellipse.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ subroutine write_ellipse(canva, cr, ellip)
call cairo_curve_to(cr, c%x - cpx, bottom, left, c%y + cpy, left, c%y);
call cairo_curve_to(cr, left, c%y - cpy, c%x - cpx, top, c%x, top);
call cairo_close_path(cr);
call fill(cr,ellip%fill_color)
call stroke(cr,ellip%stroke_color,ellip%stroke_width)
call fill(cr,ellip)
call stroke(cr,ellip)

end subroutine write_ellipse

Expand Down
2 changes: 1 addition & 1 deletion src/backends/raster/shapes/bitmap_line.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ subroutine write_line(canva, cr, l)
call cairo_move_to(cr,p1%x,p1%y)
call cairo_line_to(cr,p2%x,p2%y)
call cairo_close_path(cr)
call stroke(cr,l%stroke_color,l%stroke_width)
call stroke(cr,l)


end subroutine write_line
Expand Down
4 changes: 2 additions & 2 deletions src/backends/raster/shapes/bitmap_rect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ subroutine write_rectangle(canva, cr, rect)


call cairo_rectangle(cr, p%x, p%y, rect%width, rect%height)
call fill(cr,rect%fill_color)
call stroke(cr,rect%stroke_color, rect%stroke_width)
call fill(cr,rect)
call stroke(cr,rect)


end subroutine write_rectangle
Expand Down
4 changes: 2 additions & 2 deletions src/backends/raster/shapes/bitmap_triangle.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ subroutine write_triangle(canva, cr, tri)
call cairo_line_to(cr,p3%x,p3%y)
call cairo_line_to(cr,p1%x,p1%y)
call cairo_close_path(cr)
call fill(cr,tri%fill_color)
call stroke(cr,tri%stroke_color,tri%stroke_width)
call fill(cr,tri)
call stroke(cr,tri)

end subroutine write_triangle

Expand Down

0 comments on commit 5020f2f

Please sign in to comment.