> *I would not use the scale functionality as it applies to the whole 
canvas. *

Whatever works for your project is best, however, the scale only applies 
when you set it.  And you can always reset it.  Eg:

// Save the current state
context2d.save();

// Apply zoom
context2d.scale(xxx, xxx);

// Draw zoomed stuff
...

// Reset the zoom
context2d.restore();

This also lets browsers use the GPU to render (although, I'm not actually 
sure if the scaling is done on the CPU or the GPU).

On Friday, 7 February 2025 at 5:02:17 pm UTC+11 Leon Pennings wrote:

> I would not use the scale functionality as it applies to the whole canvas. 
> I'd prefer to apply an adapter pattern for determining actual coordinates 
> on the canvas. 
> Then you can still have a toolbar, location display or slider for the zoom 
> factor in it's normal proportions and just have the actual content you want 
> to show in a different scale. 
>
> Op donderdag 6 februari 2025 om 13:33:12 UTC+1 schreef Colin Alworth:
>
>> No problem - I wanted to be sure I didn't make a mistake, since I haven't 
>> myself used canvas "in anger" in many years, and only loosely keep track of 
>> resources and advice on it.
>>
>> SmartGWT's "Draw" examples make the API look very similar to the GXT 
>> "draw" packages - it isn't really a raster API at all, but a vector API 
>> that just happens to be built on top of a canvas implementation. 
>>
>> My recollection is that for fewer than around 1k-10k drawn items, SVG is 
>> faster and simpler to understand than canvas, and canvas's benefits only 
>> start kicking in when the DOM gets too heavy to manipulate quickly each 
>> frame. Looking briefly at the example page you shared a few weeks ago, if 
>> you were interested in getting into the low level details of how to do the 
>> drawing, your case perhaps could stand being remade in plain SVG - always 
>> high resolution. The benefits may be mostly for your own understanding 
>> rather than any real observed performance improvements from running the 
>> page (that said: dropping SmartGWT would appear to drop almost 8mb of JS 
>> out of your 9+mb page).
>>
>> On Wednesday, February 5, 2025 at 9:46:51 PM UTC-6 
>> [email protected] wrote:
>>
>>> > Neil, I'm not sure where I appeared to have said that.
>>>
>>>  
>>>
>>> I am sorry, I did not intend to put words in your mouth.
>>>
>>> That was my understanding from your previous email stating
>>> that  canvas is a raster format.  I misinterpreted your statements.
>>>
>>>  
>>>
>>> I apologize for that.
>>>
>>>  
>>>
>>> Thank you,
>>>
>>>  Neil 
>>>
>>>  
>>>
>>> --
>>>
>>> Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
>>>
>>> We offer 30 year loans on single family houses!
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/6e8eda4e-0e45-4d69-9ee8-4c6c1ae9fb2an%40googlegroups.com.

Reply via email to