Create block_rendering file and move render definition there

This commit is contained in:
Rachel Fenichel
2019-07-23 11:06:36 -07:00
parent b9bfc37fd4
commit e599ec2abe
2 changed files with 51 additions and 15 deletions

View File

@@ -33,29 +33,17 @@ goog.require('BRC');
/* global BRC */
goog.require('Blockly.blockRendering.Measurable');
/**
* Render the given block.
* @param {!Blockly.BlockSvg} block The block to render
* @public
*/
Blockly.blockRendering.render = function(block) {
if (!block.renderingDebugger) {
block.renderingDebugger = new Blockly.blockRendering.Debug();
}
new Blockly.blockRendering.Drawer(block).draw_();
};
/**
* An object that draws a block based on the given rendering information.
* @param {!Blockly.BlockSvg} block The block to render
* @param {!Blockly.blockRendering.RenderInfo} info An object containing all
* information needed to render this block.
* @private
* @package
*/
Blockly.blockRendering.Drawer = function(block) {
Blockly.blockRendering.Drawer = function(block, info) {
this.block_ = block;
this.info_ = info;
this.topLeft_ = block.getRelativeToSurfaceXY();
this.info_ = new Blockly.blockRendering.RenderInfo(block);
this.pathObject_ = new Blockly.BlockSvg.PathObject();
this.steps_ = this.pathObject_.steps;
this.inlineSteps_ = this.pathObject_.inlineSteps;

View File

@@ -0,0 +1,48 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2019 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Namespace for block rendering functionality.
* @author fenichel@google.com (Rachel Fenichel)
*/
'use strict';
/**
* The top level namespace for block rendering.
* @namespace Blockly.blockRendering
*/
goog.provide('Blockly.blockRendering');
goog.require('Blockly.blockRendering.Debug');
goog.require('Blockly.blockRendering.Drawer');
goog.require('Blockly.blockRendering.RenderInfo');
/**
* Render the given block.
* @param {!Blockly.BlockSvg} block The block to render
* @public
*/
Blockly.blockRendering.render = function(block) {
if (!block.renderingDebugger) {
block.renderingDebugger = new Blockly.blockRendering.Debug();
}
var info = new Blockly.blockRendering.RenderInfo(block);
new Blockly.blockRendering.Drawer(block, info).draw_();
};