Author Topic: Color of image_button  (Read 2696 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Color of image_button
« on: July 25, 2019, 01:46:17 PM »
Hello everyone.

Is there a way to get the current colour of the image_button tile then toggle the colour to a new different one?
Thanks in advance.

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Color of image_button
« Reply #1 on: July 25, 2019, 02:09:27 PM »
What version are you using?
Newest versions use PNG files with transparent backgrounds.
https://www142.lunapic.com/editor/ does a nice job of converting an image to PNG and setting transparent background.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Coder

  • Swamp Rat
  • Posts: 827
Re: Color of image_button
« Reply #2 on: July 25, 2019, 02:14:39 PM »
Sorry I am not talking about image edit but the color of image_button tile from a dcl file.
http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-C1E7FFC9-065F-4975-B356-CF31474B6746

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Color of image_button
« Reply #3 on: July 25, 2019, 02:51:36 PM »
Quote
Is there a way to get the current colour of the image_button tile

No - the visual appearance of a DCL image/image_button is one-way: you can modify what is displayed, but you cannot query the properties of the tile to obtain information about what is currently being displayed.

Quote
Is there a way to toggle the colour to a new different one?

I would suggest initialising the image_button to a known colour (either in the DCL file or better yet, in your program), and assigning such colour to a variable which may then be referenced in the action_tiles statements for your dialog. Ensure the variable value is updated when you alter the colour and you can easily toggle the colour.

Coder

  • Swamp Rat
  • Posts: 827
Re: Color of image_button
« Reply #4 on: July 25, 2019, 03:24:13 PM »
Thank you Lee for your kind contribution.

I was thinking if the colour property of the image_button is obtainable then I would be able to avoid using a variable but it seems it is not as you already ensured that also.

Have a nice day.

efernal

  • Bull Frog
  • Posts: 206
Re: Color of image_button
« Reply #5 on: July 27, 2019, 02:18:20 PM »
Code - Auto/Visual Lisp: [Select]
  1. ;|
  2. teste:dialog{label="teste";
  3. :image_button{key="i";width=50;height=30;color=30;}
  4. ok_cancel;}
  5. |;
  6. (DEFUN c:teste (/ cor dh)
  7.   (SETQ dh (LOAD_DIALOG "c:\\lixo\\teste.dcl"))
  8.   (NEW_DIALOG "teste" dh)
  9.   (ACTION_TILE "i" "(SETQ cor (GET_ATTR \"i\" \"color\"))(ALERT cor)")
  10.   (PRINC)
  11. )
e.fernal

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Color of image_button
« Reply #6 on: July 27, 2019, 02:24:04 PM »
A good suggestion efernal, but be aware that get_attr will only obtain the initial value, not what is currently being displayed.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Color of image_button
« Reply #7 on: July 27, 2019, 02:48:31 PM »
'Toggling the color' has me confused. Are we talking about the fill_image function?

efernal

  • Bull Frog
  • Posts: 206
Re: Color of image_button
« Reply #8 on: July 27, 2019, 02:49:06 PM »
Code - Auto/Visual Lisp: [Select]
  1. ;;try this
  2.  
  3. ;|
  4. teste:dialog{label="teste";
  5. :image_button{key="i";width=50;height=30;}
  6. ok_cancel;}
  7. |;
  8. (DEFUN c:teste (/ cor dh put_cor)
  9.   (DEFUN put_cor ()
  10.     (IF (< cor 255)
  11.       (SETQ cor (1+ cor))
  12.       (SETQ cor 1)
  13.     )
  14.     (START_IMAGE "i")
  15.     (FILL_IMAGE 0 0 (DIMX_TILE "i") (DIMY_TILE "i") cor)
  16.     (END_IMAGE)
  17.     (ALERT (ITOA cor))
  18.   )
  19.   (SETQ dh (LOAD_DIALOG "c:\\lixo\\teste.dcl"))
  20.   (SETQ cor 1)
  21.   (NEW_DIALOG "teste" dh)
  22.   (START_IMAGE "i")
  23.   (FILL_IMAGE 0 0 (DIMX_TILE "i") (DIMY_TILE "i") 1)
  24.   (ACTION_TILE "i" "(put_cor)")
  25.   (PRINC)
  26. )
  27.  
e.fernal

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Color of image_button
« Reply #9 on: July 27, 2019, 03:39:35 PM »
Maybe my ImageButtonColorPrompt subfunction would be helpful.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg