import { Container } from "./container" ; import { Control } from "./control" ; import { Measure } from "../measure" ; import { RegisterClass } from 'babylonjs/Misc/typeStore' ; import { serialize } from 'babylonjs/Misc/decorators' ; import { ICanvasRenderingContext } from "babylonjs/Engines/ICanvas" ; /** Class used to create 2D ellipse containers */ export class Ellipse extends Container { private _thickness = 1 ; /** Gets or sets border thickness */ @ serialize ( ) public get thickness ( ) : number { return this . _thickness ; } public set thickness ( value ) { if ( this . _thickness === value ) { return ; } this . _thickness = value ; this . _markAsDirty ( ) ; } param name constructor ( public name ? ) { super ( name ) ; } protected _getTypeName ( ) { return "Ellipse" ; } protected _localDraw ( context ) { context . save ( ) ; if ( this . shadowBlur || this . shadowOffsetX || this . shadowOffsetY ) { context . shadowColor = this . shadowColor ; context . shadowBlur = this . shadowBlur ; context . shadowOffsetX = this . shadowOffsetX ; context . shadowOffsetY = this . shadowOffsetY ; } Control . drawEllipse ( this . _currentMeasure . left + this . _currentMeasure . width / 2 , this . _currentMeasure . top + this . _currentMeasure . height / 2 , this . _currentMeasure . width / 2 - this . _thickness / 2 , this . _currentMeasure . height / 2 - this . _thickness / 2 , context ) ; if ( this . _background ) { context . fillStyle = this . _background ; context . fill ( ) ; } if ( this . shadowBlur || this . shadowOffsetX || this . shadowOffsetY ) { context . shadowBlur = 0 ; context . shadowOffsetX = 0 ; context . shadowOffsetY = 0 ; } if ( this . _thickness ) { if ( this . color ) { context . strokeStyle = this . color ; } context . lineWidth = this . _thickness ; context . stroke ( ) ; } context . restore ( ) ; } protected _additionalProcessing ( parentMeasure , context ) { super . _additionalProcessing ( parentMeasure , context ) ; this . _measureForChildren . width -= 2 * this . _thickness ; this . _measureForChildren . height -= 2 * this . _thickness ; this . _measureForChildren . left += this . _thickness ; this . _measureForChildren . top += this . _thickness ; } protected _clipForChildren ( context ) { Control . drawEllipse ( this . _currentMeasure . left + this . _currentMeasure . width / 2 , this . _currentMeasure . top + this . _currentMeasure . height / 2 , this . _currentMeasure . width / 2 , this . _currentMeasure . height / 2 , context ) ; context . clip ( ) ; } public _renderHighlightSpecific ( context ) { Control . drawEllipse ( this . _currentMeasure . left + this . _currentMeasure . width / 2 , this . _currentMeasure . top + this . _currentMeasure . height / 2 , this . _currentMeasure . width / 2 - this . _highlightLineWidth / 2 , this . _currentMeasure . height / 2 - this . _highlightLineWidth / 2 , context ) ; context . stroke ( ) ; } } RegisterClass ( "BABYLON.GUI.Ellipse" , Ellipse ) ;