轉譯器概念
開始建構自訂轉譯器前,建議您先瞭解組成轉譯器的不同元件,以及區塊如何對應到資料列和元素。
轉譯器元件
轉譯器是由數個不同的元件建構而成。每個元件都有專屬工作,以盡可能重複使用程式碼和提高擴充性。
轉譯器
轉譯器是一種將所有其他元件組合在一起的工廠類別。
常數提供者
「常數提供者」是所有其他元件所使用的數字和形狀集合,以及內建欄位。
轉譯資訊
「轉譯資訊」會根據其定義決定區塊的配置方式,然後建立測量結果的集合,以及導覽匣用來建立 SVG 路徑的區塊相關資料。
路徑物件
路徑物件包含存放於背景的 SVG 元素。
導覽匣
導覽匣 (例如「一對一繪圖」) 會根據算繪資訊建構 SVG 路徑,並將其套用至路徑物件。
封鎖可評估次數
可評估是代表區塊區域的矩形。可評估項目是指「轉譯資訊」用來定義區塊版面配置的內容。
部分可評估項目還包含額外資料 (例如代表的視覺元素),或轉譯資訊可用來判斷區塊版面配置的輔助方法。
不同的轉譯器可能會建立自訂可評估項目,藉此變更這些資料或輔助方法。
資料列
「資料列」是一組元素和元素墊片的水平集合。
列墊
資料列空格字元是介於兩個資料列之間的空白垂直空間。
元素
元素代表區塊上的視覺項目。包括欄位、圖示、連線等。
元素墊片
元素空格字元是一種位於資料列中元素之間的空白空間。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-12-02 (世界標準時間)。
[null,null,["上次更新時間:2023-12-02 (世界標準時間)。"],[[["Blockly renderers are comprised of several components (Renderer, Constant Provider, Render Info, Path Object, and Drawer) working together to display blocks."],["Renderers utilize \"measurables\" to define the layout of a block, which are rectangular regions representing different parts of the block."],["Blocks are visually structured using rows and elements, with spacers providing spacing between them for better organization."],["Each component of a renderer has a specific role, such as defining constants, laying out the block, creating SVG paths, and managing the SVG elements."],["Custom renderers can be built by extending or modifying these components and measurables for unique visual styles and behaviors."]]],["A renderer is composed of several components: the **renderer** (factory class), **constant provider** (numbers/shapes), **render info** (layout decision-maker), **path object** (SVG elements), and **drawer** (SVG path builder). **Render info** uses **measurables** (block region rectangles) to define the block's layout. Blocks are structured into horizontal **rows** of **elements** (visual components) separated by **element spacers**, and rows are separated by **row spacers**.\n"]]