Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>ZIM - Code Creativity</title>
- <script src="https://zimjs.org/cdn/1.3.2/createjs.js"></script>
- <script src="https://zimjs.org/cdn/cat/02/zim.js"></script>
- <script>
- window.addEventListener('load', (event) => {
- function parentUrl () {
- return (window.location !== window.parent.location) ?
- document.referrer :
- document.location.href
- }
- function updateAll (imgUrl, col, row) {
- //if(col && row) תציג את הנקודה הקודמת
- console.log('The image URL is :', imgUrl)
- var assets = [{
- src: imgUrl,
- id: 'mainImage',
- }]
- const frame = new Frame('fit', 1024, 768, light, dark, assets)
- frame.on('ready', () => {
- const stage = frame.stage
- let stageW = frame.width
- let stageH = frame.height
- var rowNumber = 10
- var colNumber = 10
- var con = new Container(800, 600)
- con.center()
- asset('mainImage').scaleTo(con).center(con)
- var stepperRow = new Stepper({
- min: 3,
- max: 20,
- })
- stepperRow.on('change', function () {
- updateTile()
- })
- stepperRow.currentValue = rowNumber
- stepperRow.sca(0.5).addTo().pos({
- 'horizontal': 'center',
- 'vertical': 'top',
- x: -100,
- y: 10,
- })
- var stepperCol = new Stepper({
- min: 3,
- max: 20,
- })
- stepperCol.on('change', function () {
- updateTile()
- })
- stepperCol.currentValue = colNumber
- stepperCol.sca(0.5).addTo().pos({
- 'horizontal': 'center',
- 'vertical': 'top',
- x: 100,
- y: 10,
- })
- var tile
- var selectChild = null
- function updateTile () {
- if (tile) tile.dispose()
- rowNumber = stepperRow.currentValue
- colNumber = stepperCol.currentValue
- var rect = new Rectangle({
- color: 'rgba(256,0,0,0.01)',
- borderColor: 'rgba(256,0,0,0.5)',
- width: con.width / colNumber,
- height: con.height / rowNumber,
- })
- tile = new Tile(rect, colNumber, rowNumber).center()
- tile.addTo(con)
- loop(tile, function (rectChild) {
- rectChild.cur()
- rectChild.firstColor = rectChild.color
- rectChild.on('mousedown', function () {
- loop(tile, function (rectChild2) {
- rectChild2.color = rectChild2.firstColor
- })
- selectChild = rectChild
- rectChild.color = 'rgba(256, 0, 0, 0.5)'
- stage.update()
- })
- })
- stage.update()
- }
- var btn = new Button({
- width: 200,
- height: 50,
- label: 'שמור',
- })
- btn.addTo().pos({
- 'horizontal': 'center',
- 'vertical': 'bottom',
- x: 0,
- y: 30,
- })
- btn.on('mousedown', function () {
- let data = {
- numRow: rowNumber,
- numCol: colNumber,
- row: selectChild.tileRow,
- col: selectChild.tileCol,
- }
- parent.postMessage({
- data,
- action: 'updateAll',
- }, parentUrl())
- })
- updateTile()
- // put your code here
- stage.update()
- })
- }
- window.addEventListener('message', (event) => {
- updateAll(event.data)
- })
- console.log('page is fully loaded')
- })
- </script>
- <meta name="viewport" content="width=device-width, user-scalable=no"/>
- </head>
- <body></body>
- </html>
Add Comment
Please, Sign In to add comment