Skip to content

Commit

Permalink
clean the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonMiraj committed Aug 15, 2024
1 parent 9662188 commit 6ff8b7d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/backends/fig_drawing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end subroutine set_background
subroutine add_shape(this, s)
class(drawing), intent(inout) :: this
class(shape), intent(in), target :: s
integer :: new_size, i
integer :: new_size
type(shapeWrapper), allocatable :: temp(:)

if (this%shape_count >= size(this%shapes)) then
Expand Down
7 changes: 4 additions & 3 deletions src/backends/fig_shapes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module fig_shapes
real(kind=8), allocatable :: dash_array(:)
end type shape

type :: shapeWrapper
class(shape), allocatable :: sh
end type

type, extends(shape) :: arc
type(point) :: center
real (kind=8):: r
Expand Down Expand Up @@ -59,7 +63,4 @@ module fig_shapes
real (kind=8):: size = 14
end type text

type :: shapeWrapper
class(shape), allocatable :: sh
end type
end module fig_shapes
2 changes: 1 addition & 1 deletion src/backends/generic_cairo/shapes/path.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ subroutine write_path(canva, cr, ph)
character(len=1), allocatable:: char_array(:)
real(kind=8), allocatable:: real_array(:)
integer :: char_count, real_count,char_ind,real_ind
type(canvas_point) :: cur_p,p1,p2,p3,p4,p5,p6
type(canvas_point) :: cur_p,p1,p2
type(point) :: temp_p
real_ind =1

Expand Down
2 changes: 0 additions & 2 deletions src/backends/generic_cairo/shapes/poly.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ subroutine write_polyline(canva, cr, pl)
type(point), allocatable:: points(:)
integer :: p_count,i
type(canvas_point) :: p
type(canvas_size):: s
call parse_string(pl%poly_string, points, p_count)

p = to_canvas(points(1), canva%size)
Expand All @@ -35,7 +34,6 @@ subroutine write_polygon(canva, cr, pl)
type(point), allocatable:: points(:)
integer :: p_count,i
type(canvas_point) :: p
type(canvas_size):: s
call parse_string(pl%poly_string, points, p_count)

p = to_canvas(points(1), canva%size)
Expand Down
3 changes: 0 additions & 3 deletions src/backends/raster/bitmap_backend.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ subroutine load_from_ppm(this,file_path)
integer :: i, j, width, height, max_color_value
integer :: red, green, blue
character(len=2) :: magic_number
integer :: bytes(3)
character(len=1) :: temp
character(len=1) :: byte
character :: ccode

open(newunit=unit_num, file=file_path, status='old', access="stream", form="formatted", iostat=ierr)
Expand Down
14 changes: 14 additions & 0 deletions src/fig.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module fig
use fig_rgb
use fig_rgb_color_constants
use fig_config
use fig_shapes
use fig_poly
use fig_path
use fig_drawing
use fig_svg
use fig_bitmap
implicit none

end module fig

1 change: 0 additions & 1 deletion src/fig_config.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ module fig_config
integer, parameter :: rgb_bit_depth = 8
logical :: FIG_ABSOLUTE_COORDINATES = .false.
end module fig_config

1 change: 1 addition & 0 deletions src/fig_rgb.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module fig_rgb
use fig_config
implicit none
public

type :: RGB
sequence
Expand Down
3 changes: 2 additions & 1 deletion src/fig_rgb_color_constants.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module fig_rgb_color_constants
use fig_rgb
implicit none
public

type(RGB), parameter :: FIG_COLOR_ALICEBLUE= RGB(0.9412, 0.9725, 1.0000, 1.0000)
type(RGB), parameter :: FIG_COLOR_ANTIQUEWHITE = RGB(0.9804, 0.9216, 0.8431, 1.0000)
Expand Down Expand Up @@ -76,7 +77,7 @@ module fig_rgb_color_constants
type(RGB), parameter :: FIG_COLOR_LIGHTGRAY = RGB(0.8275, 0.8275, 0.8275, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTGREEN = RGB(0.5647, 0.9333, 0.5647, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTGREY = RGB(0.8275, 0.8275, 0.8275, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTPINK = RGB(1.0000, 0.7137, 0.7569, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTPINK = RGB(1.0000, 0.7137, 0.7569, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTSALMON = RGB(1.0000, 0.6275, 0.4784, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTSEAGREEN = RGB( 0.1255, 0.6980, 0.6667, 1.0000)
type(RGB), parameter :: FIG_COLOR_LIGHTSKYBLUE = RGB(0.5294, 0.8078, 0.9804, 1.0000)
Expand Down
7 changes: 2 additions & 5 deletions src/fig_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ subroutine test_svg(canvas_name,err)
integer,intent(out) :: err
integer :: status
character(len=256) :: current_file, expected_file, diff_command, diff_file
character(:),allocatable :: diff_output
current_file = canvas_name // ".svg"
expected_file = "test/expected/" // canvas_name // ".svg"
diff_file = canvas_name // "_svg.diff"
Expand All @@ -35,10 +34,8 @@ subroutine test_bitmap(canvas_name,current_canvas,err)
integer,intent(out) :: err
type(bitmap_canvas)::expected_canvas
type(bitmap_canvas)::diff_canvas
integer :: status
logical :: failed = .false.
character(len=256) :: current_file, expected_file, diff_command, diff_file
character(:),allocatable :: diff_output
character(len=256) :: current_file, expected_file, diff_file
integer :: i , j
integer(c_int32_t) :: diff_color , current_pixel, expected_pixel

Expand Down Expand Up @@ -88,7 +85,7 @@ end subroutine test_bitmap
subroutine test_both(canvas_name,current_canvas)
character(len=*), intent(in) :: canvas_name
type(bitmap_canvas), intent(inout) ::current_canvas
integer :: svg_err,bitmap_err
! integer :: svg_err,bitmap_err
!call test_svg(canvas_name,svg_err)
!!call test_bitmap(canvas_name,current_canvas,bitmap_err)
!! TODO NEED fixing possibly use img_diff instead
Expand Down

0 comments on commit 6ff8b7d

Please sign in to comment.