Jump to content

Toggle display color with LISP


Recommended Posts

Posted

Thank you for returning with a feed-back! Have a nice day too! :)

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • fuccaro

    8

  • NoelStalker

    5

  • CADTutor

    1

  • hendie

    1

Posted

This functions for RGB AutoCAD bits translation can be usefull.

 

(defun RGB->Bits(RGB_List)
 (if(vl-every
      '(lambda(c)(and(< -1 c)(> 256 c)))RGB_List)
    (apply '+(mapcar '* RGB_List '(65536 256 1)))
   ); end if
 ); end of RGB->Bits


(defun Bits->RGB(Bits / r g)
 (if(and(< -1 Bits)(> 16777216 Bits))
 (list(setq r(/ Bits 65536))
      (setq g(/(- Bits(* r 65536))256))
      (- Bits(+(* r 65536)(* g 256)))
      ); end list
   ); end if
 ); end Bits->RGB

 

For example Magenta color (255 0 255) to bits:

 

_$ (RGB->Bits '(255 0 255))
16711935

 

And back Magenta bits to RGB list:

 

_$ (Bits->RGB 16711935)
(255 0 255)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...