dyoo / WeScheme

29 stars 16 forks source link

beside/align #25

Closed dyoo closed 12 years ago

dyoo commented 13 years ago

Bug reported by proefessor ordonez:

I'm using WeScheme with 3 high school students because it allows us to use the HtDP curriculum without the hassle of getting things installed in their school lab. Thank you so much for the work you've put into making this amazing tool available.

I've found a bug in WeScheme's implementation of beside/align. Try the examples at http://docs.racket-lang.org/teachpack/2htdpimage.html#(def._((lib._2htdp/image..rkt)._beside/align)) in DrRacket and WeScheme. And try the example below. The results are different in the two environments, and the result for the example below is particularly puzzling--the first two are aligned at the bottom and the last two are aligned at the top.

(beside/align "top" (rectangle 20 100 "solid" "black") (rectangle 20 120 "solid" "black") (rectangle 20 80 "solid" "black"))

schanzer commented 13 years ago

This is my fault, for never clearing out some logic I'd factored away elsewhere.

In kernel.js, lines 530 - 543 should not care about which image is taller or wider. The correct logic for calculating offsets is:

if      (placeX == "left"  )  var X = img2.getWidth()-(c1x+c2x);
else if (placeX == "right" )  var X = img1.getWidth()-(c1x+c2x);
else if (placeX == "beside")  var X = c1x+c2x;
else if (placeX == "middle" || 
         placeX == "center")  var X = 0;
else                          var X = placeX;

if      (placeY == "top")     var Y = img2.getHeight()-(c1y+c2y); 
else if (placeY == "bottom")  var Y = img1.getHeight()-(c1y+c2y);
else if (placeY == "above" )  var Y = c1y+c2y;
else if (placeY == "baseline") var Y= img1.getBaseline()-img2.getBaseline();
else if (placeY == "middle" || 
         placeY == "center")  var Y = 0;
else                          var Y = placeY;

My Git repo is messed up, but once I get it back and running I'll commit the fix (unless Danny has already copied-and-pasted this by then).

E On May 2, 2011, at 1:45 PM, dyoo wrote:

Bug reported by proefessor ordonez:

I'm using WeScheme with 3 high school students because it allows us to use the HtDP curriculum without the hassle of getting things installed in their school lab. Thank you so much for the work you've put into making this amazing tool available.

I've found a bug in WeScheme's implementation of beside/align. Try the examples at http://docs.racket-lang.org/teachpack/2htdpimage.html#(def._((lib._2htdp/image..rkt)._beside/align)) in DrRacket and WeScheme. And try the example below. The results are different in the two environments, and the result for the example below is particularly puzzling--the first two are aligned at the bottom and the last two are aligned at the top.

(beside/align "top" (rectangle 20 100 "solid" "black") (rectangle 20 120 "solid" "black") (rectangle 20 80 "solid" "black"))

Reply to this email directly or view it on GitHub: https://github.com/dyoo/WeScheme/issues/25

dyoo commented 13 years ago

In kernel.js, lines 530 - 543 should not care about which image is taller or wider. The correct logic for calculating offsets is:

Tried this, but does not appear to fix the problem from my end; image still doesn't look right.

dyoo commented 12 years ago

Appears to be fixed in https://github.com/bootstrapworld/wescheme-compiler2012/commit/62fcd96693e13a829765435d961211547c75dc8c