I need some classes

boalen (fat line, ellipse), password (Textbox, that I have, but I need to replace every letter with •••••), many lines textparagraph with highlight by special words, integer (line, ellipse), THANK YOU ALL!

@TokOut Are you looking for a Password TextBox like this.

EDIT: Replaced original code with a class version.

function setup()
    rectMode(CENTER)
    showKeyboard()
    pw=passwordBox(300,500,150,50)
end

function draw()
    pw:draw()    
end

function keyboard(k)
    pw:keyboard(k)
end

passwordBox=class()

function passwordBox:init(x,y,w,h)
    self.x=x
    self.y=y
    self.w=w
    self.h=h
    self.rtn=false
    self.str=""
    self.per="*********************"
end

function passwordBox:draw()
    background(127, 224, 224, 255)  
    noStroke()
    fill(0)
    rect(self.x+10,self.y+90,self.w,self.h)    
    fill(255, 90, 0, 255)
    stroke(255)
    strokeWidth(5)    
    rect(self.x,self.y+100,self.w,self.h)    
    self.str=keyboardBuffer()
    if self.rtn then
        self.rtn=false
        hideKeyboard()
        showKeyboard()
    end        
    fill(255)
    if self.str=="" then
        text("Password",self.x,self.y+100) 
    else
        text(string.sub(self.per,1,string.len(self.str)),self.x,self.y+100) 
    end    
end

function passwordBox:keyboard(k)
    if k==RETURN then
        self.rtn=true
        print(self.str)
    end     
end

Thx

What about boalen and many-lines-text-paragraph?

You can use textWrapWidth to automatically start a new line at a given width (soft wrap). If you want to add a manual new line (hard wrap) you can use the new line character \ eg myString = "this string has a\ new line in the middle"

Or, you can use the [[ ]] literal string brackets eg:

myString = [[this string has a
new line in the middle]]

What is boalen (fat line, ellipse)? Boolean?

parameter.boalen()

parameter.boolean()

In the screen

@TokOut Here’s a simple Boolean button.

function setup()
    rectMode(CENTER)
    b=boolBtn(200,400,80,40)
end

function draw()
    background(40, 40, 50)
    b:draw()
end

function touched(t)
    b:touched(t)
end

boolBtn=class()

function boolBtn:init(x,y,w,h)
    self.x=x
    self.y=y
    self.w=w
    self.h=h
    self.val="false"
end

function boolBtn:draw()
    fill(0, 231, 255, 255)
    rect(self.x,self.y,self.w,self.h)
    fill(255,0,0)
    text(self.val,self.x,self.y)
end

function boolBtn:touched(t)
    if t.state==BEGAN then
        if t.x>self.x-self.w/2 and t.x<self.x+self.w/2 and
                t.y>self.y-self.h/2 and t.y<self.y+self.h/2 then
            if self.val=="true" then
                self.val="false"
            else
                self.val="true"
            end
            print(self.val)
        end
    end
end

Thx

@yojimbo2000, 1. Your code don’t work 2. And? I can create a new acount

@TokOut Here’s a class that allows you to key in a lot of text in a TextBox. Just key as much as you want, then press return.

function setup()
    showKeyboard()
    tx=txtBox(300,450,150,250)
end

function draw()
    background(40, 40, 50)
    tx:draw()
end

function keyboard(k)
    tx:keyboard(k)
end

txtBox=class()

function txtBox:init(x,y,w,h)
    self.x=x
    self.y=y
    self.w=w
    self.h=h
    self.str=""
    self.wrap=self.w-8
    self.strW=0
    self.strH=0
end

function txtBox:draw()
    textMode(CORNER)
    stroke(255, 41, 0, 255)
    strokeWidth(3)
    textWrapWidth(self.wrap)
    fill(178, 221, 223, 255)
    rect(self.x,self.y,self.w,self.h)
    self.str=keyboardBuffer()
    self.strW,self.strH=textSize(self.str)
    fill(0)
    text(self.str,self.x+5,self.y+self.h-self.strH)
end

function txtBox:keyboard(k)
    if k==RETURN then
        str=self.str
        self.str=""
        hideKeyboard()
        showKeyboard()
        print(str)
    end
end

Okay, this is my boalen class:

Boalen = class()

function Boalen:init(x, y, value)
    self.x = x -- Position X
    self.y = y
    self.value = value
    self.size = 22.5
    if self.value == true then
        self.elx = self.x + 50
    else
        self.elx = self.x + 2.5
    end
end

function Boalen:draw()
    strokeWidth(50)
    stroke(255, 255, 255, 255)
    line(self.x, self.y, self.x + 50, self.y)
    
    fill(225, 220, 0, 255)
    ellipseMode(RADIUS)
    strokeWidth(0)
    ellipse(self.elx, self.y, self.size)
end

function Boalen:touched(t)
    if t.state == BEGAN and self:hit(vec2(t.x, t.y)) then
    if self.value == true then
        self.value = false
    else
        self.value = true
    end
    end
end

function Boalen:hit(p)
    local r = self.x + 50
    local t = self.y + 5
    local b = self.y - 5
    local l = self.x
        if l < p.x
        and t > p.y
        and r > p.x
        and b < p.y
        then
        return true
    end
    return false
end

I made it at my own, what was I doing false? If I touch it, it doesn’t work. Can you explain my error

Do you have a touched function as well?

Suppose you have 2 Boalen objects

b1 = Boalen(1,2,3)
b2 = Boalen(4,5,6)

Then you need this to make the touches work in your class

function touched(t)
    b1:touched(t)
    b2:touched(t)
end 

This is the main function by me:

displayMode(OVERLAY)
displayMode(FULLSCREEN)
supportedOrientations(WIDTH)
    
function setup()
    boaly = Boalen(500, 500, false)
end

function draw()
    boaly:draw()
end

function touched(t)
    boaly:touched(t)
end

What I do is to put print statements in my code to see what is happening

For example, like this

function Boalen:touched(t)
    print("touch!")
    if t.state == BEGAN and self:hit(vec2(t.x, t.y)) then
    if self.value == true then
        self.value = false
    else
        self.value = true
    end
    print("change self.value to ",self.value)
    end
end

@Ignatz ERROR: Attempt to a concencate boalen value to 34: self.value

what line of code is that?

I have written print("Boalen: "… self.value)