This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Maccraft123's profile picture

Filling empty spaces in drawing math functions

Started by Maccraft123, 29 July 2018 - 09:05 AM
Maccraft123 #1
Posted 29 July 2018 - 11:05 AM
Hi,
I made small program which draws math fuctions
But I ran into problem:
Not displaying properly function when difference between old Y and new Y is higher than 1.
I tried
Code is in attachment
Screenshot also

I program on bigger screen becouse better view than 51x19
Bomb Bloke #2
Posted 29 July 2018 - 11:43 AM
Code is in attachment
Screenshot also

Nope: you might've noticed the attachment system didn't let you upload anything.

Screenshots need to be hosted offsite, using a host such as imgur. You might also use pastebin for your code.
Exerro #3
Posted 03 August 2018 - 09:42 PM
Is your issue having something like this?


To get around this, you could draw a column of pixels up until the next Y coordinate. Something like this:

for y = currentY, nextY, currentY < nextY and 1 or -1 do
    drawPixel(currentX, y)
end

However what I'd do personally is generate a list of points (x, y coordinates) and then draw lines between those points using paintutils.drawLine or your own function.
Spoiler

--# define your function 'f'

local points = {}

for x = 1, term.getSize() do
     points[x] = f(x)
end

term.setBackgroundColour(colours.blue)

for x = 1, term.getSize() - 1 do
    paintutils.drawLine(x, points[x], x + 1, points[x + 1])
end