Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- _____ _
- | ____| |
- _ __| |__ | |_ _ __ _
- | '_ \___ \| | | | |/ _` |
- | |_) |__) | | |_| | (_| |
- | .__/____/|_|\__,_|\__,_|
- | |
- |_|
- Hello!
- p5lua is a lua version of the popular javascript library p5js.
- This is the full reference of the p5lua library.
- (Note: p5lua is still being worked on and I will add more methods and functions later.)
- ]]
- -- First, you must load the library.
- local p5 = loadstring(game:HttpGet('https://pastebin.com/raw/8BKNLVeC'))()
- --[[You can replace p5 with any variable name,
- but remember to use it as your calling variable later. ]]
- -- Here are the constants:
- p5.HALF_PI -- pi / 2.
- p5.PI -- pi.
- p5.QUARTER_PI -- pi / 4.
- p5.TAU -- 2 * pi.
- p5.TWO_PI -- 2 * pi.
- p5.width -- Width of screen.
- p5.height -- Height of screen.
- -- Here are the basic methods:
- p5:createCanvas(sizeX, sizeY, canvasColor, cursor, pos, cursorColor)
- --[[ Creates a canvas of specified size.
- - 'sizeX': int(mandatory)
- - 'sizeY': int(mandatory)
- - 'canvasColor': Color3(optional)
- - 'cursor': boolean(optional) -- Gives mouse a cursor when hovering over canvas.
- - 'pos': Vector2(optional)
- - 'cursorColor': Color3(optional)]]
- p5:translate(x, y) -- Translates 0, 0 to x, y.
- p5:pVector2(x, y) --[[ Returns a Vector2 value affected by p5:translate()
- Note: regular Vector2 values are not affected by p5:translate(). ]]
- p5:mouseX() -- Returns the mouse's X position.
- p5:mouseY() -- Returns the mouse's Y position.
- p5:dist(x1, y1, x2, y2) -- Returns the distance of x2, y2 from x1, y1.
- p5:round(num, DecimalPlaces) -- Rounds num to DecimalPlaces.
- p5:map(value, fromLow, fromHigh, toLow, toHigh) --[[ Re-maps a number
- from one range to another.]]
- p5:point(x, y, size, color) -- Draws a point at x, y.
- -- Here are the advanced methods:
- p5:beginShape(key)
- p5:vertex(key, x, y)
- p5:endShape(key)
- --[[ Using the beginShape() and endShape() functions allow creating more
- complex forms. beginShape() begins recording vertices for a shape and
- endShape() stops recording. ]]
- --[[ You will see the use of 'key' in most p5lua advanced methods.
- It is used for p5lua to interpret what object you are trying to access.
- (The key must always be a string.) For example, if I want to create a
- new shape, I must create my key in the beginShape() method.
- Then use that same key to add vertices with vertex(), or
- end the shape with endShape(). ]]
- -- Here is an example of the usage of 'key':
- p5:beginShape('Shape1') --[[ This creates a new shape
- with the unique key 'Shape1'. ]]
- p5:vertex('Shape1', 100, 500) -- Adding vertices to 'Shape1'.
- p5:vertex('Shape1', 200, 550)
- p5:endShape('Shape1') --[[ This will connect all the vertices.
- (Therefore drawing the shape.) ]]
- p5:createSlider(key, min, max, start, pos, w, color, textcolor, decimalPlaces)
- --[[ The p5lua createSlider method can appear a bit confusing with all
- the parameters, but it is actually very simple.
- (some parameters are optional such as:
- color, textcolor and decimalPlaces)
- - 'key' is used to store and grab the value from your slider.
- - 'min' and 'max' are self explanatory, they are the
- minimum and maximum values your slider should go to.
- - 'start' dictates what value the slider starts at.
- - 'pos' dictates what position the slider is on the screen.
- - 'w' (short for width) is how wide/long the slider should be.
- - 'color' the color of the slider button.
- (by default set to Color3.fromRGB(71, 161, 202))
- - 'textcolor' the color of the slider value text.
- (by default set to Color3.fromRGB(255, 255, 255))
- - 'decimalPlaces' if you would like the slider value to be rounded.
- (by default set to 1)
- ]]
- -- Here is an example using the createSlider method:
- p5:createSlider('Red', 0, 255, 0, Vector2.new(200, 400), 100, Color3.fromRGB(255, 0, 0), Color3.fromRGB(0, 0, 0), 0)
- -- Use your key to index the correct value in the p5.Values table.
- p5.Values['Red']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement