Skip to content

Commit

Permalink
Update roboscape
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteinLTU committed May 21, 2024
1 parent 387d250 commit 23f27a5
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 136 deletions.
141 changes: 141 additions & 0 deletions extensions/RoboScapeOnline2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,147 @@
var scriptElement = document.createElement('script');
scriptElement.async = false;

if(isRetinaEnabled()){
disableRetinaSupport();

// This is a hack until NetsBlox has the changes to support retina displays for the 3D view
function enableRetinaSupport() {
function a(g) {
return g.isRetinaEnabled ? (d || 1) / c : 1
}
var b = document.createElement("canvas").getContext("2d")
, c = b.webkitBackingStorePixelRatio || b.mozBackingStorePixelRatio || b.msBackingStorePixelRatio || b.oBackingStorePixelRatio || b.backingStorePixelRatio || 1
, d = Math.ceil(window.devicePixelRatio);
b = HTMLCanvasElement.prototype;
var e = CanvasRenderingContext2D.prototype
, f = {
drawImage: e.drawImage,
getImageData: e.getImageData,
width: Object.getOwnPropertyDescriptor(b, "width"),
height: Object.getOwnPropertyDescriptor(b, "height"),
shadowOffsetX: Object.getOwnPropertyDescriptor(e, "shadowOffsetX"),
shadowOffsetY: Object.getOwnPropertyDescriptor(e, "shadowOffsetY"),
shadowBlur: Object.getOwnPropertyDescriptor(e, "shadowBlur")
};
c === d || Object.keys(f).some(g=>{
g = f[g];
return g.hasOwnProperty("configurable") && !g.configurable
}
) || (b._isRetinaEnabled = !0,
b._bak = f,
Object.defineProperty(b, "isRetinaEnabled", {
get: function() {
return this._isRetinaEnabled
},
set: function(g) {
var h = a(this)
, m = this.width
, l = this.height;
this._isRetinaEnabled = g;
a(this) != h && (this.width = m,
this.height = l)
},
configurable: !0
}),
Object.defineProperty(b, "width", {
get: function() {
return f.width.get.call(this) / a(this)
},
set: function(g) {
try {
var h = a(this);
f.width.set.call(this, g * h);
this.getContext("2d")?.scale(h, h) // This line is the only change, a null check was added
} catch (m) {
console.log("Retina Display Support Problem", m),
f.width.set.call(this, g)
}
}
}),
Object.defineProperty(b, "height", {
get: function() {
return f.height.get.call(this) / a(this)
},
set: function(g) {
var h = a(this);
f.height.set.call(this, g * h);
this.getContext("2d")?.scale(h, h) // This line is the only change, a null check was added
}
}),
e.drawImage = function(g) {
var h = a(g);
switch (arguments.length) {
case 9:
var m = arguments[1];
var l = arguments[2];
var k = arguments[3];
var n = arguments[4];
var p = arguments[5];
var q = arguments[6];
var r = arguments[7];
var t = arguments[8];
break;
case 5:
l = m = 0;
k = g.width;
n = g.height;
p = arguments[1];
q = arguments[2];
r = arguments[3];
t = arguments[4];
break;
case 3:
l = m = 0;
k = g.width;
n = g.height;
p = arguments[1];
q = arguments[2];
r = g.width;
t = g.height;
break;
default:
throw Error("Called drawImage() with " + arguments.length + " arguments");
}
f.drawImage.call(this, g, m * h, l * h, k * h, n * h, p, q, r, t)
}
,
e.getImageData = function(g, h, m, l) {
var k = a(this.canvas);
return f.getImageData.call(this, g * k, h * k, m * k, l * k)
}
,
Object.defineProperty(e, "shadowOffsetX", {
get: function() {
return f.shadowOffsetX.get.call(this) / a(this.canvas)
},
set: function(g) {
var h = a(this.canvas);
f.shadowOffsetX.set.call(this, g * h)
}
}),
Object.defineProperty(e, "shadowOffsetY", {
get: function() {
return f.shadowOffsetY.get.call(this) / a(this.canvas)
},
set: function(g) {
var h = a(this.canvas);
f.shadowOffsetY.set.call(this, g * h)
}
}),
Object.defineProperty(e, "shadowBlur", {
get: function() {
return f.shadowBlur.get.call(this) / a(this.canvas)
},
set: function(g) {
var h = a(this.canvas);
f.shadowBlur.set.call(this, g * h)
}
}))
}

enableRetinaSupport();
}

scriptElement.onload = () => {
var loaderScriptElement = document.createElement('script');
loaderScriptElement.async = false;
Expand Down
14 changes: 7 additions & 7 deletions extensions/RoboScapeOnline2/pkg/roboscapesim_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ export interface InitOutput {
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_2: WebAssembly.Table;
readonly _dyn_core__ops__function__Fn_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc848945a3d0bd193: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h7b29029e76c159c7: (a: number, b: number) => void;
readonly _dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h75ed84272e5c0cbe: (a: number, b: number, c: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__hbd98963ae49dd62b: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h333c5b7209145e6f: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h50fbf020e7550799: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__Fn_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha77510dd7d25b564: (a: number, b: number) => void;
readonly _dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hafe85d1da8295a10: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h58a54247c44d5a16: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__ha204ea0aa77d1d1c: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2f48bc7cb1c39ec5: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4dc266bd3929c8bd: (a: number, b: number, c: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly wasm_bindgen__convert__closures__invoke2_mut__h741a8a0a4379930d: (a: number, b: number, c: number, d: number) => void;
readonly wasm_bindgen__convert__closures__invoke2_mut__h18f41ff999320e94: (a: number, b: number, c: number, d: number) => void;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_start: () => void;
}
Expand Down
Loading

0 comments on commit 23f27a5

Please sign in to comment.