the realPoints

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: the realPoints

Post by FourthWorld » Thu Jun 09, 2022 11:04 pm

FWIW, from revcommonlibrary:

Code: Select all

# OK-2007-07-05: Rewrote revRotatePoly and revPoints to fix bug 4882

# Parameters
#   pGraphic : A reference to a graphic
#   pAngle : The angle to rotate the graphic by
# Description
#   Performs a rotation transformation whose origin is the loc of the graphic and
#   whose magnitude is pAngle degrees. Preserves the topLeft of the graphic, but may
#   cause distortion due to rounding errors.
command revRotatePoly pGraphic, pAngle
    local tPoints, tFinalPoints
    local tLoc
    local tSinAngle, tCosAngle
    local tCurrentH, tCurrentV, tTransformedH, tTransformedV
    local tOrigLeft, tOrigTop
    
    lock screen
    lock messages
    if the realPoints of pGraphic is empty then
        put the effective points of pGraphic into tPoints
    else
        put the realPoints of pGraphic into tPoints
    end if
    put the loc of pGraphic into tLoc
    put item 1 of tLoc into tOrigLeft
    put item 2 of tLoc into tOrigTop
    put sin(pi*pAngle/180) into tSinAngle
    put cos(pi*pAngle/180) into tCosAngle
    repeat for each line tPoint in tPoints
        if tPoint is not empty then
            put item 1 of tPoint into tCurrentH
            put item 2 of tPoint into tCurrentV
            put (tOrigLeft+(tCosAngle*tCurrentH)-(tSinAngle*tCurrentV), tOrigTop+(tCosAngle*tCurrentV)+(tSinAngle*tCurrentH) ) after tFinalPoints
        end if
        put cr after tFinalPoints
    end repeat
    delete char -1 of tFinalPoints -- is CR
    if the style of pGraphic is among the items of "oval,rectangle,roundrect,regular" then
        set the style of pGraphic to "polygon"
    end if
    set points of pGraphic to tFinalPoints
    set the realPoints of pGraphic to tFinalPoints
    set loc of pGraphic to tLoc
    unlock messages
    unlock screen
end revRotatePoly

command revRotatePolygonOld pGraphic, pAngle
  local tTopLeft
  put the topLeft of pGraphic into tTopLeft
  
  local tPoints
  put revPoints(pGraphic) into tPoints
  
  local tLoc
  put the loc of pGraphic into tLoc
  
  local tSinAngle
  put sin(pAngle * (pi / 180)) into tSinAngle
  
  local tCosAngle
  put cos(pAngle * (pi / 180)) into tCosAngle
  
  local tLineCount
  put (the number of lines of tPoints) into tLineCount
  
  local tCurrentH, tCurrentV, tTransformedH, tTransformedV, tFinalPoints
  repeat for each line tPoint in tPoints
    if tPoint is empty then
      put empty & return after tFinalPoints
      next repeat
    end if 
    
    put item 1 of tPoint into tCurrentH
    put item 2 of tPoint into tCurrentV
    
    put trunc((tCosAngle * tCurrentH) - (tSinAngle * tCurrentV)) into tTransformedH
    put trunc((tSinAngle * tCurrentH) + (tCosAngle * tCurrentV)) into tTransformedV
    put tTransformedH + (item 1 of line 1 of tPoints) into tCurrentH
    put tTransformedV + (item 2 of line 1 of tPoints) into tCurrentV
    
    put tCurrentH,tCurrentV & return after tFinalPoints
  end repeat
  delete the last char of tFinalPoints
  
  set the points of pGraphic to tFinalPoints
  set the topLeft of pGraphic to tTopLeft
end revRotatePolygonOld
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the realPoints

Post by dunbarx » Fri Jun 10, 2022 7:35 pm

Richard.

So the line:

Code: Select all

set the realPoints of pGraphic to tFinalPoints
is where they appear (or are updated), each time revRotatePoly is called.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: the realPoints

Post by richmond62 » Fri Jun 10, 2022 7:53 pm

I wonder who 'rewrote'?

That stack script, having fossicked it out, makes quite instructive reading
about all sorts of things.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the realPoints

Post by dunbarx » Sat Jun 11, 2022 3:19 pm

Richmond

For me it confirms something that I find comforting. That LC uses LC for its own purposes, that "everything" is a stack, that sort of thing.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: the realPoints

Post by richmond62 » Sat Jun 11, 2022 3:34 pm

So it used to be, but not any more with the advent of LCB.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the realPoints

Post by dunbarx » Sat Jun 11, 2022 3:37 pm

but not any more with the advent of LCB.
Why on earth would you think that???

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: the realPoints

Post by richmond62 » Sat Jun 11, 2022 3:49 pm

Because it seems that far less of LC is written inwith itself than with version 7.x.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: the realPoints

Post by jacque » Sat Jun 11, 2022 5:24 pm

richmond62 wrote:
Sat Jun 11, 2022 3:49 pm
Because it seems that far less of LC is written inwith itself than with version 7.x.
Besides widgets and the occasional calls to outside APIs, both valuable features, what's different?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: the realPoints

Post by richmond62 » Sat Jun 11, 2022 5:32 pm

Maybe what is confusing me is that with version 7 you could hack stacks and the
hacks would "stay there" between boots, but, subsequently, with stacks generated
on the fly from obscure locations that seems no longer possible.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: the realPoints

Post by jacque » Sun Jun 12, 2022 5:36 pm

It's possible to save changes in script-only stacks. Either save normally in the IDE, or find them in the system file manager. On Mac the scripts are inside the app bundle.

Before adaptive Android icons were implemented I routinely changed the library that manages Android standalone builds.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: the realPoints

Post by FourthWorld » Sun Jun 12, 2022 7:12 pm

Any stack file, whether traditional binary or GitHub-focused script-only, can be saved to disk. Nothing has changed with that.

But it's never been a good idea to directly modify IDE stacks. Doing so creates a form of technical debt for yourself by forcing you to continually ask yourself whether you want to stop using new versions, ditch fixes in new versions so you can keep using your modified copies, or take on the onerous task of reimplantating your modifications with every release.

Much more efficient to change the IDE on the fly from scripts in an auto-start plugin.

devolution does that, if a living example would be helpful.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Talking LiveCode”