curses.h functionality - adding new colors? - c

Assuming can_change_color() returns true, can init_color() add more colors outside the 8 initialized basic colors? Or only modify their RGB values?
Reading through the manpage I was under the impression it could only modify one of the 8 basic colors. But recently I came across some commented code which implied it could add colors beyond the 8 initial.
I haven't found any definitive documentation on this, does anybody know?

I love That Katie Loves Classi, actually this question was answered a bit ago on Stack Exchange. Feel free to read that and enjoy!

Related

How can I create a bitmap and draw it from an array of pixel colors in Xlib?

I tried following many questions and answers online on this topic but I was never able to draw the buffer to the screen in a form of an array. I found people were creating visuals but I have no idea if I need to do that, or I can just use DefaultVisual() to get it. I found on a post online that the format of the pixel data has to be BGRX. Is the X in BGRX supposed to be the current X coordinate, or will it just be ignored? How do I create the image properly? How do I draw it after that? Do I need a pixmap for this? I am sorry for asking so many questions but it is very difficult to combine information I found on the internet to actually understand how it works and how I can do it. Some use a depth of 0, some use a depth of 24, some supply 0 or NULL as the size in bytes of one line on the window. I get mixed information on this topic. (I might edit my post tomorrow and include the code that is not working.)
Any help would be appreciated!

How to use arrays/lists and loops in Python

Ok so this is my first question here. I am currently an IT student and I am taking a fundamentals of programming class. I seem to be spending more time lost and confused than I feel as if I should. We are using Python as the programming language. The topic for this week is arrays and lists. From what I have gathered through reading many other forums, Python does not use array but lists. Therefore the assignment does not make since to me. Any help or guidance would be greatly appreciated.
Create a FLOWCHART and a STORYBOARD for each problem.
Use the information below to create a storyboard (which can be a text based description for solving the problems) and a flowchart (using flowchart symbols to illustrate how you would program) to solve each problem. You may use Microsoft Word® for your Storyboard and Microsoft PowerPoint® for your flowchart.
Problem 1: Create an array that contains the days of the week.
Problem 2: Create a loop to print the content above.
So what would the flowchart for this look like? The assignment next week builds on this by actually writing the program in Python. What would the script look like? Thanks for any help.
This is just for hinting, I won't write your program for you. In your comment, you assigned to the list (you're right, they're not called "arrays" in Python) correctly. Now you need to iterate over it to print each item individually. I'd suggest you refresh your memory in the Python Tutorial on how to control program flow, especially the for statement. Remember, the general idea is:
for item in collection_of_items:
do_something_with(item)
days = ['monday','tuesday','wednessday','thursday','friday','saturday','sunday']
for day in days:
print(day)
Edit:
what would the flowchart for this look like?
This problem is quite simple, try to make your own flowchart. Try to practice thinking at the very first lesson of programming course.
What would the script look like?
It would look like above code. But you can do it better and more professional, try to figure it out.

PDF: how do I find how much space will the text occupy when rendered?

I am writing a little PDF library in C. When generating PDF source code that is responsible for rendering text, I need to know how much space the rendered text occupies in order to render the next paragraph correctly.
How do I find out?
Thank you!
The mechanisms and math of PDF text rendering are exhaustively explained in the PDF specification ISO 32000-1. Most important are chapters 8 Graphics and 9 Text.
Essentially you need to know the current graphic state (which should be easy because you after all are the one who creates the PDF) and the metrics of the font you use and then calculate.
Most of these details are governed by the operators and calculations described in chapter 9 but one should not forget the current transformation matrix described in chapter 8.

JFreeChart: Increase Size of Data Point

This question was already asked here, but unfortunately the pointers provided in the answers are not working (the JFreeChart Forum is down).
My question is: Using the JFreeChart library, how can I increase the size of a data point in a time series scatter plot?
Thank you!
You can use the methods of ShapeUtilities, some of which have a parameter that affect size. There's an example here. See also DefaultDrawingSupplier for details of how createStandardSeriesShapes() works.

FizzBuzz comment that confused me - are hard coded conditions wrong?

I discovered the "FizzBuzz" question today at coding horror. Great article. However, something in one of the user-comments confused me -- here's the quote:
Geez guys - EVERY ONE of you who gave
example code - EVERY ONE - hard coded
the FIZZ and BUZZ conditions...
It sounds to me like this poster is ridiculing people for "hard-coding" conditions, ie :
if(i % 3 == 0)
...
What is point the poster is trying to make? Is there another way to specify conditions in a program?
Thanks for taking the time!
Dan
the FIZZ and BUZZ conditions...
The point of Fizz Buzz is to quickly weed out non-programmers, not find the best programmer. Any reasonable function that meets the specification is acceptable for this test.
If you don't hardcode, great, you extra-pass. But, that doesn't get you out of the hard questions that are following. I usually increase the difficulty with each question, but I don't want to waste time if the candidate totally can't answer simple questions.
There's nothing wrong with hardcoding some conditions.
In the context of an interview, when I know that I'm coding FizzBuzz.java and not Enterprise Fizz Buzz with a database and 1000+ simultaneous users requiring five-nines uptime, it's ideal to hardcode these conditions.
Entry-level programmers, the ones you ask FizzBuzz at least, are to follow specifications and make solutions as simple and elegant as possible. If you're an agile software house, including such features goes against YAGNI and should be discouraged. If the interviewer doesn't ask the ability to use other factors besides three and five, then it wasn't in the spec and therefore isn't needed.
It's meant as a joke.

Resources