On 19.11.2015 10:08, Fulvio wrote: > Hi, > I have a couple of notes about the patch: > 1) In my opinion $off_small should not be a global variable. > A global variable is always a burden for maintenance, and if I undestand > it correctly $off_small do not need to be changed or used outside the > displayOffers function. > > 2) Even if they are small details, an interpreted language like tcl is > not able to optimize a sum inside a loop.
Hi Fulvio, thank you for the feedback. I've corrected the patch, see the attachment. Jens
>From e21625de6ae7dd0b64f9d2b3d04b3d27b2f08aca Mon Sep 17 00:00:00 2001 From: Jens Hoffmann <xmc...@gmail.com> Date: Wed, 18 Nov 2015 19:58:39 +0100 Subject: [PATCH 1/2] Fics offers: draw guide lines and labels * draw horizontal lines in steps of 100 (ELO) * draw vertical lines in steps of 2m, 5m, 10m, 15m, 30m, 60m --- tcl/tools/fics.tcl | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/tcl/tools/fics.tcl b/tcl/tools/fics.tcl index e737a84..3b044c3 100644 --- a/tcl/tools/fics.tcl +++ b/tcl/tools/fics.tcl @@ -1140,17 +1140,31 @@ namespace eval fics { #first erase the canvas foreach id [ $w.c find all] { $w.c delete $id } - # draw scales - $w.c create line $off [expr $height - $off ] $width [expr $height - $off] -fill blue - $w.c create line $off 0 $off [expr $height - $off] -fill blue - $w.c create text 1 1 -fill black -anchor nw -text ELO - $w.c create text [expr $width - 1 ] [expr $height - 1 ] -fill black -anchor se -text [tr Time] - - # draw time markers at 5', 15' - set x [ expr $off + 5 * ($width - $off) / ($offers_maxtime - $offers_mintime)] - $w.c create line $x 0 $x [expr $height - $off] -fill red - set x [ expr $off + 15 * ($width - $off) / ($offers_maxtime - $offers_mintime)] - $w.c create line $x 0 $x [expr $height - $off] -fill red + # Draw horizontal lines + set y_unit [expr $height / 31.0] + for {set i 0} {$i < 31} {incr i} { + set y [expr $height - $i * $y_unit] + $w.c create line 0 $y $width $y -fill "light gray" + } + + # Draw horizontal tics and labels + set x1_tick [expr $width - $off] + set x_text [expr $width - 2] + foreach elo [list 5 10 15 20 25 30] { + set y [expr $height - $elo * $y_unit] + $w.c create line $x1_tick $y $width $y -fill black + $w.c create text $x_text $y -fill black -anchor se -text [expr $elo * 100] + } + + # Draw vertical lines, tics and labels + set x_unit [expr ($width - 3 * $off) / 60.0] + set y2_tick [expr $height - $off] + foreach t [list 2 5 10 15 30 60] { + set x [expr $t * $x_unit + $off] + $w.c create line $x $height $x 0 -fill "light gray" + $w.c create line $x $height $x $y2_tick -fill black + $w.c create text [expr $x + 2] $height -fill black -anchor sw -text "${t}m" + } foreach g $::fics::soughtlist { array set l $g @@ -1170,8 +1184,9 @@ namespace eval fics { set fillcolor gray } - set x [ expr $off + $tt * ($width - $off) / ($offers_maxtime - $offers_mintime)] - set y [ expr $height - $off - ( $l(elo) - $offers_minelo ) * ($height - $off) / ($offers_maxelo - $offers_minelo)] + set x [expr $tt * $x_unit + $off] + set y [expr $height - ($l(elo) / 100.0) * $y_unit] + if { $l(rated) == "rated" } { set object "oval" } else { -- 2.1.4
>From 2c3c99026d42d86d5a96200957d6ead980ae11a6 Mon Sep 17 00:00:00 2001 From: Jens Hoffmann <xmc...@gmail.com> Date: Wed, 18 Nov 2015 20:03:47 +0100 Subject: [PATCH 2/2] Fics: Remove trailing whitespace --- tcl/tools/fics.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/tools/fics.tcl b/tcl/tools/fics.tcl index 3b044c3..eb7d14c 100644 --- a/tcl/tools/fics.tcl +++ b/tcl/tools/fics.tcl @@ -1307,10 +1307,10 @@ namespace eval fics { if { $::fics::playing == 1 } { return 1 } - if { $::fics::premoveEnabled && $::fics::playing == -1 } { + if { $::fics::premoveEnabled && $::fics::playing == -1 } { .main.board.bd delete mark set ::fics::premoveSq1 -1 - return 1 + return 1 } return 0 } -- 2.1.4
------------------------------------------------------------------------------
_______________________________________________ Scid-users mailing list Scid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scid-users