Saving colors using NSCoder? - colors

How do you save (by which I mean encode and decode) colors such as ccc3, ccc4, etc using NSCoder?
It doesn't seem to be supported. The only way I've been able to solve it is to save ints, and then when I need the colors I generate them from the ints.
Is there a formal way to save ccc3, ccc4 colors using NSCoder?
ie, I want to save;
ccColor4B topColor;
ccColor4B bottomColor;
But there does not seem to be a way to encode them or decode them with NSCoder.
Thanks

It doesn't matter now, I will continue to encode/decode ints and then deal with the colors in my code.

Related

How do `Map<String, String>` get to know, the `String` endings in `MethodChannel` arguments

If dart and kotlin code communicate through binary(array of 8-bit integers (0-255)), then how does String end or even int end is represented in, or determined from binary sequence of bytes, is there some special charCode or something else.
Also is there a way to save a List<int> as-it-is to a file.txt, so it can be read directly to List<int> instead of serialization.
Please guide this new dev,
Thanking you...
Since Flutter handles the MethodChannel, in both the Dart side and Kotlin side, it can be allowed to have its own internal protocol to communicate between the native layer and Flutter. In theory they could use JSON but they are probably using something else based on the supported types and also making it more efficient: https://docs.flutter.dev/development/platform-integration/platform-channels?tab=type-mappings-kotlin-tab#codec
For saving a List<int> to a file, you need to determine how you want to encode the content in the file and then how you want to decode it. It can be as simply as just saving each number separated by comma or encode the list into JSON.
If your list of numbers can be represented with Uint8List or Int8List, then you can basically just save the numbers as raw bytes to the file and then read them again.
But List<int> is a list of 64-bit numbers and you should therefore determine how you want to encode this exactly.
For writing to files, there are several ways to do it but the specific way depends on what you exactly want. So without any more details I can just suggest you check the API: https://api.dart.dev/stable/2.17.3/dart-io/File-class.html

vtkOBJImporter color mapping for k3d

Following the code here, one can get granular vtkPolyData to pass to k3d in python. However I am currently assigning color to k3d like so;
def rgb2hex(r,g,b):
return eval("0x{:02x}{:02x}{:02x}".format(r,g,b))
#using the actors from [referenced code][1] to get the granular actors from .OBJ
col = actor.GetProperty().GetDiffuseColor()
rgb2hex(int(col[0]*255),int(col[1]*255),int(col[2]*255))
This is ugly and inefficient. vtkPolyDataMapper should be already handling the color, so there must be a way of doing this in a more direct way. How can one use the vtkPolyDataMapper to get a list of colors to pipe to the k3d.vtk_poly_data() color argument?
mapper = actor.GetMapper()
mapper.SetInputData(vtkPolyData)
VTK does not natively provide this formatting (0xrrggbb) for color. You always have to deal with 3-components floats or integers.

Jpos Generic Packager XML

Im currently working with Jpos and created an xml for a process that has the description
ASCII/Packed Maps/Unpacked Numerics/ Var Len
I The xml works correctly with this process. I now want to make a second one for a process that rather than Unpacked Numerics it uses packed Numerics but im not sure what jpos classes would do this.
Iv tried changing all the IFA_Numerics to IFB_numerics and IFA_LLNUM to IFB_LLNUM but that didnt work
What classes represent packed numerics???
So after looking through the process some more i found that it wants the length displayed not in binary so i needed to use the IFB_LLHNUM to indicate the datatype of the length

Print a variable with index (eg. x_1)

i am trying to print variables with indices.
The goal is to write something like:
x_1 + x_2 = 3 + 1 = 4
The problem is, that variables just like x_1 does not show an index. It shows the underscore itself.
/* works fine */
print(x_1)$
x_1;
/* Does not work */
ostream: make_string_output_stream()$
printf(ostream, string(x_1))$
get_output_stream_string(ostream);
Output of the code above
Converting "x_1" into a string destroys the underscore, but you need a string for the method printf().
Are there workarounds for this?
What to do here probably depends somewhat on what goal you need to achieve with this. Can you say more about the larger goal you are working toward?
In order to generate output which has typesetting instructions in it, you can call the tex or tex1 function to generate TeX output. If that needs to be displayed in a web page, I believe you can make use of the MathJax Javascript library. Sorry, I don't know more about MathJax.
You should probably write x[1] instead of x_1. Displaying x_1 with a subscript 1 is a convenience -- the rest of Maxima doesn't know much about it.
EDIT: There is also an add-on package to output MathML; there might be two such packages, I would have to check. If MathML could help solve your problem, I will look into it.

artist working with base 64

Hi Im fairly new to base64 code and could do with some info/help etc. I have recently used it while converting my photos into code as part of an experiment regarding my sculptures, I converted a photo into 152 pages of base 64 using an online converter, just to get started. I was wondering how I can reverse this, and also if I edited out some code would the image change or would it not convert at all!? Like I said I am interested in using this to help my experiments. thanks for any info .
Base64 decode functions will decode it. If you remove some of the base64 code it may not translate back into a valid image or translate into valid base64 code at all depending on how much you remove. Depending on how the image was originally compressed, it MAY give you something, but the results will be incredibly unpredictable... So you'll never know what the result of the change will be on the final product. Part of the base64 standard involves a padded width (which is why some strings end in up to 2 = signs).

Resources