@teachinglab/omd 0.7.29 → 0.7.30
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.
- package/package.json +1 -1
- package/src/omdShapes.js +40 -0
package/package.json
CHANGED
package/src/omdShapes.js
CHANGED
|
@@ -264,6 +264,7 @@ export class omdEllipse extends jsvgGroup
|
|
|
264
264
|
this.rectWidth = 10;
|
|
265
265
|
this.rectHeight = 5;
|
|
266
266
|
this.unitScale = 10;
|
|
267
|
+
this.showLabels = false;
|
|
267
268
|
|
|
268
269
|
this.shapePath = new jsvgEllipse();
|
|
269
270
|
this.shapePath.setWidthAndHeight( this.rectWidth*this.unitScale, this.rectHeight*this.unitScale );
|
|
@@ -272,6 +273,9 @@ export class omdEllipse extends jsvgGroup
|
|
|
272
273
|
this.shapePath.setFillColor( omdColor.lightGray );
|
|
273
274
|
this.addChild( this.shapePath );
|
|
274
275
|
|
|
276
|
+
this.labelsHolder = new jsvgGroup();
|
|
277
|
+
this.addChild( this.labelsHolder );
|
|
278
|
+
|
|
275
279
|
this.updateLayout();
|
|
276
280
|
}
|
|
277
281
|
|
|
@@ -286,6 +290,9 @@ export class omdEllipse extends jsvgGroup
|
|
|
286
290
|
if ( typeof data.unitScale != "undefined" )
|
|
287
291
|
this.unitScale = data.unitScale;
|
|
288
292
|
|
|
293
|
+
if ( typeof data.showLabels != "undefined" )
|
|
294
|
+
this.showLabels = data.showLabels;
|
|
295
|
+
|
|
289
296
|
this.updateLayout();
|
|
290
297
|
}
|
|
291
298
|
|
|
@@ -297,6 +304,19 @@ export class omdEllipse extends jsvgGroup
|
|
|
297
304
|
this.shapePath.setWidthAndHeight( ellipseWidth, ellipseHeight );
|
|
298
305
|
this.shapePath.setPosition( ellipseWidth * 0.5 + 10, ellipseHeight * 0.5 + 10 );
|
|
299
306
|
|
|
307
|
+
this.labelsHolder.removeAllChildren();
|
|
308
|
+
if ( this.showLabels )
|
|
309
|
+
{
|
|
310
|
+
const label = new jsvgTextLine();
|
|
311
|
+
label.setAlignment("center");
|
|
312
|
+
label.setFontFamily( "Albert Sans" );
|
|
313
|
+
label.setFontColor( "black" );
|
|
314
|
+
label.setFontSize( 12 );
|
|
315
|
+
label.setPosition( ellipseWidth * 0.5 + 10, ellipseHeight * 0.5 + 14 );
|
|
316
|
+
label.setText( `${this.rectWidth} × ${this.rectHeight}` );
|
|
317
|
+
this.labelsHolder.addChild( label );
|
|
318
|
+
}
|
|
319
|
+
|
|
300
320
|
// Set dimensions and viewBox for API compatibility
|
|
301
321
|
this.width = this.rectWidth * this.unitScale + 20;
|
|
302
322
|
this.height = this.rectHeight * this.unitScale + 20;
|
|
@@ -315,6 +335,7 @@ export class omdCircle extends jsvgGroup
|
|
|
315
335
|
|
|
316
336
|
this.radius = 5;
|
|
317
337
|
this.unitScale = 10;
|
|
338
|
+
this.showLabels = false;
|
|
318
339
|
|
|
319
340
|
this.shapePath = new jsvgEllipse();
|
|
320
341
|
this.shapePath.setWidthAndHeight( this.radius*this.unitScale, this.radius*this.unitScale );
|
|
@@ -323,6 +344,9 @@ export class omdCircle extends jsvgGroup
|
|
|
323
344
|
this.shapePath.setFillColor( omdColor.lightGray );
|
|
324
345
|
this.addChild( this.shapePath );
|
|
325
346
|
|
|
347
|
+
this.labelsHolder = new jsvgGroup();
|
|
348
|
+
this.addChild( this.labelsHolder );
|
|
349
|
+
|
|
326
350
|
this.updateLayout();
|
|
327
351
|
}
|
|
328
352
|
|
|
@@ -334,6 +358,9 @@ export class omdCircle extends jsvgGroup
|
|
|
334
358
|
if ( typeof data.unitScale != "undefined" )
|
|
335
359
|
this.unitScale = data.unitScale;
|
|
336
360
|
|
|
361
|
+
if ( typeof data.showLabels != "undefined" )
|
|
362
|
+
this.showLabels = data.showLabels;
|
|
363
|
+
|
|
337
364
|
this.updateLayout();
|
|
338
365
|
}
|
|
339
366
|
|
|
@@ -344,6 +371,19 @@ export class omdCircle extends jsvgGroup
|
|
|
344
371
|
this.shapePath.setWidthAndHeight( diameter, diameter );
|
|
345
372
|
this.shapePath.setPosition( this.radius * this.unitScale + 10, this.radius * this.unitScale + 10 );
|
|
346
373
|
|
|
374
|
+
this.labelsHolder.removeAllChildren();
|
|
375
|
+
if ( this.showLabels )
|
|
376
|
+
{
|
|
377
|
+
const label = new jsvgTextLine();
|
|
378
|
+
label.setAlignment("center");
|
|
379
|
+
label.setFontFamily( "Albert Sans" );
|
|
380
|
+
label.setFontColor( "black" );
|
|
381
|
+
label.setFontSize( 12 );
|
|
382
|
+
label.setPosition( this.radius * this.unitScale + 10, this.radius * this.unitScale + 14 );
|
|
383
|
+
label.setText( `r=${this.radius}` );
|
|
384
|
+
this.labelsHolder.addChild( label );
|
|
385
|
+
}
|
|
386
|
+
|
|
347
387
|
// Set dimensions and viewBox for API compatibility
|
|
348
388
|
this.width = 2.0 * this.radius * this.unitScale + 20;
|
|
349
389
|
this.height = 2.0 * this.radius * this.unitScale + 20;
|