 Does that work? Yes. OK. Yes. Good afternoon. My name is Regina Henshel. Welcome to my talk about multicolor gradients in macros. I assume that you have already written a macro who has already used gradients in macros. Awesome. The talk focuses on things which are new. But a library attached to the presentation file contains parts to which are not specific to multicolor gradients. And that part will help you in case you have not used gradients yet. In addition, I have uploaded a library which contains a lot of snippets about gradients, which will help you too when you go to write your own extension about with multicolor gradients. OK. Let us go again. Multicolor gradients are new in 7.6. When you implement a new feature, there are a lot of areas affected. There is a core part with filter and rendering and core modeling that is part of Armin. You can listen to his talk tomorrow. I will talk tomorrow about the file format. And now we are in the RP how to use them in macros. Unfortunately, we have not yet a user interface for multicolor gradients. So when you will use some predefined ones, you really need either use macros or edit the file format. The presentation shows you one example how to do that. That is a lot of code. The slides show only a part of the code. For those who want to have a larger view on it, I have printed them. I move them to sample. OK. Besides that, the code has emphasized parts. And you should focus on them. And do not try to read complete snippets. This is a slide I have used to take screenshots, which you will see in the next slides. It is a slide which has a background with a gradient. The light here is not so good for that gradient. OK. When you work with macros, there are other development tools. And they are a great helper when you're writing macros. So first step, we look how gradients can be seen in the development tools. When you start the development tools, you have on the left side the objects. And for this part, we need the master slides. And our example, which I showed you just. Then on the right side, you have a tab with properties. And in this properties, you will find the background of this slide. When you expand it, you get a long, long, long list of properties of the background. And you should scroll down to the fill properties. The fill properties are here. And here you will see the fill style. That tells you that actually a gradient shall be used. Then you have a fill gradient name. In this case, a submarine. That tells you what gradient to be used. When this gradient name property is empty, there is no gradient actually used. The gradient are listed in a gradient table in the document. And this table has a name access. So this name submarine is a link into this table. That is not new. That is the same with the existing gradients we already have. And here we have the gradient definition itself. And when we open that, we have the first difference. We have no longer gradient, but now we have a gradient 2. Gradient 2 is an extension to the gradient. We have a lot of properties already in gradient. They stay the same. But we have got a new property that is here, the colostops. The colostops is a sequence of notice that it is a plural. And each item is a colostop. When you expand it, you see a colostop is new too. That's a new part in the arping. It has two components. It's a struct with two components. One is a stop color that gives you, as this name says, the color. And the second one is a stop offset. This part of the properties describe the color transition from which the position is relative. It goes from 0 to 1. And this stop offset says, well, the color is located. In this case, we have a color at the start and a color at the end. And when you see this, you have surely an idea how we get a multicolor. We simply introduce more of these colostops. So multicolor gradient could be we have at offset 0, we have a green. At position dot 6, we have a yellow. And at position 1, we have a red. We have a multicolor. We will use this example, this gradient, and see how we can create it using a macro. The example I show you here is I have written a sine color gradient to selected shape. It has four steps. First, I select the shape. The next, I build the gradient. Then I add this gradient to the gradient table. This is a collection I have mentioned. And that gives me a name, a new name. And then can I assign this new gradient to the shape. In this four steps, only this step is new. The other steps would be the same for the current gradients. So we look at this new part. I have structured this new part into three steps. We look how we define the color. We create the colostops and from them the complete gradient. First, the colors. I said the colors are in a stop color, but we now need to look a little bit deeper into it. Such a stop color is an RGB color. You might not have used it in your macros. It has a blue, green, and red component. But in contrast to the usual way where you describe the color channels was values from 0 to 255, these values go from 0 to 1. It's a simple division to get these values. And this converging, I have put into a function createDessColor. The time will likely change when the gradients will become able to use theme colors. For a theme color, you need to have reference to the use theme and color is then given by a name. But that is not essential for such macros. You only need a different converter that puts what you have as this color description into numeric values. The definition itself is clear. The function is written in that way that you give the three color channel values as you can see them in the peak of color dialogue. And then I have here defined a start color and between color and the end color. That's the three colors. OK, now we create the color stops. This color stops is the quents in the API. That becomes an array in basic. That is here. Remember, we have here basic error. The two is index from 0, 1, and 2. When you assign the color stop to the array element, you need two steps. The first one is you create the struct, which is the color stop. You have to assign the stop color and the stop offset. And in the second step, you assign this complete stop to the array element. When you do that, you need to be careful that your stops are ordered in increasing in the offset values. You may use the same offset for two colors, but you may not go back, go lower. We need these two stops at the same offset position to get a hard color transition. Oh no, the last step, we create the actual gradient. Here's just again the screenshot from the developmental, so that you see where we are. When you look here, you see what belongs to this gradient, too. All great parts already exist in gradient. The really new part is emphasized in blue. We have this new component, and we assign the color stops we have just defined. I have used a worth statement because here is worth to use it. It is really a lot of properties which belong to it. Important is this one, too. The existing gradient has a start color and an end color. On to get better interoperability with backwards compatibility, it's you should set the start color to the color of the first color stop and the end color to the color of the last color stop. To do that, you need a converter again because a start and end color are data type long, and you need to convert it, but that is the easy part. It's this function to do that. I think we try it out. For that, I have to leave the presentation because the macros are written that I work with a selected shape and that is not in presentation mode. So what to do? Here we are. You don't see that. That should work. I think. Okay, try it again. I select the shape and then you can press Alt-F11 which brings up the dialogue for macros. On the left side, you select where the macro is. In this case, it is inside the presentation file. And here is the library which belongs to it and during the main and here the macro I have explained. And now I can run it. Can't you see? It's a nice, hopefully nice, green, yellow and gradient. Okay, I guess I need to... So we can go forward. Yes, we have not only color gradients but we have also transparent gradients. Fortunately, it's not very different. The gray is encoded as gray so you can use all what you have learned about color gradients for the transparency too. That means you have only make sure that the three color components have the same value and then you get the transparency. A little bit different is the table. The document has a separate table for transparency gradients and has separate properties for transparency. What you can try is... 5 minutes, okay. I will try it. Here we go the other way around. I first show you what such a transparent gradient can do. We select the shape and then we do 11 and now we make transparency and the solid white fill is a party transparent. You have at the outer edge you have a semi-transparent value that goes to no transparency and then it is an area where it stays, no transparency and then we have a heart transition to full transparency. Let's go on here. Here you see how the color values correspond to the transparency. You simply divide it to 255 and interpret the depth as percent for the transparency. That are the three steps and here you can see the areas. It goes from 0 to 3, the gradient which goes to solid. Then we have area which stays solid and here we have stops with the same offset that is the heart transition and it remains on full transparent to the end. What is new? We have gradient 2, we had gradient stops. They need to be ordered. We have color stop is new with a stop color and a stop offset and you need some converters. What you still need is a gradient table or a transparent gradient table of the document and you still need the fill properties of a shape or the background properties of a page. Okay, that's all time for questions. No question. When you came to questions later on that is my contact and I will be at Hackfest on Friday. I think that's a good place when you have questions about these macros. Thank you for listening my talk. Have a nice time at the conference.