-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.blocks
1 lines (1 loc) · 6.89 KB
/
main.blocks
1
<xml xmlns="https://developers.google.com/blockly/xml"><block type="pxt-on-start" id="~0j4Y#{@$3VR/xQc_hDN" x="0" y="0"><statement name="HANDLER"><block type="typescript_statement" id="};.;Gu6_Qm:i?o1!grkP" editable="false"><mutation xmlns="http://www.w3.org/1999/xhtml" line0="namespace circle {" line1=" //% group="Create" weight=100" line2=" //% block="create circle of radius %radius and color $color || filled is $filled"" line3=" //% blockSetVariable=myCircle" line4=" //% radius.min=5 radius.max=60 radius.defl=30" line5=" //% color.min=0 color.max=15 color.defl=2" line6=" //% filled.defl=false" line7=" export function createCircleSprite(radius: number, color: number, filled:boolean = false): Circle {" line8=" return new Circle(radius, color, filled)" line9=" }" line10=" //% group="Circle List" weight=80" line11=" //% blockSetVariable=myCircleList" line12=" //% blockSetVariable=myCircleList" line13=" export function emptyCircleList(){" line14=" return new CircleList()" line15=" }" line16="}" numlines="17"></mutation><next><block type="typescript_statement" id="u?:mI_.x9R=zMb]tD,!3" editable="false"><mutation xmlns="http://www.w3.org/1999/xhtml" line0="class CircleList{" line1=" _circles: Circle[] = []" line2=" constructor(){" line3="" line4=" }" line5=" //% group="Circle List" weight=80" line6=" //% block="add %cirlce(myCircle) to end)"" line7=" addCircleToEnd (value:Circle ){" line8=" this._circles[this._circles.length] = value" line9=" }" line10=" //% group="Circle List" weight=80" line11=" //% block="get and remove %cirlce(myCircle) from end"" line12=" getAndRemoveCircleFromEnd():Circle {" line13=" let tmp: Circle = this._circles[this._circles.length - 1]" line14=" this._circles.removeAt(this._circles.length - 1)" line15=" return tmp" line16=" }" line17=" //% group="Circle List" weight=80" line18=" //% block="remove and destroy %cirlce(myCircle) from end"" line19=" removeAndDestroyCircle(){" line20=" let tmp2 = this.getAndRemoveCircleFromEnd()" line21=" tmp2.destroy()" line22=" }" line23="}" numlines="24"></mutation><next><block type="typescript_statement" id="Y3h7U!d.n@R4wXq*LQv," editable="false"><mutation xmlns="http://www.w3.org/1999/xhtml" line0="class Circle {" line1=" _sprite: Sprite = null;" line2=" _img: Image = null;" line3=" _radius: number = 0;" line4=" _color: number = 0;" line5=" _fillColor: number = 0;" line6=" _filled: boolean = false;" line7=" imageWH: number = 0;" line8=" centerXY:number = 0;" line9=" constructor(radius: number, color: number, filled: boolean = false) {" line10=" this._radius = radius;" line11=" this._color = color;" line12=" this._fillColor = 0;" line13=" this._filled = filled;" line14=" if(this._filled){" line15=" this._fillColor = this._color;" line16=" }" line17=" this.imageWH = 2 * (this._radius + 2);" line18=" this.centerXY = this.imageWH / 2;" line19=" this._img = image.create(this.imageWH, this.imageWH);" line20=" this._img.drawCircle(this.centerXY, this.centerXY, this._radius, this._color);" line21=" if (this._filled) {" line22=" this._img.fillCircle(this.centerXY, this.centerXY, this._radius, this._fillColor)" line23=" }" line24=" this._sprite = sprites.create(this._img);" line25=" }" line26=" //% group="Properties" weight=95" line27=" //% blockSetVariable="myCircle"" line28=" //% blockCombine block="sprite"" line29=" get circle(): Sprite {" line30=" return this._sprite;" line31=" }" line32=" //% group="Properties" weight=95" line33=" //% blockSetVariable="myImage"" line34=" //% blockCombine block="image"" line35=" get imaage(): Image {" line36=" this._img.drawCircle(this.centerXY, this.centerXY, this._radius, this._color);" line37=" return this._img;" line38=" }" line39=" //% group="Properties" weight=95" line40=" //% blockSetVariable="myImage"" line41=" //% blockCombine block="image"" line42=" set image(value: Image ) {" line43=" this._img = value;" line44=" }" line45=" //% group="Properties" weight=95" line46=" //% blockSetVariable="myCircle"" line47=" //% blockCombine block="color"" line48=" get color(): number {" line49=" return this._color;" line50=" }" line51=" //% group="Properties" weight=95" line52=" //% blockSetVariable="myCircle"" line53=" //% blockCombine block="color"" line54=" set color(value: number) {" line55=" this._color = value;" line56=" this._img.drawCircle(this.centerXY, this.centerXY, this._radius, this._color);" line57=" }" line58=" //% group="Properties" weight=95" line59=" //% blockSetVariable="myCircle"" line60=" //% blockCombine block="radius"" line61=" get radius(): number {" line62=" return this._radius;" line63=" }" line64=" //% group="Properties" weight=95" line65=" //% blockSetVariable="myCircle"" line66=" //% blockCombine block="Fill Color" line67=" get fillColor() {" line68=" return this._fillColor;" line69=" }" line70=" //% group="Actions" weight=90" line71=" //% block="fill %Circle(myCircle) with color $color"" line72=" fill(color: number) {" line73=" this._filled = true;" line74=" this._fillColor = color;" line75=" this._img.fillCircle(this.centerXY, this.centerXY, this._radius, this._fillColor)" line76=" }" line77=" //% group="Actions" weight=90" line78=" //% block="erase fill from %Circle(myCircle)"" line79=" unfill() {" line80=" this._filled = false;" line81=" this._fillColor = 0;" line82=" this._img.fill(0); //clear anything in image" line83=" this._img.drawCircle(this.centerXY, this.centerXY, this._radius, this._color);" line84=" }" line85=" //% group="Actions" weight=90" line86=" //% block="destroy %Circle(myCircle)"" line87=" destroy() {" line88=" if(this._sprite != null){" line89=" this._sprite.destroy()" line90=" }" line91=" this.destroy()" line92=" }" line93=" }" numlines="94"></mutation></block></next></block></next></block></statement></block></xml>