Sudha247 / ocaml-joy

MIT License
22 stars 14 forks source link

Add functions to set colors using RGB values #46

Closed nangahamandine closed 7 months ago

nangahamandine commented 1 year ago

Add new functions for custom color creation as follows:

Modify existing functions for custom color usage For example, set_color : color -> unit - The set_color function is modified to accept custom colors so it will enable users to set the current drawing color to the specified custom color.

Mankavelda commented 1 year ago

Sounds interesting @nangahamandine I can work on this

nangahamandine commented 1 year ago

Sounds interesting @nangahamandine I can work on this

Oh I am already working on this

Sudha247 commented 1 year ago

@nangahamandine Thanks; this is undoubtedly a helpful feature. Let's try to keep the API clean of stateful elements. That means specifications should apply only to a shape and shouldn't alter how subsequent shapes behave. We don't need to expose the RGB function to the user. RGB could be an optional parameter for creating shapes. Another way to create colours is not needed at all. RGB in itself is quite versatile, so let's drop the hex codes.

To give you an idea of what must happen; get an optional argument for setting color while creating a shape. For example

val circle: ?x:int -> ?y:int -> ?stroke:(int, int, int) -> int -> shape

let black_circle  = circle 50 in
let red_circle = circle ~stroke:(255, 0, 0) in
show [black_circle; red_circle] 
nikochiko commented 1 year ago

Should we have stroke and fill instead of colour to avoid confusion on whether colour will change the stroke color or fill color?

On Tue, Oct 17, 2023, 1:30 PM Sudha Parimala @.***> wrote:

@nangahamandine https://github.com/nangahamandine Thanks; this is undoubtedly a helpful feature. Let's try to keep the API clean of stateful elements. That means specifications should apply only to a shape and shouldn't alter how subsequent shapes behave. We don't need to expose the RGB function to the user. RGB could be an optional parameter for creating shapes. I don't think another way to create colours is needed at all. RGB in itself is quite versatile, so let's drop the hex codes.

To give you an idea of what needs to happen; get an optional argument for setting color while creating a shape. For example

val circle: ?x:int -> ?y:int -> ?colour:(int, int, int) -> int -> shape let black_circle = circle 50 inlet red_circle = circle ~colour:(255, 0, 0) in show [black_circle; red_circle]

— Reply to this email directly, view it on GitHub https://github.com/Sudha247/ocaml-joy/issues/46#issuecomment-1765878498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI7MKYJTLAGWGNUCMQT3X5LX7Y3LBAVCNFSM6AAAAAA6BIFPAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRVHA3TQNBZHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Sudha247 commented 1 year ago

Yes, that makes sense. Edited my comment above ^^

nangahamandine commented 1 year ago

@nangahamandine Thanks; this is undoubtedly a helpful feature. Let's try to keep the API clean of stateful elements. That means specifications should apply only to a shape and shouldn't alter how subsequent shapes behave. We don't need to expose the RGB function to the user. RGB could be an optional parameter for creating shapes. Another way to create colours is not needed at all. RGB in itself is quite versatile, so let's drop the hex codes.

To give you an idea of what must happen; get an optional argument for setting color while creating a shape. For example

val circle: ?x:int -> ?y:int -> ?stroke:(int, int, int) -> int -> shape

let black_circle  = circle 50 in
let red_circle = circle ~stroke:(255, 0, 0) in
show [black_circle; red_circle] 

Okay, understood. I'll stick to the functions for RGB values

nangahamandine commented 1 year ago

Thank you for the updates. I'll employ the necessary changes.