1 function ellipseXIntercept(yi, rx, ry)
3 return rx * Math.sqrt(1 - (yi * yi) / (ry * ry));
6 function scanConvertRoundedRectangleOutside(r, height, lineHeight, corner)
9 var upperCorner = true;
10 var lowerCorner = true;
12 if (corner == "upper")
14 else if (corner == "lower")
17 for (var y = 0; y < height; y += lineHeight) {
18 if (y + lineHeight <= r.y || y >= r.y + r.height)
21 if (upperCorner && (y + lineHeight < r.y + r.ry)) {
22 // within the upper rounded corner part of the rectangle
23 var dx = ellipseXIntercept(y + lineHeight - r.y - r.ry, r.rx, r.ry);
24 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
26 else if (lowerCorner && (y > r.y + r.height - r.ry)) {
27 // within the lower rounded corner part of the rectangle
28 var dx = ellipseXIntercept(y - (r.y + r.height - r.ry), r.rx, r.ry);
29 intervals.push( { y: y, left: r.x + r.rx - dx, right: r.x + r.width - r.rx + dx} );
31 else // within the rectangle's vertical edges
32 intervals.push( {y: y, left: r.x, right: r.x + r.width} );
38 function genLeftRightRoundedRectFloatShapeOutsideRefTest(args)
40 genLeftRoundedRectFloatShapeOutsideRefTest(args);
41 genRightRoundedRectFloatShapeOutsideRefTest(args);
44 function genLeftRoundedRectFloatShapeOutsideRefTest(args)
46 var leftRoundedRect = args.roundedRect;
47 var leftRoundedRectIntervals = scanConvertRoundedRectangleOutside(leftRoundedRect, args.containerHeight, args.lineHeight, args.corner);
48 var leftFloatDivs = leftRoundedRectIntervals.map(function(interval) {
49 var width = SubPixelLayout.snapToLayoutUnit(interval.right);
50 var cls = "left-" + args.floatElementClassSuffix;
51 return '<div class="' + cls + '" style="width:' + width + 'px"></div>';
53 document.getElementById("left-" + args.insertElementIdSuffix).insertAdjacentHTML('afterend', leftFloatDivs.join("\n"));
56 function genRightRoundedRectFloatShapeOutsideRefTest(args)
58 var rightRoundedRect = Object.create(args.roundedRect);
59 rightRoundedRect.x = args.containerWidth - args.roundedRect.width;
60 var rightRoundedRectIntervals = scanConvertRoundedRectangleOutside(rightRoundedRect, args.containerHeight, args.lineHeight, args.corner);
61 var rightFloatDivs = rightRoundedRectIntervals.map(function(interval) {
62 var width = args.containerWidth - SubPixelLayout.snapToLayoutUnit(interval.left);
63 var cls = "right-" + args.floatElementClassSuffix;
64 return '<div class="' + cls + '" style="width:' + width + 'px"></div>';
66 document.getElementById("right-" + args.insertElementIdSuffix).insertAdjacentHTML('afterend', rightFloatDivs.join("\n"));