> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Drawing.new

> 创建请求类型的新 Drawing object，并将其添加到 Real tracked Drawing object list。type string 必须是以下精确支持名称之一: "Line", "Text", "Circle", "Square", "Quad", "Triangle", "Image"。缺失值、non-string 或不支持的 type values 会引发 Lua error。 the Drawing API 只在 the required rendering environment is active 为 true 时注册此 API；如果该检查为 false，initializer 会在创建这些 globals 之前返回。

<div className="real-function-page">
  ```lua theme={null}
  Drawing.new(objectType: "Image" | "Line" | "Text" | "Circle" | "Square" | "Quad" | "Triangle"): DrawingObject
  ```

  ## 参数

  <ParamField path={"objectType"} type={"\"Image\" | \"Line\" | \"Text\" | \"Circle\" | \"Square\" | \"Quad\" | \"Triangle\""} required>
    要创建的精确 Drawing type name。支持的值为 "Line", "Text", "Circle", "Square", "Quad", "Triangle", "Image"。
  </ParamField>

  ## 返回值

  <ResponseField name={"object"} type={"DrawingObject"}>
    带有 Drawing object type 的已创建 Drawing object。
  </ResponseField>

  ## 示例

  创建一个可见的正方形并配置其基本绘图属性。

  ```lua theme={null}
  local square = Drawing.new("Square")
  square.Position = Vector2.new(120, 120)
  square.Size = Vector2.new(220, 120)
  square.Color = Color3.fromRGB(120, 170, 255)
  square.Filled = true
  square.Visible = true
  ```
</div>
