OLD | NEW |
| (Empty) |
1 function ellipseXIntercept(yi, rx, ry) | |
2 { | |
3 return rx * Math.sqrt(1 - (yi * yi) / (ry * ry)); | |
4 } | |
5 | |
6 function scanConvertRoundedRectangleOutside(r, height, lineHeight) | |
7 { | |
8 var intervals = []; | |
9 | |
10 for (var y = 0; y < height; y += lineHeight) { | |
11 if (y + lineHeight <= r.y || y >= r.y + r.height) | |
12 continue; | |
13 | |
14 if (y + lineHeight < r.y + r.ry) { | |
15 // within the upper rounded corner of the rectangle | |
16 var dx = ellipseXIntercept(y + lineHeight - r.y - r.ry, r.rx, r.ry); | |
17 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width
- r.rx + dx} ); | |
18 } | |
19 else if (y > r.y + r.height - r.ry) { | |
20 // within the lower rounded corner of the rectangle | |
21 var dx = ellipseXIntercept(y - (r.y + r.height - r.ry), r.rx, r.ry); | |
22 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width
- r.rx + dx} ); | |
23 } | |
24 else // within the rectangle's vertical edges | |
25 intervals.push( {y: y, left: r.x, right: r.x + r.width} ); | |
26 } | |
27 | |
28 return intervals; | |
29 } | |
30 | |
31 function genLeftRightRoundedRectFloatShapeOutsideRefTest(args) | |
32 { | |
33 genLeftRoundedRectFloatShapeOutsideRefTest(args); | |
34 genRightRoundedRectFloatShapeOutsideRefTest(args); | |
35 } | |
36 | |
37 function genLeftRoundedRectFloatShapeOutsideRefTest(args) | |
38 { | |
39 var leftRoundedRect = args.roundedRect; | |
40 var leftRoundedRectIntervals = scanConvertRoundedRectangleOutside(leftRounde
dRect, args.containerHeight, args.lineHeight); | |
41 var leftFloatDivs = leftRoundedRectIntervals.map(function(interval) { | |
42 var width = SubPixelLayout.snapToLayoutUnit(interval.right); | |
43 var cls = "left-" + args.floatElementClassSuffix; | |
44 return '<div class="' + cls + '" style="width:' + width + 'px"></div>'; | |
45 }); | |
46 document.getElementById("left-" + args.insertElementIdSuffix).insertAdjacent
HTML('afterend', leftFloatDivs.join("\n")); | |
47 } | |
48 | |
49 function genRightRoundedRectFloatShapeOutsideRefTest(args) | |
50 { | |
51 var rightRoundedRect = Object.create(args.roundedRect); | |
52 rightRoundedRect.x = args.containerWidth - args.roundedRect.width; | |
53 var rightRoundedRectIntervals = scanConvertRoundedRectangleOutside(rightRoun
dedRect, args.containerHeight, args.lineHeight); | |
54 var rightFloatDivs = rightRoundedRectIntervals.map(function(interval) { | |
55 var width = args.containerWidth - SubPixelLayout.snapToLayoutUnit(interv
al.left); | |
56 var cls = "right-" + args.floatElementClassSuffix; | |
57 return '<div class="' + cls + '" style="width:' + width + 'px"></div>'; | |
58 }); | |
59 document.getElementById("right-" + args.insertElementIdSuffix).insertAdjacen
tHTML('afterend', rightFloatDivs.join("\n")); | |
60 } | |
OLD | NEW |