@ironm00n/pyret-lang 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -797,6 +797,8 @@
797
797
  this.imageData= imageData;
798
798
  this.width = imageData.width;
799
799
  this.height = imageData.height;
800
+ this.pinholeX = this.width / 2;
801
+ this.pinholeY = this.height / 2;
800
802
  };
801
803
 
802
804
  ImageDataImage.prototype = heir(BaseImage.prototype);
@@ -890,14 +892,14 @@
890
892
  switch(placeX1.toLowerCase()) {
891
893
  case "left": x1 -= 0; anchor1 = "-left"; break;
892
894
  case "middle": x1 -= img1.width / 2; anchor1 = "-middle"; break;
893
- case "pinhole": x1 -= img1.pinholeX; anchor1 = "-pinhole"; break;
895
+ case "pinhole": x1 -= img1.getPinholeX(); anchor1 = "-pinhole"; break;
894
896
  case "right": x1 -= img1.width; anchor1 = "-right"; break;
895
897
  default: throw new Error("Unknown XPlace option for image 1: " + placeX1);
896
898
  }
897
899
  switch(placeY1.toLowerCase()) {
898
900
  case "top": y1 -= 0; anchor1 = "top" + anchor1; break;
899
901
  case "center": y1 -= img1.height / 2; anchor1 = "center" + anchor1; break;
900
- case "pinhole": y1 -= img1.pinholeY; anchor1 = "pinhole" + anchor1; break;
902
+ case "pinhole": y1 -= img1.getPinholeY(); anchor1 = "pinhole" + anchor1; break;
901
903
  case "baseline": y1 -= img1.getBaseline(); anchor1 = "baseline" + anchor1; break;
902
904
  case "bottom": y1 -= img1.height; anchor1 = "bottom" + anchor1; break;
903
905
  default: throw new Error("Unknown YPlace option for image 1: " + placeY1);
@@ -905,14 +907,14 @@
905
907
  switch(placeX2.toLowerCase()) {
906
908
  case "left": x2 -= 0; anchor2 = "-left"; break;
907
909
  case "middle": x2 -= img2.width / 2; anchor2 = "-middle"; break;
908
- case "pinhole": x2 -= img2.pinholeX; anchor2 = "-pinhole"; break;
910
+ case "pinhole": x2 -= img2.getPinholeX(); anchor2 = "-pinhole"; break;
909
911
  case "right": x2 -= img2.width; anchor2 = "-right"; break;
910
912
  default: throw new Error("Unknown XPlace option for image 2: " + placeX2);
911
913
  }
912
914
  switch(placeY2.toLowerCase()) {
913
915
  case "top": y2 -= 0; anchor2 = "top" + anchor2; break;
914
916
  case "center": y2 -= img2.height / 2; anchor2 = "center" + anchor2; break;
915
- case "pinhole": y2 -= img2.pinholeY; anchor2 = "pinhole" + anchor2; break;
917
+ case "pinhole": y2 -= img2.getPinholeY(); anchor2 = "pinhole" + anchor2; break;
916
918
  case "baseline": y2 -= img2.getBaseline(); anchor2 = "baseline" + anchor2; break;
917
919
  case "bottom": y2 -= img2.height; anchor2 = "bottom" + anchor2; break;
918
920
  default: throw new Error("Unknown YPlace option for image 2: " + placeY2);
@@ -949,8 +951,8 @@
949
951
  this.y2 = y2;
950
952
  this.img1 = img1;
951
953
  this.img2 = img2;
952
- this.pinholeX = img1.pinholeX + x1;
953
- this.pinholeY = img1.pinholeY + y1;
954
+ this.pinholeX = img1.getPinholeX() + x1;
955
+ this.pinholeY = img1.getPinholeY() + y1;
954
956
  this.alphaBaseline = img1.alphaBaseline ? img1.getBaseline() + y1 : img2.getBaseline() + y2;
955
957
  // console.log("Baseline1: " + img1.alphaBaseline + ", Baseline2: " + img2.alphaBaseline + " ==> " + this.alphaBaseline);
956
958
  var shiftText = "";
@@ -1022,8 +1024,8 @@
1022
1024
  this.angle = Math.round(angle);
1023
1025
  this.translateX = translate.x;
1024
1026
  this.translateY = translate.y;
1025
- this.pinholeX = img.pinholeX*cos - img.pinholeY*sin + translate.x;
1026
- this.pinholeY = img.pinholeX*sin + img.pinholeY*cos + translate.y;
1027
+ this.pinholeX = img.getPinholeX()*cos - img.getPinholeY()*sin + translate.x;
1028
+ this.pinholeY = img.getPinholeX()*sin + img.getPinholeY()*cos + translate.y;
1027
1029
  this.ariaText = "Rotated image, "+(-1 * angle)+" degrees: "+img.ariaText;
1028
1030
  };
1029
1031
 
@@ -1045,8 +1047,8 @@
1045
1047
  this.width === other.width &&
1046
1048
  this.height === other.height &&
1047
1049
  this.angle === other.angle &&
1048
- this.pinholeX === other.pinholeX &&
1049
- this.pinholeY === other.pinholeX &&
1050
+ this.getPinholeX() === other.getPinholeX() &&
1051
+ this.getPinholeY() === other.getPinholeY() &&
1050
1052
  imageEquals(this.img, other.img) )
1051
1053
  || BaseImage.prototype.equals.call(this, other);
1052
1054
  };
@@ -1066,12 +1068,12 @@
1066
1068
  this.height = img.height * Math.abs(yFactor);
1067
1069
  this.xFactor = xFactor;
1068
1070
  this.yFactor = yFactor;
1069
- this.pinholeX = img.pinholeX * xFactor;
1071
+ this.pinholeX = img.getPinholeX() * xFactor;
1070
1072
  if (xFactor < 0) { // translate pinhole into image region
1071
1073
  this.pinholeX += this.width;
1072
1074
  this._vertices.forEach((v) => v.x += this.width);
1073
1075
  }
1074
- this.pinholeY = img.pinholeY * yFactor;
1076
+ this.pinholeY = img.getPinholeY() * yFactor;
1075
1077
  if (yFactor < 0) { // translate pinhole into image region
1076
1078
  this.pinholeY += this.height;
1077
1079
  this._vertices.forEach((v) => v.y += this.height);
@@ -1118,10 +1120,10 @@
1118
1120
  this.width = width;
1119
1121
  this.height = height;
1120
1122
  this.img = img;
1121
- if (img.pinholeX >= x && img.pinholeX <= x + width &&
1122
- img.pinholeY >= y && img.pinholeY <= y + height) {
1123
- this.pinholeX = img.pinholeX - x;
1124
- this.pinholeY = img.pinholeY - y;
1123
+ if (img.getPinholeX() >= x && img.getPinholeX() <= x + width &&
1124
+ img.getPinholeY() >= y && img.getPinholeY() <= y + height) {
1125
+ this.pinholeX = img.getPinholeX() - x;
1126
+ this.pinholeY = img.getPinholeY() - y;
1125
1127
  } else {
1126
1128
  this.pinholeX = width / 2;
1127
1129
  this.pinholeY = height / 2;
@@ -1159,8 +1161,8 @@
1159
1161
  this.img = img;
1160
1162
  this.width = img.width;
1161
1163
  this.height = img.height;
1162
- this.pinholeX = img.pinholeX;
1163
- this.pinholeY = img.pinholeY;
1164
+ this.pinholeX = img.getPinholeX();
1165
+ this.pinholeY = img.getPinholeY();
1164
1166
  this.ariaText = " Framed image: "+img.ariaText;
1165
1167
  this.alphaBaseline = img.alphaBaseline;
1166
1168
  };
@@ -1192,8 +1194,8 @@
1192
1194
  this.img = img;
1193
1195
  this.width = img.width;
1194
1196
  this.height = img.height;
1195
- this.pinholeX = img.pinholeX;
1196
- this.pinholeY = img.pinholeY;
1197
+ this.pinholeX = img.getPinholeX();
1198
+ this.pinholeY = img.getPinholeY();
1197
1199
  this.ariaText = " Pinhole image: "+img.ariaText;
1198
1200
  };
1199
1201
 
@@ -1207,18 +1209,18 @@
1207
1209
  ctx.restore();
1208
1210
  ctx.beginPath();
1209
1211
  ctx.strokeStyle = "black"; ctx.lineWidth = 1.5;
1210
- ctx.moveTo(this.pinholeX - 5, this.pinholeY);
1211
- ctx.lineTo(this.pinholeX + 5, this.pinholeY);
1212
- ctx.moveTo(this.pinholeX, this.pinholeY - 5);
1213
- ctx.lineTo(this.pinholeX, this.pinholeY + 5);
1212
+ ctx.moveTo(this.getPinholeX() - 5, this.getPinholeY());
1213
+ ctx.lineTo(this.getPinholeX() + 5, this.getPinholeY());
1214
+ ctx.moveTo(this.getPinholeX(), this.getPinholeY() - 5);
1215
+ ctx.lineTo(this.getPinholeX(), this.getPinholeY() + 5);
1214
1216
  ctx.closePath();
1215
1217
  ctx.stroke();
1216
1218
  ctx.beginPath();
1217
1219
  ctx.strokeStyle = "white"; ctx.lineWidth = 0.75;
1218
- ctx.moveTo(this.pinholeX - 5, this.pinholeY);
1219
- ctx.lineTo(this.pinholeX + 5, this.pinholeY);
1220
- ctx.moveTo(this.pinholeX, this.pinholeY - 5);
1221
- ctx.lineTo(this.pinholeX, this.pinholeY + 5);
1220
+ ctx.moveTo(this.getPinholeX() - 5, this.getPinholeY());
1221
+ ctx.lineTo(this.getPinholeX() + 5, this.getPinholeY());
1222
+ ctx.moveTo(this.getPinholeX(), this.getPinholeY() - 5);
1223
+ ctx.lineTo(this.getPinholeX(), this.getPinholeY() + 5);
1222
1224
  ctx.closePath();
1223
1225
  ctx.stroke();
1224
1226
  ctx.restore();
@@ -1242,11 +1244,11 @@
1242
1244
  this.height = img.height;
1243
1245
  this.direction = direction;
1244
1246
  if (direction === "horizontal") {
1245
- this.pinholeX = this.width - img.pinholeX;
1246
- this.pinholeY = img.pinholeY;
1247
+ this.pinholeX = this.width - img.getPinholeX();
1248
+ this.pinholeY = img.getPinholeY();
1247
1249
  } else {
1248
- this.pinholeX = img.pinholeX;
1249
- this.pinholeY = this.height - img.pinholeY;
1250
+ this.pinholeX = img.getPinholeX();
1251
+ this.pinholeY = this.height - img.getPinholeY();
1250
1252
  }
1251
1253
  this.ariaText = direction+"ly flipped image: " + img.ariaText;
1252
1254
  };
@@ -1708,8 +1710,8 @@
1708
1710
  var width = this.width - 2*adjust, height = this.height - 2*adjust;
1709
1711
  var aX = adjust, aY = adjust;
1710
1712
 
1711
- ctx.moveTo(aX + this.pinholeX - adjust, aY + this.pinholeY - adjust);
1712
- ctx.arc(aX + this.pinholeX - adjust, aY + this.pinholeY - adjust, this.radius - 2*adjust, 0, -this.angle, true);
1713
+ ctx.moveTo(aX + this.getPinholeX() - adjust, aY + this.getPinholeY() - adjust);
1714
+ ctx.arc(aX + this.getPinholeX() - adjust, aY + this.getPinholeY() - adjust, this.radius - 2*adjust, 0, -this.angle, true);
1713
1715
  ctx.closePath();
1714
1716
  if (this.style.toString().toLowerCase() === "outline") {
1715
1717
  ctx.strokeStyle = colorString(this.color);
@@ -267,6 +267,10 @@
267
267
  // TODO(joe): This works because it's a builtin and already loaded on execRt.
268
268
  // In what situations may this not work?
269
269
  var rendererrorMod = execRt.modules["builtin://render-error-display"];
270
+ if (rendererrorMod == null) {
271
+ console.dir(res);
272
+ process.exit(1);
273
+ }
270
274
  var rendererror = execRt.getField(rendererrorMod, "provide-plus-types");
271
275
  var gf = execRt.getField;
272
276
  execRt.runThunk(function() {
@@ -134,7 +134,7 @@
134
134
  rawImage.onerror = function(e) {
135
135
  restarter.error(runtime.ffi.makeMessageException("Unable to load " + originalUrl + ". If that URL loads when you open it in your browser, there may be an issue with how that website serves images for programs. One workaround is to download the image, put it in your Google Drive, and use the 'Insert' button to add it to your program."));
136
136
  };
137
- rawImage.setAttribute("crossorigin", "anonymous");
137
+ rawImage.crossOrigin = "anonymous";
138
138
  rawImage.src = String(url);
139
139
  });
140
140
  };
@@ -837,7 +837,7 @@
837
837
  'row': runtime.makeMethodN(function(self, ...args) {
838
838
  // NOTE: Deliberately no arity check
839
839
  if(headers.length !== args.length) {
840
- throw runtime.ffi.throwRowLengthMismatch(makeTable(headers, []), args);
840
+ throw runtime.ffi.throwRowLengthMismatch(headers, args);
841
841
  }
842
842
  return makeRow({ headerIndex: headerIndex }, args);
843
843
  }),