The fill colour of the Shape. Used for all shapes.
-- Create a new shape
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
-- Change the colour and position of the shape
Shape.position = osrs.Vector2.new(600,600)
Shape.colour = osrs.Colour.new(255,0,0,255)
-- Create another new shape
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
-- Change the colour and position of the shape
Shape2.position:set(400, 400)
Shape2.colour:set(0,255,0,255)
Used for Rectangles, Sprites, and Text. Represents the dimensions in screen space of the primitive. For TEXT, represents the box in which the text is drawn (text size can be controlled by selecting the font).
-- Create a new shape
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
-- Change the dimensions and position of the shape
Shape.position = osrs.Vector2.new(600,600)
Shape.dimensions = osrs.Vector2.new(50,50)
-- Create another new shape
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
-- Change the dimensions and position of the shape
Shape2.position:set(400, 400)
Shape2.dimensions:set(100, 20)
Endpoint in screen coordinates, for line shape.
-- Create a new shape
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
-- Change the endpoint of the shape
Shape.endpoint:set(250, 250)
-- Create another shape of a diffrent color
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
Shape2.colour:set(0,255,0,255)
-- Change the endpoint of the shape
Shape2.endpoint:set(100, 100)
For text shapes, specifies the font to use.
Horizontal alignment for text shapes.
ReadonlyidThe Shape's ID in the draw list. This also controls the shape's draw order. You can manipulate this value with the "sort" family of functions. Ids are assigned out with a stride of 1024, leaving space to sort Shapes between other shapes.
-- Create two new shapes with a set position
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
Shape.position:set(500, 500)
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
Shape.position:set(600, 500)
-- Check the shapes ID's
osrs.print("Rectangle Shape ID: " .. tostring(Shape.id) .. "\nCircle Shape ID: " .. tostring(Shape2.id))
Alias for "Position" when using a CIRCLE shape.
The position of the Shape. For Circles, this is the center-point. For lines, it represents the start-point. For all other shapes it is the upper-left corner in screen space.
-- Create a new shape
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
-- Change the position of the shape
Shape.position = osrs.Vector2.new(100,100)
-- Create another new shape
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
-- Change the position of the shape
Shape2.position:set(300, 300)
Radius in pixels for CIRCLE shapes.
See ShadingType primitive for more information. Not all shadings are supported by all Shapes. For instance only CIRCLE and RECTANGLE support the "Empty" shading.
-- Create two new shapes with diffrent positions
local Shape1 = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
Shape1.position:set(100, 100)
local Shape2 = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
Shape2.position:set(200, 200)
-- Change one of the shapes shading types
Shape1.shading = osrs.Shape.ShadingType.EMPTY
Indicates which Shape this object represents. Changing a Shape type dynamically is possible, but you should fill in any missing parameters for the new shape in the same call-stack. For example, if changing to CIRCLE, be sure to set the "radius" property.
For SPRITE shapes, this sets or gets the sprite that will be rendered. Sprite Ids must be retrieved by other API calls. However, the range begins at 0, which allows a simple demonstration:
Stroke width, in pixels, for a circle shape.
-- Create a new circle shape
local Shape = osrs.Shape.new(osrs.Shape.PrimitiveType.CIRCLE)
-- Change the shading of the circle to empty and update the position
Shape.shading = osrs.Shape.ShadingType.EMPTY
Shape.position:set(300, 300)
-- Change the radius of the circle
Shape.radius = 200
-- Change the stroke width of the circle
-- Should be less than the radius
Shape.strokewidth = 100
For text shapes, specifies the text that will render. Text is word-wrapped within its bounding box, and positioned according to halign and valign params.
Vertical alignment for text shapes.
For text shapes, this is the vertical spacing in pixels between individual lines of text.
Sorts this shape above the submitted shape.
local first = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
first.position:set(500,500)
first.colour:set(255,0,0,255)
local second = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
second.position:set(520,520)
second.colour:set(0,255,0,255)
--normally first draws behind second, but this causes it to sort in front.
first:sortAbove(second)
Sort the shape as closely as possible to the submitted Id.
The id to set. Will walk upwards by 1 until a free id slot is found.
-- bring a shape to the top of the sort order, and then return it to it's staring position.
-- assume "rect" and "top_shape" are shapes, and top_shape is the highest-positioned shape.
--save off rect's position in the sort order.
local starting_id = rect.id
--bring rect to top.
rect_id.sortAbove(top_shape)
--return shape to starting position. If something has claimed its id, will sort as closely as possible
--to the requested id.
rect.sortAt(starting_id)
Sorts this shape below the submitted shape
local first = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
first.position:set(500,500)
first.colour:set(255,0,0,255)
local second = osrs.Shape.new(osrs.Shape.PrimitiveType.RECTANGLE)
second.position:set(530,530)
second.colour:set(0,255,0,255)
--normally second draws in front of first, but this causes it to sort below.
second:sortBelow(first)
StaticnewConstructor
The PrimitiveType this Shape represents
OptionalshouldRender: booleanShould the shape be added to the draw list? Defaults to true.
This section is for 2D images and text shapes that can appear on the screen. These methods and properties will allow you to draw customized shapes and text onto the old school runescape client window for people using your plugin to see.
Lets say you wanted to put a red circle on the screen. You can create a new shape using the shape constructor. You specify that it is a circle by naming its type, a PrimitiveType, and set the colour to red. Once this is done, you can use the Graphics namespace to add your newly made shape to the screen.
Now lets say you added your red circle to the screen, but you now want to add a blue rectangle that would be under it. This is something that you can easily do using the sortAbove function. To make the rectangle, follow the steps we did above to make our circle, and then use the sortAbove method with both shapes.
There are multiple properties that you can play around with and use to customize a shape in any way, such as changing its width, height, and position. If you are creating a text shape for the screen you can even change the font it uses.
Using the shape class with all its properties and functions will let you create expressive 2D art that will show up right on the OSRS game screen.