How to apply different gradients to same text in pixi.js? - gradient

Task: I have single text, which is wrapped in two lines and each line should have its own gradient. Separating text is not allowed. It needs to look like this:
I tried using  fillGradientType: PIXI.TEXT_GRADIENT.LINEAR_HORIZONTAL, fillGradientStops:[0.0, 0.4, 0.6, 0.7, 0.9], but it resulted in:
How can I apply separate gradient to two lines of same text without dividing it?

I've submitted a PR to PIXI which gives you this functionality via a new gradient style, TEXT_GRADIENT.LINEAR_VERTICAL_NOREPEAT
Check out https://github.com/pixijs/pixi.js/pull/4016 for to track its progress and for examples

Related

swiftUICharts lIbrary creating a LineView with SwiftUI

Using an Example of SwiftUICharts, I have used the following, to create a line chart:
**LineView(data: [8,23.5,54.8,32,12,37,7,23,43])**
And it works very nicely:-)
However I want to plot x,y rather than just y values
I have tried
Code Block
LineView(data: [1,2,3,4,5,6,7,8,9], [8,23.5,54.8,32,12,37,7,23,43])
(With and without the comma which separates the 2 bracketed “terms”)
And
LineView(data: [(1,8),(2,23.5),(3,54.8),(4,32),(5,12),(6,37),(7,7),(8,23),(9,43)])
All gave errors
Any idea how I should present the data to obtain the x,y line graph?
TIA,
Phil.

Make part of a line dashed in chart.js

This is my goal:
a line graph where for x<10, the line is dashed, and for x>=10, it's a solid line.
I know one way to do it is to have two datasets, one with null values for x>=10, and another one with null values for x<10. However, this solution seems too hacky and also at the joint point (x=10), the tooltip will show two lines.
Is there any way to do this in a clean way?

Text wrap with box in Basemap

I'd like to write some text on a world map pointing to several locations. The text to be written for each location is short, a few lines, with one or two words/numbers (i.e earthquake magnitude, location, date). Is there a pythonic way to perform this?
Since matplotlib-basemap is based on matplotlib, you can simply use
plt.text(x,y,'yourtext')
to write text onto your map. If you want to have it boxed, add something like:
plt.text(x,y,'yourtext',bbox={'pad':10})
See also http://matplotlib.org/users/text_intro.html.

Formatting text in R Shiny

I am developing an application in R Shiny. One of my modules in the application, displays dynamic text depending on user inputs. I would like to display the text as bullet points and additionally would like the text in "strong" or "heading" format. I can do this individually but somehow I am not able to figure out how to combine the 2. So assuming that my function returns a character vector a, with 2 components that I need to display, I can do the following:
HTML("<ul><li>",a[1],"</li><li>",a[2]) #To generate bullet points
HTML(paste(h4(a[1],a[2],sep=''))) #To concatenate and change format to heading
Now my question is - How can I do both (display as bullets with heading format)? I tried different combinations but it's not working.
Secondly, how do I change the colour of my text?
Any help will be greatly appreciated.
Thanks!
To get a bullet list with heading format, you can just add an <h4> tag to the paste. Also, make sure you close all the tags you open, for ex:
HTML("<ul'><li><h4>",a[1],"</h4></li><li><h4>",a[2],"</h4></li></ul>")
You can use inline CSS to change the color, for ex:
HTML("<ul style='color:red'><li><h4>",a[1],"</h4></li><li><h4>",a[2],"</h4></li></ul>")
More info here.

GTK TextView - creating a static display format

I am trying to simulate a piece of hardware, and this hardware has a static ribbon display.
to do this, I'd like to use a TextView. My display has 10 rows, with 25 columns. So I figured that a TextView should be easy enough.
basically, I would like to be able to say "insert/replace string S at row X, starting at column Y". i may need to only update a specific row, or even a single column within a row.
I have not been successful at getting this to work though. the best I have been able to do is to fill the TextView with 10 lines of 25 spaces when i create it, and then use the get_iter_at_line_offset to get the iterator of a line, and then push the new text onto that line.
but this will start appending text to the line, rather than replacing the existing one.
I need both row and column control (i.e. need to be able to set text at a specific (X,Y) coordinate).
I'm assuming this is somehow possible using marks.
Can anyone give me a quick example of how i can do this? Unfortunately, there isn't a whole lot of documentation on this sort of thing.
You'll have to get an iter at a specific line, row X, and then use the iterator's forward_chars() method to move forward Y characters. Then delete the number of characters you are replacing, and finally insert the text you want to insert. You can do it all with iterators, I think - iterators are invalidated when you change the buffer, but when you delete text, one of your iterators is revalidated to point to the place where the text was.
If you're targetting GTK+ 3.x, you should really look into using Cairo. Since you don't actually need a text buffer, it seems like overkill and a bit of a mis-alignment to use the GtkTextView.
Look at the very basic introduction on how to draw with Cairo in GTK+. Then look at the text-rendering Cairo APIs, that should be enough to get you started.