fixes micro:bit + breadboard sim size issue
This commit is contained in:
parent
fc0faf5181
commit
52527dd584
@ -68,8 +68,8 @@ namespace pxsim.visuals {
|
|||||||
scaleUnit2: number,
|
scaleUnit2: number,
|
||||||
margin: [number, number, number, number],
|
margin: [number, number, number, number],
|
||||||
middleMargin: number,
|
middleMargin: number,
|
||||||
maxWidth: number,
|
maxWidth?: string,
|
||||||
maxHeight: number,
|
maxHeight?: string,
|
||||||
}
|
}
|
||||||
export interface ComposeResult {
|
export interface ComposeResult {
|
||||||
host: SVGSVGElement,
|
host: SVGSVGElement,
|
||||||
@ -84,16 +84,17 @@ namespace pxsim.visuals {
|
|||||||
let [a, b] = [opts.el1, opts.el2];
|
let [a, b] = [opts.el1, opts.el2];
|
||||||
U.assert(a.x == 0 && a.y == 0 && b.x == 0 && b.y == 0, "el1 and el2 x,y offsets not supported");
|
U.assert(a.x == 0 && a.y == 0 && b.x == 0 && b.y == 0, "el1 and el2 x,y offsets not supported");
|
||||||
let setXY = (e: SVGSVGElement, x: number, y: number) => svg.hydrate(e, {x: x, y: y});
|
let setXY = (e: SVGSVGElement, x: number, y: number) => svg.hydrate(e, {x: x, y: y});
|
||||||
let setWH = (e: SVGSVGElement, w: number, h: number) => svg.hydrate(e, {width: w, height: h});
|
let setWH = (e: SVGSVGElement, w: string, h: string) => svg.hydrate(e, {width: w, height: h});
|
||||||
|
let setWHpx = (e: SVGSVGElement, w: number, h: number) => svg.hydrate(e, {width: `${w}px`, height: `${h}px`});
|
||||||
let scaleUnit = opts.scaleUnit2;
|
let scaleUnit = opts.scaleUnit2;
|
||||||
let aScalar = opts.scaleUnit2 / opts.scaleUnit1;
|
let aScalar = opts.scaleUnit2 / opts.scaleUnit1;
|
||||||
let bScalar = 1.0;
|
let bScalar = 1.0;
|
||||||
let aw = a.w * aScalar;
|
let aw = a.w * aScalar;
|
||||||
let ah = a.h * aScalar;
|
let ah = a.h * aScalar;
|
||||||
setWH(a.el, aw, ah);
|
setWHpx(a.el, aw, ah);
|
||||||
let bw = b.w * bScalar;
|
let bw = b.w * bScalar;
|
||||||
let bh = b.h * bScalar;
|
let bh = b.h * bScalar;
|
||||||
setWH(b.el, bw, bh);
|
setWHpx(b.el, bw, bh);
|
||||||
let [mt, mr, mb, ml] = opts.margin;
|
let [mt, mr, mb, ml] = opts.margin;
|
||||||
let mm = opts.middleMargin;
|
let mm = opts.middleMargin;
|
||||||
let innerW = Math.max(aw, bw);
|
let innerW = Math.max(aw, bw);
|
||||||
@ -111,7 +112,8 @@ namespace pxsim.visuals {
|
|||||||
"viewBox": `0 0 ${w} ${h}`,
|
"viewBox": `0 0 ${w} ${h}`,
|
||||||
"class": `sim-bb`,
|
"class": `sim-bb`,
|
||||||
});
|
});
|
||||||
setWH(host, opts.maxWidth, opts.maxHeight);
|
if (opts.maxWidth && opts.maxHeight)
|
||||||
|
setWH(host, opts.maxWidth, opts.maxHeight);
|
||||||
setXY(host, 0, 0);
|
setXY(host, 0, 0);
|
||||||
let under = <SVGGElement>svg.child(host, "g");
|
let under = <SVGGElement>svg.child(host, "g");
|
||||||
host.appendChild(a.el);
|
host.appendChild(a.el);
|
||||||
|
@ -34,8 +34,8 @@ namespace pxsim.visuals {
|
|||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
const VIEW_WIDTH = 299;
|
const VIEW_WIDTH = "100%";
|
||||||
const VIEW_HEIGHT = 433;
|
const VIEW_HEIGHT = "100%";
|
||||||
|
|
||||||
if (0 < activeComponents.length) {
|
if (0 < activeComponents.length) {
|
||||||
this.breadboard = new Breadboard();
|
this.breadboard = new Breadboard();
|
||||||
|
Loading…
Reference in New Issue
Block a user