stevon8ter's color picker [FINISHED]

Hello there,
I was wondering if it’s possible of creating a circle with multiple colors, maybe through meshes…?

I already found out how to create a circular mesh…

and I also found this

Tho I think it’s not circular enough, like you can see the stripes…
(no offence @SkyTheCoder, that’s still a beautifull piece of code)

Thx in advance

What do you mean by stripes? I used sine and cosine with radians in a for loop, so it’s as circular as it gets.

It doesn’t use a mesh, and I’ve been thinking about making one using a mesh, though.

@stevon8ter. you mean multiples colors in one circle or diferents colors for each circle?

@Luismi, I mean like how it’s shown in the other topic :wink: like a color picker…

@SkyTheCoder, well it’s just that you can see that it’s not 100% circular (well it is, but it’s not 100% smooth)

But it could be i needn’t it anymore, as I just made a hexagon, and it isn’t looking bad, so I might use that one

@stevon8ter ok . I think @loopspace project called 3D demostration help you.

his figures in this case are cubes, have a contrast of colors, not if if you mean that :slight_smile:

@stevon8ter Those hard edges are pixels… I could blur the edges, but in my opinion that’s ugly. I like a nice, clear image.

ok lads, I finally made some progress, this is a very early version, and I still need to do alot of improvements, but I’m still welcoming feedback and critisism

and yes i know the square’s colors aren’t how they should be… but I can’t seem to get the colors right, or I should add some extra triangles to that mesh…?

@stevon8ter I like it. The only thing I have a problem with is when I’m moving the small circle into the corner of the square, I hit the outside area which then moves the larger circle to that area. Maybe the square should be a little smaller so there’s more room between it and the outer area.

@dave1707 yeah I should probably do that, but I also gotta add that once you press the square for example, and then move outside, you still have the ‘cursor’ thingy there selected untill the touch is ended, like the native codea color choser, so you can drag it around etc, also another thing I gotta do is make it so that the hexagon thing can only be moved in the center, if you get what i mean, … like that the circle thing’s always in the center of it, that will also remove another bug at the same time (try doing it to the corner of the blue, sometimes the color then changes to black…

@Jmv38 Does it run at 60fps all the time? On mine then it drops to about 30fps when new touch data comes in (due to the image:get - when I comment out that line then it runs at 60fps all the time).

There’s no code yet for the square.

  • it didnt freeze. I just couldnt stop it.
  • it runs 60hz.
  • but only the ring works, the selection inside the square does not move

Hmm i added an fps watcher, and it slows the code to 30fps, and that’s on an ipad 3, does anyone know how this could be? Are it the calculations for the triangle, or are there to much meshes (I don’t think so, alot of apps use more meshes, i only use 14 triangles for every color chooser…)

@stevon8ter is this while touching the colour picker? If so it’s because of a constant use of img:get(x,y) every frame, you could make it so this is called every other frame, I’m not sure if it will make much of a different to the performance…
To make it get called every other frame make a new variable called Switch and set it to ‘true’.
Then in your draw function type Switch = not Switch
then use this if statement

if Switch then
 colours = img:get(x,y)

I don’t the above is great practice but it might help… Also you don’t want to be drawing to the screen every frame using img:get(x,y). You should store this as a colour variable when touching the screen, you can check this by setting a variable to true in the colour picker touched function then when the touch ends set it to false, then use that variable in the draw function around img:get(x,y) that should improve the speed a lot.

@Luatee, I had already changed the draw event so it doesn’t use the getcolor, I’ve put it in the touch function, tho it’s around 30 fps even when not touching, touching doesn’t really lower the fps…

@Luatee, ok nevermind, I forgot to change something in my code, but I fixed it, now it runs at 60fps, tho when touching it drops to 35, but I think that wouldn’t be that much of a problem since there shouldn’t be to much to do when choosing a color

Edit: i figured out how to increase the fps when touching :wink: but that will be something for tommorow, going to bed now

Ah, did you spot that you were drawing the same mesh onto the image every draw?

@Andrew_Stacey yes that too :wink:

Ok so my colorpicker didn’t freeze? :slight_smile: @Jmv38

just wanna know that because I need feedback for inprovement and troubleshooting, also, which ipad are you on and how much fps does it give you? (iirc you’re on ipad1 so yeah I wanna know how it runs there as well :wink: )

Actually i didnt remember the 3 finger tap! Thanks for reminding me that!

@Luatee @SkyTheCoder I think @Jmv38 knows that already but it somehow froze… idk what the problem would be though, for now I haven’t had a freeze when using my code