Changes between Version 13 and Version 14 of IconTutorial


Ignore:
Timestamp:
Dec 29, 2007, 8:07:16 PM (17 years ago)
Author:
cinc
Comment:

Explanation of context saving and scaling

Legend:

Unmodified
Added
Removed
Modified
  • IconTutorial

    v13 v14  
    240240Where is the second overlay image gone?
    241241
     242It's actually still kind of there but you can't see it because it is scaled two times by 0.01 and thus won't be painted anymore (it's size is smaller than a single pixel). The reason is the way scaling (and positioning using the ''<transl>'' command) works. The scaling is applied once to the drawing context and will work on all subsequent paint commands. The same goes for the translate command which moves the current drawing context in space. So the first scale command resizes all the following images by 0.01. The second scale comand resizes again by 0.01 for the then following images (that is !OverlayImage2). The scaling also influences the translate commands which are also global.[[BR]]
     243So to get the same icon as before the commands has to be like the following.
     244
     245{{{
     246   Key name: CairoCommands
     247   Data:     <ctxt>save</><transl>0 0.2</><scale>0.01 0.01</><imgkey>OverlayImage # 1</>
     248                          <transl>40 10</><imgkey>OverlayImage2 # 1</><ctxt>restore</>
     249}}}
     250
     251Note how the second scale command is removed and the values of the translate command are increased bei 100 to compensate for the very first scaling. Additionally the values of the second translate command are offsets added to the first ''<transl>0 0.2</>'' because both translate commands work on the second overlay picture.
     252
     253Calculating the correct factors and offsets may become tricky when using a lot of commands so the ''<ctxt>'' command comes in handy in the end. Interpreting the command string and assembling the final icon may use slightly more time for the longer sequence but this only happens once when loading the icon and thus doesn't cause much harm.
     254