Merge pull request #5 from schanzer/master
Update whalesong's image library
This commit is contained in:
commit
397bb90747
|
@ -37,9 +37,12 @@ var isFontWeight = function(x){
|
|||
|| (x === false); // false is also acceptable
|
||||
};
|
||||
var isMode = function(x) {
|
||||
return ((isString(x) || isSymbol(x)) &&
|
||||
(x.toString().toLowerCase() == "solid" ||
|
||||
x.toString().toLowerCase() == "outline"));
|
||||
return ((isString(x) || isSymbol(x)) &&
|
||||
(x.toString().toLowerCase() == "solid" ||
|
||||
x.toString().toLowerCase() == "outline")) ||
|
||||
((jsnums.isReal(x)) &&
|
||||
(jsnums.greaterThanOrEqual(x, 0) &&
|
||||
jsnums.lessThanOrEqual(x, 255)));
|
||||
};
|
||||
|
||||
var isPlaceX = function(x) {
|
||||
|
@ -67,6 +70,24 @@ var isStyle = function(x) {
|
|||
|
||||
|
||||
|
||||
// Useful trigonometric functions based on htdp teachpack
|
||||
|
||||
// excess : compute the Euclidean excess
|
||||
// Note: If the excess is 0, then C is 90 deg.
|
||||
// If the excess is negative, then C is obtuse.
|
||||
// If the excess is positive, then C is acuse.
|
||||
function excess(sideA, sideB, sideC) {
|
||||
return sideA*sideA + sideB*sideB - sideC*sideC;
|
||||
}
|
||||
|
||||
// return c^2 = a^2 + b^2 - 2ab cos(C)
|
||||
function cosRel(sideA, sideB, angleC) {
|
||||
return (sideA*sideA) + (sideB*sideB) - (2*sideA*sideB*Math.cos(angleC * Math.PI/180));
|
||||
}
|
||||
|
||||
var less = function(lhs, rhs) {
|
||||
return (rhs - lhs) > 0.00001;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -137,7 +158,7 @@ var checkAngle = plt.baselib.check.makeCheckArgumentType(
|
|||
|
||||
var checkMode = plt.baselib.check.makeCheckArgumentType(
|
||||
isMode,
|
||||
'solid or outline');
|
||||
'solid or outline or [0-255]');
|
||||
|
||||
|
||||
var checkSideCount = plt.baselib.check.makeCheckArgumentType(
|
||||
|
@ -161,10 +182,18 @@ var checkListofColor = plt.baselib.check.makeCheckListofArgumentType(
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
EXPORTS['image=?'] =
|
||||
makePrimitiveProcedure(
|
||||
'image=?',
|
||||
2,
|
||||
function(MACHINE) {
|
||||
var img1 = checkImageOrScene(MACHINE,'image=?', 0);
|
||||
var img2 = checkImageOrScene(MACHINE,'image=?', 1);
|
||||
return img1.equals(img2);
|
||||
});
|
||||
|
||||
|
||||
EXPORTS['image-color?'] =
|
||||
makePrimitiveProcedure(
|
||||
|
@ -322,6 +351,40 @@ EXPORTS['image-url'] =
|
|||
'image-url');
|
||||
|
||||
|
||||
EXPORTS['video/url'] =
|
||||
makeClosure(
|
||||
'video/url',
|
||||
1,
|
||||
function(MACHINE) {
|
||||
var path = checkString(MACHINE, 'video/url', 0);
|
||||
PAUSE(
|
||||
function(restart) {
|
||||
var rawVideo = document.createElement('video');
|
||||
rawVideo.src = path.toString();
|
||||
rawVideo.addEventListener('canplay', function() {
|
||||
restart(function(MACHINE) {
|
||||
function pause(){ rawVideo.pause(); return true;};
|
||||
finalizeClosureCall(
|
||||
MACHINE,
|
||||
makeFileVideo(path.toString(), rawVideo));
|
||||
// aState.addBreakRequestedListener(pause);
|
||||
});
|
||||
});
|
||||
rawVideo.addEventListener('error', function(e) {
|
||||
restart(function(MACHINE) {
|
||||
plt.baselib.exceptions.raiseFailure(
|
||||
MACHINE,
|
||||
plt.baselib.format.format(
|
||||
"unable to load ~a: ~a",
|
||||
[url,
|
||||
e.message]));
|
||||
});
|
||||
});
|
||||
rawVideo.src = path.toString();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
EXPORTS['overlay'] =
|
||||
|
@ -580,6 +643,28 @@ EXPORTS['empty-scene'] =
|
|||
true);
|
||||
});
|
||||
|
||||
EXPORTS['put-image'] =
|
||||
makePrimitiveProcedure(
|
||||
'put-image',
|
||||
4,
|
||||
function(MACHINE) {
|
||||
var picture = checkImage(MACHINE, "put-image", 0);
|
||||
var x = checkReal(MACHINE, "put-image", 1);
|
||||
var y = checkReal(MACHINE, "put-image", 2);
|
||||
var background = checkImageOrScene(MACHINE, "place-image", 3);
|
||||
if (isScene(background)) {
|
||||
return background.add(picture, jsnums.toFixnum(x), background.getHeight() - jsnums.toFixnum(y));
|
||||
} else {
|
||||
var newScene = makeSceneImage(background.getWidth(),
|
||||
background.getHeight(),
|
||||
[],
|
||||
false);
|
||||
newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2);
|
||||
newScene = newScene.add(picture, jsnums.toFixnum(x), background.getHeight() - jsnums.toFixnum(y));
|
||||
return newScene;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
EXPORTS['place-image'] =
|
||||
|
@ -598,8 +683,8 @@ EXPORTS['place-image'] =
|
|||
background.getHeight(),
|
||||
[],
|
||||
false);
|
||||
newScene = newScene.add(background.updatePinhole(0, 0), 0, 0);
|
||||
newScene = newScene.add(picture, jsnums.toFixnum(x), jsnums.toFixnum(y));
|
||||
newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2);
|
||||
newScene = newScene.add(picture, jsnums.toFixnum(x), jsnums.toFixnum(y));
|
||||
return newScene;
|
||||
}
|
||||
|
||||
|
@ -632,8 +717,8 @@ EXPORTS['place-image/align'] =
|
|||
background.getHeight(),
|
||||
[],
|
||||
false);
|
||||
newScene = newScene.add(background.updatePinhole(0, 0), 0, 0);
|
||||
newScene = newScene.add(img, jsnums.toFixnum(x), jsnums.toFixnum(y));
|
||||
newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2);
|
||||
newScene = newScene.add(img, jsnums.toFixnum(x), jsnums.toFixnum(y));
|
||||
return newScene;
|
||||
}
|
||||
});
|
||||
|
@ -784,17 +869,19 @@ EXPORTS['scene+line'] =
|
|||
var c = checkColor(MACHINE, "scene+line", 5);
|
||||
// make a scene containing the image
|
||||
var newScene = makeSceneImage(jsnums.toFixnum(img.getWidth()),
|
||||
jsnums.toFixnum(img.getHeight()),
|
||||
[],
|
||||
true);
|
||||
newScene = newScene.add(img.updatePinhole(0, 0), 0, 0);
|
||||
jsnums.toFixnum(img.getHeight()),
|
||||
[],
|
||||
false);
|
||||
newScene = newScene.add(img, img.getWidth()/2, img.getHeight()/2);
|
||||
// make an image containing the line
|
||||
var line = makeLineImage(jsnums.toFixnum(x2-x1),
|
||||
jsnums.toFixnum(y2-y1),
|
||||
c,
|
||||
false);
|
||||
jsnums.toFixnum(y2-y1),
|
||||
c,
|
||||
false),
|
||||
leftMost = Math.min(x1,x2),
|
||||
topMost = Math.min(y1,y2);
|
||||
// add the line to scene, offset by the original amount
|
||||
return newScene.add(line, jsnums.toFixnum(x1), jsnums.toFixnum(y1));
|
||||
return newScene.add(line, line.getWidth()/2+leftMost, line.getHeight()/2+topMost);
|
||||
});
|
||||
|
||||
|
||||
|
@ -836,9 +923,27 @@ EXPORTS['rectangle'] =
|
|||
s.toString(),
|
||||
c);
|
||||
});
|
||||
/*
|
||||
|
||||
need to port over checks for isListofPosns and isListOfLength
|
||||
|
||||
EXPORTS['polygon'] =
|
||||
makePrimitiveProcedure(
|
||||
'polygon',
|
||||
3,
|
||||
function(MACHINE) {
|
||||
function isPosnList(lst){ return isListOf(lst, types.isPosn); }
|
||||
var points = checkListOfLength(MACHINE, "polygon", 0);
|
||||
var points = checkListOfPosns(MACHINE, "polygon", 0);
|
||||
var s = checkMode(MACHINE, "polygon", 2);
|
||||
var c = checkColor(MACHINE, "polygon", 3);
|
||||
return makePosnImage(points,
|
||||
s.toString(),
|
||||
c);
|
||||
});
|
||||
|
||||
EXPORTS['regular-polygon'] =
|
||||
*/
|
||||
EXPORTS['regular-polygon'] =
|
||||
makePrimitiveProcedure(
|
||||
'regular-polygon',
|
||||
4,
|
||||
|
@ -880,14 +985,219 @@ EXPORTS['triangle'] =
|
|||
var s = checkNonNegativeReal(MACHINE, "triangle", 0);
|
||||
var m = checkMode(MACHINE, "triangle", 1);
|
||||
var c = checkColor(MACHINE, "triangle", 2);
|
||||
return makeTriangleImage(jsnums.toFixnum(s),
|
||||
60,
|
||||
m.toString(),
|
||||
c);
|
||||
return makeTriangleImage(jsnums.toFixnum(s),
|
||||
jsnums.toFixnum(360-60),
|
||||
jsnums.toFixnum(s),
|
||||
m.toString(),
|
||||
c);
|
||||
});
|
||||
|
||||
|
||||
EXPORTS['right-triangle'] =
|
||||
EXPORTS['triangle/sas'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/sas',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var sideA = checkNonNegativeReal(MACHINE, "triangle/sas", 0);
|
||||
var angleB = checkAngle(MACHINE, "triangle/sas", 1);
|
||||
var sideC = checkNonNegativeReal(MACHINE, "triangle/sas", 2);
|
||||
var style = checkMode(MACHINE, "triangle/sas", 3);
|
||||
var color = checkColor(MACHINE, "triangle/sas", 4);
|
||||
// cast to fixnums
|
||||
sideA = jsnums.toFixnum(sideA); angleB = jsnums.toFixnum(angleB); sideC = jsnums.toFixnum(sideC);
|
||||
var sideB2 = cosRel(sideA, sideC, angleB);
|
||||
var sideB = Math.sqrt(sideB2);
|
||||
|
||||
if (sideB2 <= 0) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given side, angle and side will not form a triangle: "
|
||||
+ sideA + ", " + angleB + ", " + sideC, []) );
|
||||
} else {
|
||||
if (less(sideA + sideC, sideB) ||
|
||||
less(sideB + sideC, sideA) ||
|
||||
less(sideA + sideB, sideC)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given side, angle and side will not form a triangle: "
|
||||
+ sideA + ", " + angleB + ", " + sideC, []) );
|
||||
}
|
||||
}
|
||||
|
||||
var angleA = Math.acos(excess(sideB, sideC, sideA) / (2 * sideB * sideC)) * (180 / Math.PI);
|
||||
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
EXPORTS['triangle/sss'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/sss',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var sideA = checkNonNegativeReal(MACHINE, "triangle/sss", 0);
|
||||
var sideB = checkNonNegativeReal(MACHINE, "triangle/sss", 1);
|
||||
var sideC = checkNonNegativeReal(MACHINE, "triangle/sss", 2);
|
||||
var style = checkMode(MACHINE, "triangle/sss", 3);
|
||||
var color = checkColor(MACHINE, "triangle/sss", 4);
|
||||
// cast to fixnums
|
||||
sideA = jsnums.toFixnum(sideA); sideB = jsnums.toFixnum(sideB); sideC = jsnums.toFixnum(sideC);
|
||||
if (less(sideA + sideB, sideC) ||
|
||||
less(sideC + sideB, sideA) ||
|
||||
less(sideA + sideC, sideB)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given sides will not form a triangle: "
|
||||
+ sideA+", "+sideB+", "+sideC, []) );
|
||||
}
|
||||
|
||||
var angleA = Math.acos(excess(sideB, sideC, sideA) / (2 * sideB * sideC)) * (180 / Math.PI);
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
EXPORTS['triangle/ass'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/ass',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var angleA = checkAngle(MACHINE, "triangle/ass", 0);
|
||||
var sideB = checkNonNegativeReal(MACHINE, "triangle/ass", 1);
|
||||
var sideC = checkNonNegativeReal(MACHINE, "triangle/ass", 2);
|
||||
var style = checkMode(MACHINE, "triangle/ass", 3);
|
||||
var color = checkColor(MACHINE, "triangle/ass", 4);
|
||||
// cast to fixnums
|
||||
angleA = jsnums.toFixnum(angleA); sideB = jsnums.toFixnum(sideB); sideC = jsnums.toFixnum(sideC);
|
||||
if (colorDb.get(color)) { color = colorDb.get(color); }
|
||||
if (less(180, angleA)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given angle, side and side will not form a triangle: "
|
||||
+ angleA + ", " + sideB + ", " + sideC, []) );
|
||||
}
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
EXPORTS['triangle/ssa'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/ssa',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var sideA = checkNonNegativeReal(MACHINE, "triangle/ssa", 0);
|
||||
var sideB = checkNonNegativeReal(MACHINE, "triangle/ssa", 1);
|
||||
var angleC = checkAngle(MACHINE, "triangle/ssa", 2);
|
||||
var style = checkMode(MACHINE, "triangle/ssa", 3);
|
||||
var color = checkColor(MACHINE, "triangle/ssa", 4);
|
||||
// cast to fixnums
|
||||
sideA = jsnums.toFixnum(sideA); sideB = jsnums.toFixnum(sideB); angleC = jsnums.toFixnum(angleC);
|
||||
if (less(180, angleC)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given side, side and angle will not form a triangle: "
|
||||
+ sideA + ", " + sideB + ", " + angleC, []) );
|
||||
}
|
||||
var sideC2 = cosRel(sideA, sideB, angleC);
|
||||
var sideC = Math.sqrt(sideC2);
|
||||
|
||||
if (sideC2 <= 0) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given side, side and angle will not form a triangle: "
|
||||
+ sideA + ", " + sideB + ", " + angleC, []) );
|
||||
} else {
|
||||
if (less(sideA + sideB, sideC) ||
|
||||
less(sideC + sideB, sideA) ||
|
||||
less(sideA + sideC, sideB)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given side, side and angle will not form a triangle: "
|
||||
+ sideA + ", " + sideB + ", " + angleC, []) );
|
||||
}
|
||||
}
|
||||
|
||||
var angleA = Math.acos(excess(sideB, sideC, sideA) / (2 * sideB * sideC)) * (180 / Math.PI);
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
EXPORTS['triangle/aas'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/aas',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var angleA = checkAngle(MACHINE, "triangle/aas", 0);
|
||||
var angleB = checkAngle(MACHINE, "triangle/aas", 1);
|
||||
var sideC = checkNonNegativeReal(MACHINE, "triangle/aas", 2);
|
||||
var style = checkMode(MACHINE, "triangle/aas", 3);
|
||||
var color = checkColor(MACHINE, "triangle/aas", 4);
|
||||
// cast to fixnums
|
||||
var angleA = jsnums.toFixnum(angleA); angleB = jsnums.toFixnum(angleB); sideC = jsnums.toFixnum(sideC);
|
||||
var angleC = (180 - angleA - angleB);
|
||||
if (less(angleC, 0)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given angle, angle and side will not form a triangle: "
|
||||
+ angleA + ", " + angleB + ", " + sideC, []) );
|
||||
}
|
||||
var hypotenuse = sideC / (Math.sin(angleC*Math.PI/180))
|
||||
var sideB = hypotenuse * Math.sin(angleB*Math.PI/180);
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
|
||||
EXPORTS['triangle/asa'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/asa',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var angleA = checkAngle(MACHINE, "triangle/asa", 0);
|
||||
var sideB = checkNonNegativeReal(MACHINE, "triangle/asa", 1);
|
||||
var angleC = checkAngle(MACHINE, "triangle/asa", 2);
|
||||
var style = checkMode(MACHINE, "triangle/asa", 3);
|
||||
var color = checkColor(MACHINE, "triangle/asa", 4);
|
||||
// cast to fixnums
|
||||
var angleA = jsnums.toFixnum(angleA); sideB = jsnums.toFixnum(sideB); angleC = jsnums.toFixnum(angleC);
|
||||
var angleB = (180 - angleA - angleC);
|
||||
if (less(angleB, 0)) {
|
||||
raise( types.incompleteExn(types.exnFailContract, "The given angle, side and angle will not form a triangle: "
|
||||
+ angleA + ", " + sideB + ", " + angleC, []) );
|
||||
}
|
||||
var base = (sideB * Math.sin(angleA*Math.PI/180)) / (Math.sin(angleB*Math.PI/180));
|
||||
var sideC = (sideB * Math.sin(angleC*Math.PI/180)) / (Math.sin(angleB*Math.PI/180));
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
EXPORTS['triangle/saa'] =
|
||||
makePrimitiveProcedure(
|
||||
'triangle/saa',
|
||||
5,
|
||||
function(MACHINE) {
|
||||
var sideA = checkNonNegativeReal(MACHINE, "triangle/saa", 0);
|
||||
var angleB = checkAngle(MACHINE, "triangle/saa", 1);
|
||||
var angleC = checkAngle(MACHINE, "triangle/saa", 2);
|
||||
var style = checkMode(MACHINE, "triangle/saa", 3);
|
||||
var color = checkColor(MACHINE, "triangle/saa", 4);
|
||||
// cast to fixnums
|
||||
var sideA = jsnums.toFixnum(sideA); angleB = jsnums.toFixnum(angleB); angleC = jsnums.toFixnum(angleC);
|
||||
var angleA = (180 - angleC - angleB);
|
||||
var hypotenuse = sideA / (Math.sin(angleA*Math.PI/180));
|
||||
var sideC = hypotenuse * Math.sin(angleC*Math.PI/180);
|
||||
var sideB = hypotenuse * Math.sin(angleB*Math.PI/180);
|
||||
return makeTriangleImage(jsnums.toFixnum(sideC),
|
||||
jsnums.toFixnum(angleA),
|
||||
jsnums.toFixnum(sideB),
|
||||
style.toString(),
|
||||
color);
|
||||
});
|
||||
|
||||
|
||||
|
||||
EXPORTS['right-triangle'] =
|
||||
makePrimitiveProcedure(
|
||||
'right-triangle',
|
||||
4,
|
||||
|
@ -896,10 +1206,11 @@ EXPORTS['right-triangle'] =
|
|||
var side2 = checkNonNegativeReal(MACHINE, "right-triangle", 1);
|
||||
var s = checkMode(MACHINE, "right-triangle", 2);
|
||||
var c = checkColor(MACHINE, "right-triangle", 3);
|
||||
return makeRightTriangleImage(jsnums.toFixnum(side1),
|
||||
jsnums.toFixnum(side2),
|
||||
s.toString(),
|
||||
c);
|
||||
return makeTriangleImage(jsnums.toFixnum(side1),
|
||||
jsnums.toFixnum(360-90),
|
||||
jsnums.toFixnum(side2),
|
||||
s.toString(),
|
||||
c);
|
||||
});
|
||||
|
||||
|
||||
|
@ -909,13 +1220,18 @@ EXPORTS['isosceles-triangle'] =
|
|||
4,
|
||||
function(MACHINE) {
|
||||
var side = checkNonNegativeReal(MACHINE, "isosceles-triangle", 0);
|
||||
var angle = checkAngle(MACHINE, "isosceles-triangle", 1);
|
||||
var angleC = checkAngle(MACHINE, "isosceles-triangle", 1);
|
||||
var s = checkMode(MACHINE, "isosceles-triangle", 2);
|
||||
var c = checkColor(MACHINE, "isosceles-triangle", 3);
|
||||
return makeTriangleImage(jsnums.toFixnum(side),
|
||||
jsnums.toFixnum(angle),
|
||||
s.toString(),
|
||||
c);
|
||||
// cast to fixnums
|
||||
side = jsnums.toFixnum(side); angleC = jsnums.toFixnum(angleC);
|
||||
var angleAB = (180-angleC)/2;
|
||||
var base = 2*side*Math.sin((angleC*Math.PI/180)/2);
|
||||
return makeTriangleImage(jsnums.toFixnum(base),
|
||||
jsnums.toFixnum(360-angleAB),// add 180 to make the triangle point up
|
||||
jsnums.toFixnum(side),
|
||||
s.toString(),
|
||||
c);
|
||||
});
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,11 +12,12 @@
|
|||
"js-impl.js")
|
||||
#:provided-values (text
|
||||
text/font
|
||||
|
||||
|
||||
bitmap/url
|
||||
image-url ;; older name for bitmap/url
|
||||
open-image-url ;; older name for bitmap/url
|
||||
|
||||
video/url
|
||||
play-sound
|
||||
overlay
|
||||
overlay/xy
|
||||
overlay/align
|
||||
|
@ -28,6 +29,7 @@
|
|||
above
|
||||
above/align
|
||||
empty-scene
|
||||
put-image
|
||||
place-image
|
||||
place-image/align
|
||||
rotate
|
||||
|
@ -43,9 +45,17 @@
|
|||
circle
|
||||
square
|
||||
rectangle
|
||||
polygon
|
||||
regular-polygon
|
||||
ellipse
|
||||
triangle
|
||||
triangle/sas
|
||||
triangle/sss
|
||||
triangle/ass
|
||||
triangle/ssa
|
||||
triangle/aas
|
||||
triangle/asa
|
||||
triangle/saa
|
||||
right-triangle
|
||||
isosceles-triangle
|
||||
star
|
||||
|
@ -66,6 +76,6 @@
|
|||
side-count?
|
||||
step-count?
|
||||
image?
|
||||
|
||||
image=?
|
||||
name->color
|
||||
))
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
above
|
||||
above/align
|
||||
empty-scene
|
||||
put-image
|
||||
place-image
|
||||
place-image/align
|
||||
rotate
|
||||
|
@ -30,9 +31,17 @@
|
|||
circle
|
||||
square
|
||||
rectangle
|
||||
polygon
|
||||
regular-polygon
|
||||
ellipse
|
||||
triangle
|
||||
triangle/sas
|
||||
triangle/sss
|
||||
triangle/ass
|
||||
triangle/ssa
|
||||
triangle/aas
|
||||
triangle/asa
|
||||
triangle/saa
|
||||
right-triangle
|
||||
isosceles-triangle
|
||||
star
|
||||
|
@ -51,19 +60,22 @@
|
|||
angle?
|
||||
side-count?
|
||||
image?
|
||||
image=?
|
||||
;; Something funky is happening on the Racket side of things with regards
|
||||
;; to step-count? See: http://bugs.racket-lang.org/query/?cmd=view&pr=12031
|
||||
;; step-count?
|
||||
|
||||
|
||||
bitmap/url
|
||||
|
||||
video/url
|
||||
play-sound
|
||||
|
||||
name->color
|
||||
|
||||
|
||||
step-count?
|
||||
image-url
|
||||
open-image-url
|
||||
color-list->bitmap
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
@ -99,6 +111,7 @@
|
|||
above
|
||||
above/align
|
||||
empty-scene
|
||||
put-image
|
||||
place-image
|
||||
place-image/align
|
||||
rotate
|
||||
|
@ -114,9 +127,17 @@
|
|||
circle
|
||||
square
|
||||
rectangle
|
||||
polygon
|
||||
regular-polygon
|
||||
ellipse
|
||||
triangle
|
||||
triangle/sas
|
||||
triangle/sss
|
||||
triangle/ass
|
||||
triangle/ssa
|
||||
triangle/aas
|
||||
triangle/asa
|
||||
triangle/saa
|
||||
right-triangle
|
||||
isosceles-triangle
|
||||
star
|
||||
|
@ -134,12 +155,15 @@
|
|||
y-place?
|
||||
angle?
|
||||
side-count?
|
||||
|
||||
|
||||
image?
|
||||
image=?
|
||||
;; Something funky is happening on the Racket side of things with regards
|
||||
;; to step-count? See: http://bugs.racket-lang.org/query/?cmd=view&pr=12031
|
||||
;; step-count?
|
||||
bitmap/url
|
||||
video/url
|
||||
play-sound
|
||||
name->color
|
||||
step-count?
|
||||
image-url
|
||||
|
@ -149,7 +173,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;(define (my-step-count? x)
|
||||
; (and (integer? x)
|
||||
|
@ -161,9 +185,9 @@
|
|||
|
||||
|
||||
#;(define (name->color n)
|
||||
(error 'name->color "not implemented yet"))
|
||||
(error 'name->color "not implemented yet"))
|
||||
|
||||
|
||||
#;(provide (rename-out [my-step-count? step-count?]
|
||||
[bitmap/url image-url]
|
||||
[bitmap/url open-image-url]))
|
||||
[bitmap/url image-url]
|
||||
[bitmap/url open-image-url]))
|
||||
|
|
897
whalesong/tests/test-images.rkt
Normal file
897
whalesong/tests/test-images.rkt
Normal file
|
@ -0,0 +1,897 @@
|
|||
#lang whalesong
|
||||
|
||||
(require whalesong/world)
|
||||
(require whalesong/image)
|
||||
|
||||
;(play-sound "http://www.html5tutorial.info/media/vincent.mp3" true)
|
||||
|
||||
;; "Checking Empty scene"
|
||||
;; (empty-scene 40 50 "red")
|
||||
"These three circles (red, green, blue) should be left aligned"
|
||||
(above/align "left"
|
||||
(circle 30 "solid" "red")
|
||||
(above/align "left" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
|
||||
"These three circles (red, green, blue) should be right aligned"
|
||||
(above/align "right"
|
||||
(circle 30 "solid" "red")
|
||||
(above/align "right" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
|
||||
"These three circles (red, green, blue) should be middle aligned, vertically"
|
||||
(above/align "middle"
|
||||
(circle 30 "solid" "red")
|
||||
(above/align "middle" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
|
||||
|
||||
"These three circles (red, green, blue) should be top-aligned"
|
||||
(beside/align "top"
|
||||
(circle 30 "solid" "red")
|
||||
(beside/align "top" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
"These three circles (red, green, blue) should be bottom-aligned"
|
||||
(beside/align "bottom"
|
||||
(circle 30 "solid" "red")
|
||||
(beside/align "bottom" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
"These three circles (red, green, blue) should be middle-aligned, horizontally"
|
||||
(beside/align "middle"
|
||||
(circle 30 "solid" "red")
|
||||
(beside/align "middle" (circle 50 'solid 'green) (circle 20 'solid 'blue)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"should be a bar graph"
|
||||
(define (make-stars number)
|
||||
(cond [(eq? number 1) (star 12 "solid" "purple")]
|
||||
[true (beside (star 12 "solid" "purple") (make-stars (- number 1)))] ))
|
||||
(define (bar-graph l1)
|
||||
(cond [(empty? l1) (circle 0 "outline" "blue")]
|
||||
[true (above/align "left" (make-stars (car l1)) (bar-graph (cdr l1)))]))
|
||||
(bar-graph '(1 3 5 3 9 5 3 4 4 3 5 2))
|
||||
|
||||
|
||||
|
||||
(check-expect (image? 'blue) #f)
|
||||
(check-expect (image? (circle 20 "solid" "green")) #t)
|
||||
|
||||
"should be a solid green circle: " (circle 20 "solid" "green")
|
||||
|
||||
"should be an outline turquoise rectangle: " (rectangle 20 30 "outline" "turquoise")
|
||||
|
||||
"should be a solid, mostly-translucent red rectangle: " (rectangle 200 300 10 "red")
|
||||
"should be an outline red rectangle: " (rectangle 200 300 "outline" "red")
|
||||
"should be an *invisible* red rectangle: " (rectangle 200 300 0 "red")
|
||||
|
||||
(define halfred (make-color 255 0 0 128))
|
||||
(define quarterred (make-color 255 0 0 64))
|
||||
"should be a solid red triangle" (triangle 50 "solid" "red")
|
||||
"should be a solid triangle made from a half-transparent red" (triangle 50 "solid" halfred)
|
||||
"should be a solid, half-alpha triangle made from a half-transparent red" (triangle 50 128 halfred)
|
||||
"should be a solid triangle made from a quater-trasparent red" (triangle 50 "solid" quarterred)
|
||||
|
||||
;(check-expect (color? (make-color 3 4 5)))
|
||||
|
||||
(check-expect (color-red (make-color 3 4 5)) 3)
|
||||
(check-expect (color-green (make-color 3 4 5)) 4)
|
||||
(check-expect (color-blue (make-color 3 4 5)) 5)
|
||||
|
||||
(check-expect (image? (empty-scene 20 50)) true)
|
||||
|
||||
(check-expect (image? (place-image (circle 50 'solid 'blue)
|
||||
50
|
||||
50
|
||||
(empty-scene 100 100)))
|
||||
true)
|
||||
|
||||
"should be a blue circle in a scene with a border: " (place-image (circle 50 'solid 'blue)
|
||||
50
|
||||
50
|
||||
(empty-scene 100 100))
|
||||
|
||||
"should be a blue circle in the UR of a scene with a border: " (put-image (circle 50 'solid 'blue)
|
||||
100
|
||||
100
|
||||
(empty-scene 100 100))
|
||||
|
||||
(check-expect (image?
|
||||
(rectangle 20 20 'solid 'green))
|
||||
true)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; TEXT & TEXT/FONT
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"simple text functionality"
|
||||
(text "hello world" 20 'black)
|
||||
(text (string-copy "hello world") 30 'purple)
|
||||
(text "hello world" 40 'red)
|
||||
|
||||
|
||||
"test font-weight"
|
||||
(text/font "Hello" 24 "purple"
|
||||
"Gill Sans" 'swiss 'normal 'bold #f)
|
||||
(text/font "Hello" 24 "green"
|
||||
"Gill Sans" 'swiss 'normal 'light #f)
|
||||
|
||||
"test font-style"
|
||||
(text/font "Goodbye" 48 "indigo"
|
||||
"Helvetica" 'modern 'italic 'normal #f)
|
||||
(text/font "Goodbye" 48 "indigo"
|
||||
"Helvetica" 'modern 'normal 'normal #f)
|
||||
|
||||
"test underline-height calculation"
|
||||
(text/font "test this!" 80 "purple"
|
||||
"Helvetica" 'roman 'normal 'normal #t)
|
||||
|
||||
(text/font "low-hanging glyphs" 36 "blue"
|
||||
"Times" 'roman 'normal 'bold #t)
|
||||
|
||||
(text/font "teeny-tiny text" 8 "black"
|
||||
"Times" 'roman 'normal 'bold #t)
|
||||
|
||||
(text/font "not really a link" 36 "blue"
|
||||
"Courier" 'roman 'italic 'normal #t)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; IMAGE-URL & VIDEO-URL
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"importing images and video"
|
||||
(image-url "http://www.bootstrapworld.org/images/icon.png")
|
||||
(open-image-url "http://www.bootstrapworld.org/images/icon.png")
|
||||
|
||||
;(video/url "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4")
|
||||
#;(overlay (circle 20 "solid" "red")
|
||||
(video/url "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"))
|
||||
#;(rotate 45
|
||||
(video/url "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; OVERLAY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"the next two images should be identical"
|
||||
(overlay (circle 20 "solid" (make-color 50 50 255))
|
||||
(square 40 "solid" (make-color 100 100 255)))
|
||||
|
||||
|
||||
(overlay (circle 20 "solid" (make-color 50 50 255))
|
||||
(regular-polygon 40 4 "solid" (make-color 100 100 255)))
|
||||
|
||||
(overlay (ellipse 10 10 "solid" "red")
|
||||
(ellipse 20 20 "solid" "black")
|
||||
(ellipse 30 30 "solid" "red")
|
||||
(ellipse 40 40 "solid" "black")
|
||||
(ellipse 50 50 "solid" "red")
|
||||
(ellipse 60 60 "solid" "black"))
|
||||
|
||||
"the next two images should be identical"
|
||||
(overlay (square 20 "solid" (make-color 50 50 255))
|
||||
(square 26 "solid" (make-color 100 100 255))
|
||||
(square 32 "solid" (make-color 150 150 255))
|
||||
(square 38 "solid" (make-color 200 200 255))
|
||||
(square 44 "solid" (make-color 250 250 255)))
|
||||
(overlay (regular-polygon 20 4 "solid" (make-color 50 50 255))
|
||||
(regular-polygon 26 4 "solid" (make-color 100 100 255))
|
||||
(regular-polygon 32 4 "solid" (make-color 150 150 255))
|
||||
(regular-polygon 38 4 "solid" (make-color 200 200 255))
|
||||
(regular-polygon 44 4 "solid" (make-color 250 250 255)))
|
||||
|
||||
"overlay with place-image - target should be centered"
|
||||
(place-image (overlay (ellipse 10 10 "solid" "white")
|
||||
(ellipse 20 20 "solid" "black")
|
||||
(ellipse 30 30 "solid" "white")
|
||||
(ellipse 40 40 "solid" "black")
|
||||
(ellipse 50 50 "solid" "white")
|
||||
(ellipse 60 60 "solid" "black"))
|
||||
150 100
|
||||
(rectangle 300 200 "solid" "black"))
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; OVERLAY/XY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"should be some overlay/xys"
|
||||
(overlay/xy (rectangle 20 20 "outline" "black")
|
||||
20 0
|
||||
(rectangle 20 20 "outline" "black"))
|
||||
(overlay/xy (rectangle 20 20 "solid" "red")
|
||||
20 20
|
||||
(rectangle 20 20 "solid" "black"))
|
||||
(overlay/xy (rectangle 20 20 "solid" "red")
|
||||
-20 -20
|
||||
(rectangle 20 20 "solid" "black"))
|
||||
(overlay/xy
|
||||
(overlay/xy (ellipse 40 40 "outline" "black")
|
||||
10
|
||||
15
|
||||
(ellipse 10 10 "solid" "forestgreen"))
|
||||
20
|
||||
15
|
||||
(ellipse 10 10 "solid" "forestgreen"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; OVERLAY/ALIGN
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"some examples of overlay/align"
|
||||
(overlay/align "middle" "middle"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
(overlay/align "right" "top"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
(overlay/align "left" "bottom"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
|
||||
(overlay/align "right" "bottom"
|
||||
(rectangle 20 20 "solid" "silver")
|
||||
(rectangle 30 30 "solid" "seagreen")
|
||||
(rectangle 40 40 "solid" "silver")
|
||||
(rectangle 50 50 "solid" "seagreen"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; UNDERLAY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"some underlays"
|
||||
(underlay (circle 20 'solid 'green)
|
||||
(rectangle 10 20 'solid 'blue))
|
||||
|
||||
(underlay (ellipse 10 60 "solid" "red")
|
||||
(ellipse 20 50 "solid" "black")
|
||||
(ellipse 30 40 "solid" "red")
|
||||
(ellipse 40 30 "solid" "black")
|
||||
(ellipse 50 20 "solid" "red")
|
||||
(ellipse 60 10 "solid" "black"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; UNDERLAY/XY & UNDERLAY/ALIGN
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"examples of underlay and underlay/align"
|
||||
(underlay/xy (circle 20 'solid 'green)
|
||||
30 10
|
||||
(rectangle 10 20 'solid 'blue))
|
||||
|
||||
|
||||
|
||||
;; color list
|
||||
"the following should be a blue circle, but by using color-list->image"
|
||||
(let ([circle-color-list (image->color-list (circle 20 'solid 'blue))])
|
||||
;; fixme: add tests for number of colors
|
||||
(color-list->image circle-color-list 40 40 0 0))
|
||||
|
||||
|
||||
|
||||
|
||||
(underlay/align "middle" "middle"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
(underlay/align "right" "top"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
(underlay/align "left" "bottom"
|
||||
(ellipse 60 30 "solid" "purple")
|
||||
(rectangle 30 60 "solid" "orange"))
|
||||
|
||||
(underlay/align "right" "bottom"
|
||||
(rectangle 50 50 "solid" "silver")
|
||||
(rectangle 40 40 "solid" "seagreen")
|
||||
(rectangle 30 30 "solid" "silver")
|
||||
(rectangle 20 20 "solid" "seagreen"))
|
||||
|
||||
"This is issue 40 https://github.com/dyoo/WeScheme/issues/40"
|
||||
(underlay/align "left" "middle"
|
||||
(rectangle 30 60 "solid" "orange")
|
||||
(ellipse 60 30 "solid" "purple"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; BESIDE & BESIDE/ALIGN
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"examples of beside and beside/align"
|
||||
(beside (ellipse 20 70 "solid" "gray")
|
||||
(ellipse 20 50 "solid" "darkgray")
|
||||
(ellipse 20 30 "solid" "dimgray")
|
||||
(ellipse 20 10 "solid" "black"))
|
||||
|
||||
(beside/align "bottom"
|
||||
(ellipse 20 70 "solid" "lightsteelblue")
|
||||
(ellipse 20 50 "solid" "mediumslateblue")
|
||||
(ellipse 20 30 "solid" "slateblue")
|
||||
(ellipse 20 10 "solid" "navy"))
|
||||
|
||||
(beside/align "top"
|
||||
(ellipse 20 70 "solid" "mediumorchid")
|
||||
(ellipse 20 50 "solid" "darkorchid")
|
||||
(ellipse 20 30 "solid" "purple")
|
||||
(ellipse 20 10 "solid" "indigo"))
|
||||
|
||||
"align these text images on their baselines"
|
||||
(beside/align "baseline"
|
||||
(text "ijy" 18 "black")
|
||||
(text "ijy" 24 "black"))
|
||||
|
||||
|
||||
"issue 25 https://github.com/dyoo/WeScheme/issues/25"
|
||||
(beside/align "top"
|
||||
(rectangle 20 100 "solid" "black")
|
||||
(rectangle 20 120 "solid" "black")
|
||||
(rectangle 20 80 "solid" "black"))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ABOVE & ABOVE/ALIGN
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"should be some examples of above and above/align"
|
||||
(above (ellipse 70 20 "solid" "gray")
|
||||
(ellipse 50 20 "solid" "darkgray")
|
||||
(ellipse 30 20 "solid" "dimgray")
|
||||
(ellipse 10 20 "solid" "black"))
|
||||
|
||||
(above/align "right"
|
||||
(ellipse 70 20 "solid" "gold")
|
||||
(ellipse 50 20 "solid" "goldenrod")
|
||||
(ellipse 30 20 "solid" "darkgoldenrod")
|
||||
(ellipse 10 20 "solid" "sienna"))
|
||||
(above/align "left"
|
||||
(ellipse 70 20 "solid" "yellowgreen")
|
||||
(ellipse 50 20 "solid" "olivedrab")
|
||||
(ellipse 30 20 "solid" "darkolivegreen")
|
||||
(ellipse 10 20 "solid" "darkgreen"))
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; PLACE-IMAGE/ALIGN
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"should be right in the center"
|
||||
(place-image/align (circle 16 "solid" "yellow")
|
||||
32 32 "center" "center"
|
||||
(rectangle 64 64 "solid" "goldenrod"))
|
||||
|
||||
"should be at the bottom-right corner"
|
||||
(place-image/align (circle 16 "solid" "yellow")
|
||||
32 32 "left" "top"
|
||||
(rectangle 64 64 "solid" "goldenrod"))
|
||||
|
||||
"should be at the upper-left corner"
|
||||
(place-image/align (circle 16 "solid" "yellow")
|
||||
32 32 "right" "bottom"
|
||||
(rectangle 64 64 "solid" "goldenrod"))
|
||||
|
||||
"test 'beside' with scenes -- from the DrRacket documentation"
|
||||
(beside (place-image/align (circle 8 "solid" "tomato")
|
||||
0 0 "center" "center"
|
||||
(rectangle 32 32 "outline" "black"))
|
||||
(place-image/align (circle 8 "solid" "tomato")
|
||||
8 8 "center" "center"
|
||||
(rectangle 32 32 "outline" "black"))
|
||||
(place-image/align (circle 8 "solid" "tomato")
|
||||
16 16 "center" "center"
|
||||
(rectangle 32 32 "outline" "black"))
|
||||
(place-image/align (circle 8 "solid" "tomato")
|
||||
24 24 "center" "center"
|
||||
(rectangle 32 32 "outline" "black"))
|
||||
(place-image/align (circle 8 "solid" "tomato")
|
||||
32 32 "center" "center"
|
||||
(rectangle 32 32 "outline" "black")))
|
||||
|
||||
"some overlay and place-image stress tests"
|
||||
(define flag2
|
||||
(place-image
|
||||
(rotate 90
|
||||
(underlay/align
|
||||
"center" "center"
|
||||
(rectangle 50 450 "solid" "white")
|
||||
(rotate 90
|
||||
(rectangle 50 450 "solid" "white"))
|
||||
(rotate 90
|
||||
(rectangle 30 450 "solid" "red"))
|
||||
(rotate 180
|
||||
(rectangle 30 450 "solid" "red"))))
|
||||
|
||||
200 100
|
||||
(place-image
|
||||
(rotate 65
|
||||
(underlay/align
|
||||
"center" "center"
|
||||
(rectangle 15 450 "solid" "red")
|
||||
(rotate 50
|
||||
(rectangle 15 450 "solid" "red"))))
|
||||
200 100
|
||||
(place-image
|
||||
(rotate 65
|
||||
(underlay/align
|
||||
"center" "center"
|
||||
(rectangle 40 450 "solid" "white")
|
||||
(rotate 50
|
||||
(rectangle 40 450 "solid" "white"))))
|
||||
200 100
|
||||
(rectangle 400 200 "solid" "navy")))))
|
||||
|
||||
|
||||
(define Australia2
|
||||
(place-image
|
||||
flag2
|
||||
200 100
|
||||
(place-image
|
||||
(star-polygon 30 7 3 "solid" "white")
|
||||
650 60
|
||||
(place-image
|
||||
(star-polygon 50 7 3 "solid" "white")
|
||||
200 300
|
||||
(place-image
|
||||
(star-polygon 40 7 3 "solid" "white")
|
||||
60 20
|
||||
(place-image
|
||||
(star-polygon 40 7 3 "solid" "white")
|
||||
68 124
|
||||
(rectangle 900 400 "solid" "navy")))))))
|
||||
flag2
|
||||
Australia2
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; TRIANGLE, RIGHT TRIANGLE & ISOSCELES-TRIANGLE
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Three triangles of various sizes and fills"
|
||||
(triangle 36 "solid" "darkslategray")
|
||||
(triangle 4 "solid" "purple")
|
||||
(triangle 30 "outline" "cornflowerblue")
|
||||
|
||||
"Triangles side by side"
|
||||
(beside (triangle 36 "solid" "darkslategray")
|
||||
(triangle 30 "solid" "cornflowerblue"))
|
||||
|
||||
"Triangles above."
|
||||
(above (triangle 36 "solid" "darkslategray")
|
||||
(triangle 30 "solid" "cornflowerblue"))
|
||||
|
||||
"Three right triangles of various sizes and fills"
|
||||
(right-triangle 36 48 "solid" "darkslategray")
|
||||
(right-triangle 4 60 "solid" "purple")
|
||||
(right-triangle 30 40 "solid" "cornflowerblue")
|
||||
|
||||
"Three isosceles triangles of various sizes and fills"
|
||||
|
||||
(isosceles-triangle 60 30 "solid" "aquamarine")
|
||||
(isosceles-triangle 200 170 "outline" "seagreen")
|
||||
(isosceles-triangle 60 330 "solid" "lightseagreen")
|
||||
|
||||
"Trying ASA triangle (30 40 60)"
|
||||
(triangle/asa 30 40 60 "solid" "blue")
|
||||
|
||||
"Trying AAS triangle (30 60 40)"
|
||||
(triangle/aas 30 60 40 "outline" "green")
|
||||
|
||||
"Trying SAA triangle (100 30 90)"
|
||||
(triangle/saa 100 30 90 "solid" "red")
|
||||
|
||||
"Trying SSA triangle (60 60 40)"
|
||||
(triangle/ass 60 60 40 "outline" "turquoise")
|
||||
|
||||
"Trying ASS triangle (60 80 90)"
|
||||
(triangle/ass 60 80 90 "solid" "maroon")
|
||||
|
||||
"Trying SSS triangle (60 60 60)"
|
||||
(triangle/sss 60 60 60 "outline" "red")
|
||||
|
||||
"Trying SAS triangle (60 30 60)"
|
||||
(triangle/sas 60 30 60 "solid" "brown")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; STAR, RADIAL-STAR & STAR-POLYGON
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"old star implementation"
|
||||
|
||||
(star 5 8 4 "solid" "darkslategray")
|
||||
(star 5 30 15 "outline" "black")
|
||||
(star 5 20 10 "solid" "red")
|
||||
|
||||
"new star implementation"
|
||||
(star 8 "solid" "darkslategray")
|
||||
(star 30 "outline" "black")
|
||||
(star 20 "solid" "red")
|
||||
|
||||
"radial star"
|
||||
(radial-star 8 8 64 "solid" "darkslategray")
|
||||
(radial-star 32 30 40 "outline" "black")
|
||||
(radial-star 5 20 40 "solid" "red")
|
||||
|
||||
"star-polygon"
|
||||
(star-polygon 40 5 2 "solid" "seagreen")
|
||||
(star-polygon 40 7 3 "outline" "darkred")
|
||||
(star-polygon 20 10 3 "solid" "cornflowerblue")
|
||||
"should look like a pentagon"
|
||||
(star-polygon 20 5 1 "solid" "darkblue")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SQUARE
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Three squares of various sizes and fills"
|
||||
(square 60 "outline" "black")
|
||||
(square 200 "solid" "seagreen")
|
||||
(square 100 "outline" "blue")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; RHOMBUS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Three rhombuses of various sizes and fills"
|
||||
(rhombus 40 45 "solid" "magenta")
|
||||
(rhombus 100 200 "solid" "orange")
|
||||
(rhombus 80 330 "outline" "seagreen")
|
||||
|
||||
"rhombuses beside each other"
|
||||
(beside (rhombus 40 45 "solid" "magenta")
|
||||
(rhombus 100 200 "solid" "orange")
|
||||
(rhombus 80 330 "outline" "seagreen"))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; REGULAR-POLYGON
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Some regular polygons..."
|
||||
"A triangle of side-length 20: should be 20x17"
|
||||
(regular-polygon 20 3 "solid" "purple")
|
||||
"A square of side-length 40: should be 40x40"
|
||||
(regular-polygon 40 4 "solid" "aquamarine")
|
||||
"A pentagon of side-length 30: should be 49x46"
|
||||
(regular-polygon 30 5 "solid" "pink")
|
||||
"A hexagon of side-length 20: should be 40x35"
|
||||
(regular-polygon 20 6 "solid" "gold")
|
||||
"A septagon of side-length 40: should be 90x88"
|
||||
(regular-polygon 40 7 "solid" "goldenrod")
|
||||
"An octagon of side-length 30: should be 72x72"
|
||||
(regular-polygon 30 8 "solid" "darkgoldenrod")
|
||||
"A nonagon of side-length 20: should be 58x57"
|
||||
(regular-polygon 20 9 "solid" "sienna")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; POLYGON
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Some polygons defined with posns..."
|
||||
#;(polygon (list (make-posn 0 0)
|
||||
(make-posn -10 20)
|
||||
(make-posn 60 0)
|
||||
(make-posn -10 -20))
|
||||
"solid"
|
||||
"burlywood")
|
||||
|
||||
#;(polygon (list (make-posn 0 0)
|
||||
(make-posn 0 40)
|
||||
(make-posn 20 40)
|
||||
(make-posn 20 60)
|
||||
(make-posn 40 60)
|
||||
(make-posn 40 20)
|
||||
(make-posn 20 20)
|
||||
(make-posn 20 0))
|
||||
"solid"
|
||||
"plum")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ROTATE
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Three images at 30, 60, 90 degree rotation:"
|
||||
(rotate 30 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
(rotate 60 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
(rotate 90 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
|
||||
"Rotated, huge image"
|
||||
(rotate 30 (scale 3 (image-url "http://www.bootstrapworld.org/images/icon.png")))
|
||||
|
||||
"From the Racket documentation:"
|
||||
(rotate 45 (ellipse 60 20 "solid" "olivedrab"))
|
||||
(rotate 5 (rectangle 50 50 "outline" "black"))
|
||||
"unrotated T"
|
||||
(beside/align
|
||||
"center"
|
||||
(rectangle 40 20 "solid" "darkseagreen")
|
||||
(rectangle 20 100 "solid" "darkseagreen"))
|
||||
"rotate 45 degrees"
|
||||
(rotate 45
|
||||
(beside/align
|
||||
"center"
|
||||
(rectangle 40 20 "solid" "darkseagreen")
|
||||
(rectangle 20 100 "solid" "darkseagreen")))
|
||||
|
||||
(beside
|
||||
(rotate 30 (square 50 "solid" "red"))
|
||||
(flip-horizontal
|
||||
(rotate 30 (square 50 "solid" "blue"))))
|
||||
|
||||
"A solid blue triangle, rotated 30 degrees. Should be flush left"
|
||||
(rotate 30 (triangle 100 "solid" "blue"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SCALE & SCALE/XY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"scaling small and large"
|
||||
(scale 1/2 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
(scale 2 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
|
||||
(scale/xy 1 2 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
(scale/xy 2 1 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
|
||||
"This should be the normal image"
|
||||
(scale/xy 1 1 (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
|
||||
"From the Racket documentation: two identical ellipses, and a circle"
|
||||
(scale 2 (ellipse 20 30 "solid" "blue"))
|
||||
(ellipse 40 60 "solid" "blue")
|
||||
(scale/xy 3
|
||||
2
|
||||
(ellipse 20 30 "solid" "blue"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; FRAME AND CROP
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"frame and crop examples from DrRacket documentation"
|
||||
(frame (ellipse 20 20 "outline" "black"))
|
||||
|
||||
(beside
|
||||
(ellipse 20 70 "solid" "lightsteelblue")
|
||||
(frame (ellipse 20 50 "solid" "mediumslateblue"))
|
||||
(ellipse 20 30 "solid" "slateblue")
|
||||
(ellipse 20 10 "solid" "navy"))
|
||||
|
||||
(crop 0 0 40 40 (circle 40 "solid" "chocolate"))
|
||||
(crop 40 60 40 60 (ellipse 80 120 "solid" "dodgerblue"))
|
||||
(above
|
||||
(beside (crop 40 40 40 40 (circle 40 "solid" "palevioletred"))
|
||||
(crop 0 40 40 40 (circle 40 "solid" "lightcoral")))
|
||||
(beside (crop 40 0 40 40 (circle 40 "solid" "lightcoral"))
|
||||
(crop 0 0 40 40 (circle 40 "solid" "palevioletred"))))
|
||||
|
||||
"should be a quarter of a circle, inscribed in a square"
|
||||
(place-image
|
||||
(crop 0 0 20 20 (circle 20 "solid" "Magenta"))
|
||||
10 10
|
||||
(rectangle 40 40 "solid" "blue"))
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; LINE, ADD-LINE & SCENE+LINE
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"Three tests for line"
|
||||
(line 30 30 "black")
|
||||
|
||||
(line -30 20 "red")
|
||||
|
||||
(line 30 -20 "red")
|
||||
|
||||
"Three tests for add-line"
|
||||
(add-line (ellipse 40 40 "outline" "maroon")
|
||||
0 40 40 0 "maroon")
|
||||
|
||||
(add-line (rectangle 40 40 "solid" "gray")
|
||||
-10 50 50 -10 "maroon")
|
||||
|
||||
(add-line
|
||||
(rectangle 100 100 "solid" "darkolivegreen")
|
||||
25 25 100 100
|
||||
"goldenrod")
|
||||
|
||||
"Three tests for scene+line: should be identical to above, but cropped around base image"
|
||||
(scene+line (ellipse 40 40 "outline" "maroon")
|
||||
0 40 40 0 "maroon")
|
||||
|
||||
(scene+line (rectangle 40 40 "solid" "gray")
|
||||
-10 50 50 -10 "maroon")
|
||||
|
||||
(scene+line
|
||||
(rectangle 100 100 "solid" "darkolivegreen")
|
||||
25 25 100 100
|
||||
"goldenrod")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; FLIP-VERTICAL & FLIP-HORIZONTAL
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"a red triangle, a blue one flippled horizontally and a green one flippled vertically"
|
||||
(right-triangle 30 40 "solid" "red")
|
||||
(flip-horizontal (right-triangle 30 40 "solid" "blue"))
|
||||
(flip-vertical (right-triangle 30 40 "solid" "green"))
|
||||
|
||||
"those three triangles beside each other"
|
||||
(beside (right-triangle 30 40 "solid" "red")
|
||||
(flip-horizontal (right-triangle 30 40 "solid" "blue"))
|
||||
(flip-vertical (right-triangle 30 40 "solid" "green")))
|
||||
|
||||
|
||||
|
||||
"one image flipped vertically, and one flipped horizontally"
|
||||
(flip-vertical (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
(flip-horizontal (image-url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
|
||||
"BESIDE: reference image"
|
||||
(beside (square 20 "solid" (make-color 50 50 255))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
"flip the second one horizontally"
|
||||
(beside (square 20 "solid" (make-color 50 50 255))
|
||||
(flip-horizontal (square 34 "solid" (make-color 150 150 255))))
|
||||
|
||||
"flip the second one vertically"
|
||||
(beside (square 20 "solid" (make-color 50 50 255))
|
||||
(flip-vertical (square 34 "solid" (make-color 150 150 255))))
|
||||
|
||||
"flip the first one horizontally"
|
||||
(beside (flip-horizontal (square 20 "solid" (make-color 50 50 255)))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
"flip the first one vertically"
|
||||
(beside (flip-vertical (square 20 "solid" (make-color 50 50 255)))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
"ABOVE: reference image"
|
||||
(above (square 20 "solid" (make-color 50 50 255))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
"flip the second one horizontally"
|
||||
(above (square 20 "solid" (make-color 50 50 255))
|
||||
(flip-horizontal (square 34 "solid" (make-color 150 150 255))))
|
||||
|
||||
"flip the second one vertically"
|
||||
(above (square 20 "solid" (make-color 50 50 255))
|
||||
(flip-vertical (square 34 "solid" (make-color 150 150 255))))
|
||||
|
||||
"flip the first one horizontally"
|
||||
(above (flip-horizontal (square 20 "solid" (make-color 50 50 255)))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
"flip the first one vertically"
|
||||
(above (flip-vertical (square 20 "solid" (make-color 50 50 255)))
|
||||
(square 34 "solid" (make-color 150 150 255)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; IMAGE EQUALITY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"checking a circle against a rectangle"
|
||||
(check-expect (image=? (circle 50 "solid" "blue")
|
||||
(rectangle 20 30 "outline" "turquoise"))
|
||||
#f)
|
||||
(check-expect (image=? (empty-scene 20 50) (empty-scene 20 50)) true)
|
||||
|
||||
"checking a circle against a different one"
|
||||
(check-expect (image=? (circle 50 "solid" "blue")
|
||||
(circle 50 "solid" "turquoise"))
|
||||
#f)
|
||||
|
||||
"checking a triangle against a different one"
|
||||
(check-expect (image=? (triangle 50 "solid" "blue")
|
||||
(triangle 50 "outline" "blue"))
|
||||
#f)
|
||||
|
||||
"checking a circle against a different one"
|
||||
(check-expect (image=? (circle 50 "solid" "blue")
|
||||
(circle 50 "solid" "turquoise"))
|
||||
#f)
|
||||
|
||||
"checking a textImage against a different one"
|
||||
(check-expect (image=? (text "purple" 50 "blue")
|
||||
(text "purple" 50 "red"))
|
||||
#f)
|
||||
|
||||
"checking a textImage against itself"
|
||||
(check-expect (image=? (text "purple" 50 "blue")
|
||||
(text "purple" 50 "blue"))
|
||||
#t)
|
||||
|
||||
"checking a bitmap against itself"
|
||||
(check-expect (image=? (bitmap/url "http://www.bootstrapworld.org/images/icon.gif")
|
||||
(bitmap/url "http://www.bootstrapworld.org/images/icon.gif"))
|
||||
#t)
|
||||
|
||||
"checking a bitmap against a shape of the same size"
|
||||
(check-expect (image=? (bitmap/url "http://www.bootstrapworld.org/images/icon.gif")
|
||||
(rectangle 150 150 "solid" "pink"))
|
||||
#f)
|
||||
|
||||
"checking a bitmap against a shape of a different size"
|
||||
(check-expect (image=? (bitmap/url "http://www.bootstrapworld.org/images/icon.gif")
|
||||
(rectangle 100 100 "solid" "pink"))
|
||||
#f)
|
||||
|
||||
"checking a bitmap against a different one"
|
||||
(check-expect (image=? (bitmap/url "http://www.bootstrapworld.org/images/icon.gif")
|
||||
(bitmap/url "http://www.bootstrapworld.org/images/icon.png"))
|
||||
#f)
|
||||
|
||||
"checking a rectangle against itself"
|
||||
(check-expect (image=? (rectangle 100 50 "solid" "blue")
|
||||
(rectangle 100 50 "solid" "blue"))
|
||||
#t)
|
||||
|
||||
"checking a rhombus against itself"
|
||||
(check-expect (image=? (rhombus 100 50 "solid" "blue")
|
||||
(rhombus 100 50 "solid" "blue"))
|
||||
#t)
|
||||
|
||||
"checking a square against a 2x larger one that's been scaled by 1/2"
|
||||
(check-expect (image=? (scale 1/2 (square 100 "solid" "blue"))
|
||||
(square 50 "solid" "blue"))
|
||||
#t)
|
||||
|
||||
"checking a square against a 2x larger one that's been scaled by 1/3"
|
||||
(check-expect (image=? (scale 1/3 (square 100 "solid" "blue"))
|
||||
(square 50 "solid" "blue"))
|
||||
#f)
|
||||
|
||||
"checking a rectangle against its equivalent polygon"
|
||||
(check-expect (image=? (regular-polygon 40 4 "solid" "black")
|
||||
(rectangle 40 40 "solid" "black"))
|
||||
#t)
|
||||
|
||||
"checking a circle against its equivalent ellipse"
|
||||
(check-expect (image=? (circle 50 90 "orange")
|
||||
(ellipse 100 100 90 "orange"))
|
||||
#t)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; IMAGE PROPERTIES
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
"(image-width (ellipse 30 40 'solid' 'orange'))"
|
||||
(image-width (ellipse 30 40 "solid" "orange"))
|
||||
|
||||
"(image-width (circle 30 'solid' 'orange'))"
|
||||
(image-width (circle 30 "solid" "orange"))
|
||||
|
||||
"(image-width (beside (circle 20 'solid' 'orange') (circle 20 'solid' 'purple')))"
|
||||
(image-width (beside (circle 20 "solid" "orange") (circle 20 "solid" "purple")))
|
||||
|
||||
"(image-height (overlay (circle 20 'solid' 'orange') (circle 30 'solid' 'purple')))"
|
||||
(image-height (overlay (circle 20 "solid" "orange") (circle 30 "solid" "purple")))
|
||||
|
||||
"(image-height (rectangle 10 0 'solid' 'purple'))"
|
||||
(image-height (rectangle 10 0 "solid" "purple"))
|
||||
|
||||
"(image-baseline (text 'Hello' 24 'black'))"
|
||||
(image-baseline (text "Hello" 24 "black"))
|
||||
|
||||
"(image-baseline (text/font 'Goodbye' 48 'indigo' 'Helvetica' 'modern 'normal 'normal #f))"
|
||||
(image-baseline (text/font "Goodbye" 48 "indigo" "Helvetica" 'modern 'normal 'normal #f))
|
||||
|
||||
|
||||
"(image-height (text/font 'Goodbye' 48 'indigo' 'Helvetica' 'modern 'normal 'normal #f))"
|
||||
(image-height (text/font "Goodbye" 48 "indigo" "Helvetica" 'modern 'normal 'normal #f))
|
||||
|
||||
"(image-baseline (rectangle 100 100 'solid' 'black'))"
|
||||
(image-baseline (rectangle 100 100 "solid" "black"))
|
||||
|
||||
"(image-height (rectangle 100 100 'solid' 'black'))"
|
||||
(image-height (rectangle 100 100 "solid" "black"))
|
||||
|
||||
|
||||
"(mode? 'outline')"
|
||||
(mode? "outline")
|
||||
|
||||
"(mode? 'checkered')"
|
||||
(mode? "checkered")
|
||||
|
||||
"(image-color? 'pink')"
|
||||
(image-color? "pink")
|
||||
|
||||
"(image-color? 'puke')"
|
||||
(image-color? "puke")
|
||||
|
||||
"(y-place? 'middle')"
|
||||
(y-place? "middle")
|
||||
|
||||
"(x-place? 'up-top')"
|
||||
(x-place? "up-top")
|
||||
|
||||
"(angle? 290)"
|
||||
(angle? 290)
|
||||
|
||||
"(angle? -290)"
|
||||
(angle? -290)
|
||||
|
||||
"(side-count? 20)"
|
||||
(side-count? 20)
|
||||
|
||||
"(side-count? 2)"
|
||||
(side-count? 2)
|
||||
|
||||
"(step-count? 2)"
|
||||
(step-count? 2)
|
||||
|
||||
"(step-count? 0)"
|
||||
(step-count? 0)
|
Loading…
Reference in New Issue
Block a user