It looks like you're new here. If you want to get involved, click one of these buttons!
i am a beginner and i am trying to make a code in which you can draw. I can get it to draw by making it place ellipses where ever I touch but I want to be able to make the drawing size bigger and smaller and change the color without the spot I lifted my finger to get larger or change color. I know its confusing so I'll give you what I have so far.
function setup()
x = 100000
y = 100000
parameter.color("Color", color(255, 0, 0, 255))
parameter.integer("Size", 0, 150, 20)
backingMode(RETAINED)
end
function draw()
fill(Color)
ellipse(x, y, Size)
end
function touched(touch)
x = touch.x
y = touch.y
end
Comments
@Joey72099 A easy way of not allowing the spot to get bigger would be resetting the x and y.
Example:
Easiest way is to use a table.
EX: in setup define the table:
spots = {}
in draw you draw the stuff in the table:
in touched you store touches in the table:
table.insert(spots, {x = touch.x, y = touch.y, size = Size, colour = Color})
Hope that helps. (Just remove the code you have in draw and use this instead)
If you need/want an explanation of how it all works, feel free to ask
P.S. @Prynok, how does that solve the problem?
@JakAttak It does not seem to be working for me. What should I get rid of from my original?
@JakAttak @Prynok I'm pretty sure that Prynok's idea works but I think in the long run as a new programmer I'm going to want to better understand tables and the stuff that JakAttak's using so I still want to hear your idea JakAttack but thanks for the script Prynok
@Joey72099, i may have misunderstood what you wanted to do...
But try this:
@JakAttak Can you explain how this works to me
and would there be any way to keep it from making separate circles instead of a single line if you go to fast across the screen or is that just a processor thing or something like that that just can't do that many circles a second
@Joey72099 - it sounds like you may need to do a few tutorials before going any further. You'll find them on the wiki link above, along with some ebooks. I recommend starting with Lua, the language behind Codea.
We don't have the resources to do 1:1 training in the forum, unfortunately.
@Ignatz ok
The line in setup:
spots = {}
initiates a table and stores it as variable spots.The code in draw is called a for loop. It goes through everything stored in the table spots and draws a circle using the info stored.
The code in touched stores the info of the size, colour, and placement of the dot everytime you touch the screen. This is permanent, allowing you to change the Size and Color without overwriting already draw dots.
@JakAttack He asked
"I want to be able to make the drawing size bigger and smaller and change the color without the spot I lifted my finger to get larger or change color."
So I gave him a easy solution, so instead of the touch always being in the last place, causing the above problems, it resets itself back to the original position.
@Joey72099, I think you should look at the
backingMode(RETAINED)
function. Here is a small demo I whipped up:Joey72099 Is this kind of what you're after. Change the size and color for each draw.
@Jordan So does the clear button make everything the background color or does it get rid of the writing?
@Jordan @dave1707 both of these work great thanks so much for the help