مفاهیم رندر
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
قبل از شروع ساختن یک رندر سفارشی، درک اجزای مختلف سازنده یک رندر و همچنین نحوه تقسیم یک بلوک به ردیف ها و عناصر مفید است.
اجزای رندر
یک رندر از چندین مؤلفه مختلف ساخته شده است. هر جزء یک کار منحصر به فرد برای به حداکثر رساندن استفاده مجدد و توسعه پذیری کد دارد.
رندر
رندر یک کلاس کارخانه ای است که تمام اجزای دیگر را با هم ترکیب می کند.
ارائه دهنده ثابت
ارائهدهنده ثابت مجموعهای از اعداد و اشکال است که توسط همه اجزای دیگر و همچنین فیلدهای داخلی استفاده میشود.
رندر اطلاعات
اطلاعات رندر تصمیم میگیرد که چگونه یک بلوک باید بر اساس تعریف آن چیده شود، و سپس مجموعهای از اندازهگیریها و دادههای مربوط به بلوک را ایجاد میکند که کشو برای ایجاد مسیرهای SVG استفاده میکند.
شی مسیر
شی مسیر حاوی عناصر SVG است که در dom زندگی می کنند و بلوک را تشکیل می دهند.
کشو
کشو (مانند «one-who-draws») مسیرهای SVG را بر اساس اطلاعات رندر میسازد و آنها را روی شی مسیر اعمال میکند.
بلوک های قابل اندازه گیری
قابل اندازه گیری مستطیلی است که ناحیه ای از یک بلوک را نشان می دهد. اندازه گیری ها همان چیزی هستند که اطلاعات رندر برای تعریف چیدمان بلوک استفاده می کند.
برخی از اندازهگیریها همچنین شامل دادههای اضافی هستند (مانند چیز بصری که نشان میدهند)، یا روشهای کمکی که اطلاعات رندر میتواند برای تعیین نحوه چیدمان بلوک استفاده کند.
رندرهای مختلف ممکن است اندازه گیری های سفارشی را برای تغییر این داده ها یا روش های کمکی ایجاد کنند.
ردیف ها
یک ردیف مجموعه ای افقی از عناصر و فاصله دهنده های عناصر است.

فاصله دهنده ردیف
فاصله بین ردیف یک فضای عمودی خالی است که بین دو ردیف قرار می گیرد.

عناصر
یک عنصر یک چیز بصری را در یک بلوک نشان می دهد. اینها شامل فیلدها ، نمادها ، اتصالات و غیره است.

فاصله دهنده های المان
فاصلهگذار عنصر فضای خالی است که بین عناصر در یک ردیف قرار میگیرد.

جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eBlockly renderers are comprised of several components (Renderer, Constant Provider, Render Info, Path Object, and Drawer) working together to display blocks.\u003c/p\u003e\n"],["\u003cp\u003eRenderers utilize "measurables" to define the layout of a block, which are rectangular regions representing different parts of the block.\u003c/p\u003e\n"],["\u003cp\u003eBlocks are visually structured using rows and elements, with spacers providing spacing between them for better organization.\u003c/p\u003e\n"],["\u003cp\u003eEach component of a renderer has a specific role, such as defining constants, laying out the block, creating SVG paths, and managing the SVG elements.\u003c/p\u003e\n"],["\u003cp\u003eCustom renderers can be built by extending or modifying these components and measurables for unique visual styles and behaviors.\u003c/p\u003e\n"]]],["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"],null,["# Renderer concepts\n\nBefore you start building a custom renderer, it is helpful to understand the\ndifferent components that make up a renderer, as well as how a block gets\nbroken up into rows and elements.\n\nRenderer components\n-------------------\n\nA renderer is built up of several different components. Each component has a\nunique job to maximize code reuse and extensibility.\n\n### Renderer\n\nThe [renderer](/blockly/guides/create-custom-blocks/renderers/concepts/renderer) is a factory class that bundles all of the other\ncomponents together.\n\n### Constant provider\n\nThe [constant provider](/blockly/guides/create-custom-blocks/renderers/concepts/constants) is a collection of numbers, and shapes used\nby all of the other components, as well as built-in fields.\n\n### Render info\n\nThe [render info](/blockly/guides/create-custom-blocks/renderers/concepts/info) decides how it a block should be laid out based\non its definition, and then creates a collection of\n[measurables](#block_measurables) and data about the block which the\n[drawer](/blockly/guides/create-custom-blocks/renderers/concepts/drawer) uses to create SVG paths.\n\n### Path Object\n\nThe [path object](/blockly/guides/create-custom-blocks/renderers/concepts/path-object) contains the SVG elements that live in the dom\nand make up the block.\n\n### Drawer\n\nThe [drawer](/blockly/guides/create-custom-blocks/renderers/concepts/drawer) (as in \"one-who-draws\") builds SVG [paths](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) based on\nthe [render info](/blockly/guides/create-custom-blocks/renderers/concepts/info) and applies them to the\n[path object](/blockly/guides/create-custom-blocks/renderers/concepts/path-object).\n\nBlock measurables\n-----------------\n\nA measurable is a rectangle representing a region of a block. Measurables are\nwhat the [render info](/blockly/guides/create-custom-blocks/renderers/concepts/info) uses to define the layout of the block.\n\nSome measurables also include extra data (such as the visual thing they are\nrepresenting), or helper methods that the render info can use to figure out how\nto lay out the block.\n\nDifferent renderers may create custom measurables to change these data or\nhelper methods.\n\n### Rows\n\nA [row](/blockly/guides/create-custom-blocks/renderers/concepts/rows) is a horizontal collection of [elements](/blockly/guides/create-custom-blocks/renderers/concepts/elements) and\n[element spacers](/blockly/guides/create-custom-blocks/renderers/concepts/elements#element_spacer).\n\n### Row spacers\n\nA [row spacer](/blockly/guides/create-custom-blocks/renderers/concepts/rows#row_spacer) is an empty vertical space that goes between two\nrows.\n\n### Elements\n\nAn [element](/blockly/guides/create-custom-blocks/renderers/concepts/elements) represents a visual thing on a block. These include\n[fields](/blockly/guides/create-custom-blocks/fields/overview), [icons](/blockly/guides/create-custom-blocks/icons/overview), connections, etc.\n\n### Element spacers\n\nAn [element spacer](/blockly/guides/create-custom-blocks/renderers/concepts/elements#element_spacer) is an empty space that goes between elements\nin a row."]]