objective c - Drawing line on a CALayer in OSx -
i know if can me painting on layers.
the situation this
i programming on kind of screen http://multitouch.com, 12 touches simultaneously. in app developing, can manage multiple images. can rotate, scale move @ same time images (maximum 12 touches on screen!) accomplish use layers performances. every image represented calayer, create calayer's , set image 'contents'. hierarchy this.
i have nsview.
- nsview "container_view"
- calayer "images_layer" sublayer of "container_view" layer (they have same frame)
- calayer "img_1_layer", calayer "img_2_layer", calayer "img_3_layer", etc sublayer of "images_layer"
as told before, can rotate, scale , move images.
double tap on single image, lock whole screen, can still rotate , move image 2 fingers.
now user can draw 1 finger on image.
the main problem have not experience graphics , example on internet draw line on view.
the question how draw finger on calayer. have calayer, cannot have nsview
many thantk in advance, sergio
hi mazyod, calayer class provides image big.
please try understand context
mainwindow root naturally
nsviewcontroller called mainviewcontroller custom nsview root view - view called container , it's set contentview of mainwindow
calayer called images_layer - it's layer added sublayer of container's layer
calayer called img_layer - it's layer added sublayer of images_layer (i have 1 of each image, set contents naturally, cgimageref)
when click on image (imglayer), 3 methods fired usual:
ontouchpointdown - x, y etc ontouchpointmove - x, y etc ontouchpointup - x, y etc
ok, have found.
- set layer's delegate
- override method in delegate
- call layer setneeddisplay method when need
-
(void)drawlayer:(calayer *)layer incontext:(cgcontextref)ctx
{
nsgraphicscontext *gc = [nsgraphicscontext graphicscontextwithgraphicsport:ctx flipped:no]; [nsgraphicscontext savegraphicsstate]; [nsgraphicscontext setcurrentcontext:gc]; // draw points bezier path [nsgraphicscontext restoregraphicsstate];
}
Comments
Post a Comment